diff options
author | nick_m <mainsbridge@gmail.com> | 2017-06-17 04:08:56 +1000 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2017-07-22 02:15:20 +1000 |
commit | fb761a6fa7719fbd532dec08564142336316d92c (patch) | |
tree | 9d2218584a5befa4870f431210a1d1fc31fdda21 /gtk2_ardour | |
parent | d1932b23b3811f734d282e92b691473e446399b2 (diff) |
Rework time info box updates on region selection change
Should provide better performance as we now only listen for changes in the
selected regions. Testing every changed region to see if its in
the selection was not working very well under some circumstances.
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/time_info_box.cc | 70 | ||||
-rw-r--r-- | gtk2_ardour/time_info_box.h | 2 |
2 files changed, 35 insertions, 37 deletions
diff --git a/gtk2_ardour/time_info_box.cc b/gtk2_ardour/time_info_box.cc index 968e3ba9de..2c316c05a9 100644 --- a/gtk2_ardour/time_info_box.cc +++ b/gtk2_ardour/time_info_box.cc @@ -28,11 +28,12 @@ #include "ardour/profile.h" #include "ardour/session.h" -#include "time_info_box.h" #include "audio_clock.h" -#include "editor.h" -#include "control_point.h" #include "automation_line.h" +#include "control_point.h" +#include "editor.h" +#include "region_view.h" +#include "time_info_box.h" #include "pbd/i18n.h" @@ -136,7 +137,6 @@ TimeInfoBox::TimeInfoBox (std::string state_node_name, bool with_punch) Editor::instance().get_selection().TimeChanged.connect (sigc::mem_fun (*this, &TimeInfoBox::selection_changed)); Editor::instance().get_selection().RegionsChanged.connect (sigc::mem_fun (*this, &TimeInfoBox::selection_changed)); - Region::RegionPropertyChanged.connect (region_property_connections, invalidator (*this), boost::bind (&TimeInfoBox::region_property_change, this, _1, _2), gui_context()); Editor::instance().MouseModeChanged.connect (editor_connections, invalidator(*this), boost::bind (&TimeInfoBox::track_mouse_mode, this), gui_context()); } @@ -156,30 +156,6 @@ TimeInfoBox::track_mouse_mode () selection_changed (); } -void -TimeInfoBox::region_property_change (boost::shared_ptr<ARDOUR::Region> r, const PBD::PropertyChange& what_changed) -{ - Selection& selection (Editor::instance().get_selection()); - - if (selection.regions.empty()) { - return; - } - - PBD::PropertyChange our_interests; - - our_interests.add (ARDOUR::Properties::position); - our_interests.add (ARDOUR::Properties::length); - our_interests.add (ARDOUR::Properties::start); - - if (!what_changed.contains (our_interests)) { - return; - } - - if (selection.regions.contains (r)) { - selection_changed (); - } -} - bool TimeInfoBox::clock_button_release_event (GdkEventButton* ev, AudioClock* src) { @@ -255,11 +231,28 @@ TimeInfoBox::set_session (Session* s) } void +TimeInfoBox::region_selection_changed () +{ + framepos_t s, e; + Selection& selection (Editor::instance().get_selection()); + s = selection.regions.start(); + e = selection.regions.end_frame(); + selection_start->set_off (false); + selection_end->set_off (false); + selection_length->set_off (false); + selection_start->set (s); + selection_end->set (e); + selection_length->set (e, false, s); +} + +void TimeInfoBox::selection_changed () { framepos_t s, e; Selection& selection (Editor::instance().get_selection()); + region_property_connections.drop_connections(); + switch (Editor::instance().current_mouse_mode()) { case Editing::MouseContent: @@ -304,14 +297,19 @@ TimeInfoBox::selection_changed () selection_length->set (e - s + 1); } } else { - s = selection.regions.start(); - e = selection.regions.end_frame(); - selection_start->set_off (false); - selection_end->set_off (false); - selection_length->set_off (false); - selection_start->set (s); - selection_end->set (e); - selection_length->set (e - s + 1); + /* this is more efficient than tracking changes per region in large selections */ + std::set<boost::shared_ptr<ARDOUR::Playlist> > playlists; + for (RegionSelection::iterator s = selection.regions.begin(); s != selection.regions.end(); ++s) { + boost::shared_ptr<Playlist> pl = (*s)->region()->playlist(); + if (pl) { + playlists.insert (pl); + } + } + for (std::set<boost::shared_ptr<ARDOUR::Playlist> >::iterator ps = playlists.begin(); ps != playlists.end(); ++ps) { + (*ps)->ContentsChanged.connect (region_property_connections, invalidator (*this), + boost::bind (&TimeInfoBox::region_selection_changed, this), gui_context()); + } + region_selection_changed (); } break; diff --git a/gtk2_ardour/time_info_box.h b/gtk2_ardour/time_info_box.h index cf06b404c9..0ffd00a2be 100644 --- a/gtk2_ardour/time_info_box.h +++ b/gtk2_ardour/time_info_box.h @@ -70,13 +70,13 @@ private: PBD::ScopedConnectionList region_property_connections; void selection_changed (); + void region_selection_changed (); void sync_selection_mode (AudioClock*); void sync_punch_mode (AudioClock*); bool clock_button_release_event (GdkEventButton* ev, AudioClock* src); void track_mouse_mode (); - void region_property_change (boost::shared_ptr<ARDOUR::Region> r, const PBD::PropertyChange& what_changed); }; #endif /* __time_info_box_h__ */ |