diff options
author | David Robillard <d@drobilla.net> | 2014-11-20 17:36:09 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-11-22 00:46:15 -0500 |
commit | 41a9060df9a5261ea7c9ca848ebdd5854d40fd86 (patch) | |
tree | ad55a29d3868368033048effd02a5e9c68e89b26 | |
parent | 2966dd4a9fa7c293f9a2dade9d0b7899ef10a68d (diff) |
Move time converters only to the region views that actually need them.
A step towards sorting out time issues more solidly, the time situation of MIDI
region views and automation region views is slightly different.
-rw-r--r-- | gtk2_ardour/automation_region_view.cc | 25 | ||||
-rw-r--r-- | gtk2_ardour/automation_region_view.h | 10 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 30 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.h | 24 | ||||
-rw-r--r-- | gtk2_ardour/region_view.cc | 37 | ||||
-rw-r--r-- | gtk2_ardour/region_view.h | 11 |
6 files changed, 82 insertions, 55 deletions
diff --git a/gtk2_ardour/automation_region_view.cc b/gtk2_ardour/automation_region_view.cc index ab13a99c16..f7c2b6b642 100644 --- a/gtk2_ardour/automation_region_view.cc +++ b/gtk2_ardour/automation_region_view.cc @@ -39,14 +39,16 @@ #include "i18n.h" -AutomationRegionView::AutomationRegionView (ArdourCanvas::Container* parent, - AutomationTimeAxisView& time_axis, - boost::shared_ptr<ARDOUR::Region> region, - const Evoral::Parameter& param, - boost::shared_ptr<ARDOUR::AutomationList> list, - double spu, - uint32_t basic_color) +AutomationRegionView::AutomationRegionView (ArdourCanvas::Container* parent, + AutomationTimeAxisView& time_axis, + boost::shared_ptr<ARDOUR::Region> region, + const Evoral::Parameter& param, + boost::shared_ptr<ARDOUR::AutomationList> list, + double spu, + uint32_t basic_color) : RegionView(parent, time_axis, region, spu, basic_color, true) + , _region_relative_time_converter(region->session().tempo_map(), region->position()) + , _source_relative_time_converter(region->session().tempo_map(), region->position() - region->start()) , _parameter(param) { if (list) { @@ -251,6 +253,15 @@ AutomationRegionView::region_resized (const PBD::PropertyChange& what_changed) { RegionView::region_resized (what_changed); + if (what_changed.contains (ARDOUR::Properties::position)) { + _region_relative_time_converter.set_origin_b(_region->position()); + } + + if (what_changed.contains (ARDOUR::Properties::start) || + what_changed.contains (ARDOUR::Properties::position)) { + _source_relative_time_converter.set_origin_b (_region->position() - _region->start()); + } + if (!_line) { return; } diff --git a/gtk2_ardour/automation_region_view.h b/gtk2_ardour/automation_region_view.h index 4e97e2f367..d8f0b2637f 100644 --- a/gtk2_ardour/automation_region_view.h +++ b/gtk2_ardour/automation_region_view.h @@ -54,6 +54,14 @@ public: float times, boost::shared_ptr<const ARDOUR::AutomationList> slist); + ARDOUR::BeatsFramesConverter const & region_relative_time_converter () const { + return _region_relative_time_converter; + } + + ARDOUR::BeatsFramesConverter const & source_relative_time_converter () const { + return _source_relative_time_converter; + } + inline AutomationTimeAxisView* automation_view() const { return dynamic_cast<AutomationTimeAxisView*>(&trackview); } @@ -75,6 +83,8 @@ protected: void exited(); private: + ARDOUR::BeatsFramesConverter _region_relative_time_converter; + ARDOUR::BeatsFramesConverter _source_relative_time_converter; Evoral::Parameter _parameter; boost::shared_ptr<AutomationLine> _line; }; diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index cfb5108a60..503f2302c3 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -91,11 +91,16 @@ PBD::Signal1<void, MidiRegionView *> MidiRegionView::SelectionCleared; #define MIDI_BP_ZERO ((Config->get_first_midi_bank_is_zero())?0:1) -MidiRegionView::MidiRegionView (ArdourCanvas::Container *parent, RouteTimeAxisView &tv, - boost::shared_ptr<MidiRegion> r, double spu, uint32_t basic_color) +MidiRegionView::MidiRegionView (ArdourCanvas::Container* parent, + RouteTimeAxisView& tv, + boost::shared_ptr<MidiRegion> r, + double spu, + uint32_t basic_color) : RegionView (parent, tv, r, spu, basic_color) , _current_range_min(0) , _current_range_max(0) + , _region_relative_time_converter(r->session().tempo_map(), r->position()) + , _source_relative_time_converter(r->session().tempo_map(), r->position() - r->start()) , _active_notes(0) , _note_group (new ArdourCanvas::Container (group)) , _note_diff_command (0) @@ -128,12 +133,17 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Container *parent, RouteTimeAxisVi SelectionCleared.connect (_selection_cleared_connection, invalidator (*this), boost::bind (&MidiRegionView::selection_cleared, this, _1), gui_context ()); } -MidiRegionView::MidiRegionView (ArdourCanvas::Container *parent, RouteTimeAxisView &tv, - boost::shared_ptr<MidiRegion> r, double spu, uint32_t basic_color, - TimeAxisViewItem::Visibility visibility) +MidiRegionView::MidiRegionView (ArdourCanvas::Container* parent, + RouteTimeAxisView& tv, + boost::shared_ptr<MidiRegion> r, + double spu, + uint32_t basic_color, + TimeAxisViewItem::Visibility visibility) : RegionView (parent, tv, r, spu, basic_color, false, visibility) , _current_range_min(0) , _current_range_max(0) + , _region_relative_time_converter(r->session().tempo_map(), r->position()) + , _source_relative_time_converter(r->session().tempo_map(), r->position() - r->start()) , _active_notes(0) , _note_group (new ArdourCanvas::Container (parent)) , _note_diff_command (0) @@ -181,6 +191,8 @@ MidiRegionView::MidiRegionView (const MidiRegionView& other) , RegionView (other) , _current_range_min(0) , _current_range_max(0) + , _region_relative_time_converter(other.region_relative_time_converter()) + , _source_relative_time_converter(other.source_relative_time_converter()) , _active_notes(0) , _note_group (new ArdourCanvas::Container (get_canvas_group())) , _note_diff_command (0) @@ -210,6 +222,8 @@ MidiRegionView::MidiRegionView (const MidiRegionView& other, boost::shared_ptr<M : RegionView (other, boost::shared_ptr<Region> (region)) , _current_range_min(0) , _current_range_max(0) + , _region_relative_time_converter(other.region_relative_time_converter()) + , _source_relative_time_converter(other.source_relative_time_converter()) , _active_notes(0) , _note_group (new ArdourCanvas::Container (get_canvas_group())) , _note_diff_command (0) @@ -1353,11 +1367,17 @@ MidiRegionView::region_resized (const PropertyChange& what_changed) RegionView::region_resized(what_changed); if (what_changed.contains (ARDOUR::Properties::position)) { + _region_relative_time_converter.set_origin_b(_region->position()); set_duration(_region->length(), 0); if (_enable_display) { redisplay_model(); } } + + if (what_changed.contains (ARDOUR::Properties::start) || + what_changed.contains (ARDOUR::Properties::position)) { + _source_relative_time_converter.set_origin_b (_region->position() - _region->start()); + } } void diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 9885b98f3a..f6a6889017 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -275,6 +275,14 @@ public: /** Convert a timestamp in absolute frames to beats measured from source start*/ double absolute_frames_to_source_beats(framepos_t) const; + ARDOUR::BeatsFramesConverter const & region_relative_time_converter () const { + return _region_relative_time_converter; + } + + ARDOUR::BeatsFramesConverter const & source_relative_time_converter () const { + return _source_relative_time_converter; + } + void goto_previous_note (bool add_to_selection); void goto_next_note (bool add_to_selection); void change_note_lengths (bool, bool, Evoral::MusicalTime beats, bool start, bool end); @@ -379,26 +387,28 @@ private: uint8_t _current_range_min; uint8_t _current_range_max; - - typedef std::list<NoteBase*> Events; + + typedef std::list<NoteBase*> Events; typedef std::vector< boost::shared_ptr<PatchChange> > PatchChanges; - typedef std::vector< boost::shared_ptr<SysEx> > SysExes; + typedef std::vector< boost::shared_ptr<SysEx> > SysExes; + + ARDOUR::BeatsFramesConverter _region_relative_time_converter; + ARDOUR::BeatsFramesConverter _source_relative_time_converter; boost::shared_ptr<ARDOUR::MidiModel> _model; Events _events; PatchChanges _patch_changes; SysExes _sys_exes; Note** _active_notes; - ArdourCanvas::Container* _note_group; + ArdourCanvas::Container* _note_group; ARDOUR::MidiModel::NoteDiffCommand* _note_diff_command; Note* _ghost_note; double _last_ghost_x; double _last_ghost_y; - ArdourCanvas::Rectangle* _step_edit_cursor; + ArdourCanvas::Rectangle* _step_edit_cursor; Evoral::MusicalTime _step_edit_cursor_width; Evoral::MusicalTime _step_edit_cursor_position; - NoteBase* _channel_selection_scoped_note; - + NoteBase* _channel_selection_scoped_note; /** A group used to temporarily reparent _note_group to during start trims, so * that the notes don't move with the parent region view. diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index 49b47332ae..b562076884 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -65,12 +65,12 @@ static const int32_t sync_mark_width = 9; PBD::Signal1<void,RegionView*> RegionView::RegionViewGoingAway; -RegionView::RegionView (ArdourCanvas::Container* parent, +RegionView::RegionView (ArdourCanvas::Container* parent, TimeAxisView& tv, boost::shared_ptr<ARDOUR::Region> r, double spu, uint32_t basic_color, - bool automation) + bool automation) : TimeAxisViewItem (r->name(), *parent, tv, spu, basic_color, r->position(), r->length(), false, automation, (automation ? TimeAxisViewItem::ShowFrame : TimeAxisViewItem::Visibility (TimeAxisViewItem::ShowNameText| @@ -85,9 +85,7 @@ RegionView::RegionView (ArdourCanvas::Container* parent, , _pixel_width(1.0) , in_destructor(false) , wait_for_data(false) - , _silence_text (0) - , _region_relative_time_converter(r->session().tempo_map(), r->position()) - , _source_relative_time_converter(r->session().tempo_map(), r->position() - r->start()) + , _silence_text (0) { GhostRegion::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RegionView::remove_ghost, this, _1), gui_context()); } @@ -95,9 +93,7 @@ RegionView::RegionView (ArdourCanvas::Container* parent, RegionView::RegionView (const RegionView& other) : sigc::trackable(other) , TimeAxisViewItem (other) - , _silence_text (0) - , _region_relative_time_converter(other.region_relative_time_converter()) - , _source_relative_time_converter(other.source_relative_time_converter()) + , _silence_text (0) { /* derived concrete type will call init () */ @@ -112,9 +108,7 @@ RegionView::RegionView (const RegionView& other) RegionView::RegionView (const RegionView& other, boost::shared_ptr<Region> other_region) : sigc::trackable(other) , TimeAxisViewItem (other) - , _silence_text (0) - , _region_relative_time_converter(other_region->session().tempo_map(), other_region->position()) - , _source_relative_time_converter(other_region->session().tempo_map(), other_region->position() - other_region->start()) + , _silence_text (0) { /* this is a pseudo-copy constructor used when dragging regions around on the canvas. @@ -130,13 +124,13 @@ RegionView::RegionView (const RegionView& other, boost::shared_ptr<Region> other GhostRegion::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RegionView::remove_ghost, this, _1), gui_context()); } -RegionView::RegionView (ArdourCanvas::Container* parent, - TimeAxisView& tv, +RegionView::RegionView (ArdourCanvas::Container* parent, + TimeAxisView& tv, boost::shared_ptr<ARDOUR::Region> r, - double spu, - uint32_t basic_color, - bool recording, - TimeAxisViewItem::Visibility visibility) + double spu, + uint32_t basic_color, + bool recording, + TimeAxisViewItem::Visibility visibility) : TimeAxisViewItem (r->name(), *parent, tv, spu, basic_color, r->position(), r->length(), recording, false, visibility) , _region (r) , sync_mark(0) @@ -148,9 +142,7 @@ RegionView::RegionView (ArdourCanvas::Container* parent, , _pixel_width(1.0) , in_destructor(false) , wait_for_data(false) - , _silence_text (0) - , _region_relative_time_converter(r->session().tempo_map(), r->position()) - , _source_relative_time_converter(r->session().tempo_map(), r->position() - r->start()) + , _silence_text (0) { } @@ -417,11 +409,6 @@ RegionView::region_resized (const PropertyChange& what_changed) if (what_changed.contains (ARDOUR::Properties::position)) { set_position (_region->position(), 0); - _region_relative_time_converter.set_origin_b (_region->position()); - } - - if (what_changed.contains (ARDOUR::Properties::start) || what_changed.contains (ARDOUR::Properties::position)) { - _source_relative_time_converter.set_origin_b (_region->position() - _region->start()); } PropertyChange s_and_l; diff --git a/gtk2_ardour/region_view.h b/gtk2_ardour/region_view.h index 0837c075f0..cb6b56912f 100644 --- a/gtk2_ardour/region_view.h +++ b/gtk2_ardour/region_view.h @@ -97,14 +97,6 @@ class RegionView : public TimeAxisViewItem static PBD::Signal1<void,RegionView*> RegionViewGoingAway; - ARDOUR::BeatsFramesConverter const & region_relative_time_converter () const { - return _region_relative_time_converter; - } - - ARDOUR::BeatsFramesConverter const & source_relative_time_converter () const { - return _source_relative_time_converter; - } - /** Called when a front trim is about to begin */ virtual void trim_front_starting () {} @@ -192,9 +184,6 @@ class RegionView : public TimeAxisViewItem /** a text item to display strip silence statistics */ ArdourCanvas::Text* _silence_text; - - ARDOUR::BeatsFramesConverter _region_relative_time_converter; - ARDOUR::BeatsFramesConverter _source_relative_time_converter; }; #endif /* __gtk_ardour_region_view_h__ */ |