From cc82fc675b096c3dfec76d0c45671b78c85007cf Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 27 Jan 2017 19:18:33 +0100 Subject: remove editor/mixer selection change signals; make editor and mixer use PresentationInfo::Change more correctly; make Selection a bit smarter when setting track selection --- gtk2_ardour/selection.cc | 89 +++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 32 deletions(-) (limited to 'gtk2_ardour/selection.cc') diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc index 98b5d62c10..36a4a087a9 100644 --- a/gtk2_ardour/selection.cc +++ b/gtk2_ardour/selection.cc @@ -57,7 +57,6 @@ Selection::Selection (const PublicEditor* e) : tracks (e) , editor (e) , next_time_id (0) - , _no_tracks_changed (false) { clear (); @@ -132,13 +131,13 @@ void Selection::clear_tracks (bool with_signal) { if (!tracks.empty()) { + PresentationInfo::ChangeSuspender cs; + for (TrackViewList::iterator x = tracks.begin(); x != tracks.end(); ++x) { (*x)->set_selected (false); } + tracks.clear (); - if (!_no_tracks_changed && with_signal) { - TracksChanged(); - } } } @@ -290,9 +289,6 @@ Selection::toggle (TimeAxisView* track) tracks.erase (i); } - if (!_no_tracks_changed) { - TracksChanged(); - } } void @@ -429,19 +425,18 @@ Selection::add (const list >& pllist) } void -Selection::add (const TrackViewList& track_list) +Selection::add (TrackViewList const & track_list) { clear_objects(); //enforce object/range exclusivity + PresentationInfo::ChangeSuspender cs; + TrackViewList added = tracks.add (track_list); if (!added.empty()) { for (TrackViewList::iterator x = added.begin(); x != added.end(); ++x) { (*x)->set_selected (true); } - if (!_no_tracks_changed) { - TracksChanged (); - } } } @@ -639,31 +634,18 @@ Selection::remove (TimeAxisView* track) if ((i = find (tracks.begin(), tracks.end(), track)) != tracks.end()) { track->set_selected (false); tracks.erase (i); - - if (!_no_tracks_changed) { - TracksChanged(); - } } } void Selection::remove (const TrackViewList& track_list) { - bool changed = false; - for (TrackViewList::const_iterator i = track_list.begin(); i != track_list.end(); ++i) { TrackViewList::iterator x = find (tracks.begin(), tracks.end(), *i); if (x != tracks.end()) { (*i)->set_selected (false); tracks.erase (x); - changed = true; - } - } - - if (changed) { - if (!_no_tracks_changed) { - TracksChanged(); } } } @@ -797,7 +779,23 @@ void Selection::set (TimeAxisView* track) { clear_objects (); //enforce object/range exclusivity - clear_tracks (false); + + PresentationInfo::ChangeSuspender cs; + + if (!tracks.empty()) { + + if (tracks.size() == 1 && tracks.front() == track) { + /* already single selection: nothing to do */ + return; + } + + for (TrackViewList::iterator x = tracks.begin(); x != tracks.end(); ++x) { + (*x)->set_selected (false); + } + + tracks.clear (); + } + add (track); } @@ -805,7 +803,40 @@ void Selection::set (const TrackViewList& track_list) { clear_objects(); //enforce object/range exclusivity - clear_tracks (false); + + PresentationInfo::ChangeSuspender cs; + + if (!tracks.empty()) { + + /* cannot use set::operator== (set const &) here, because + * apparently the ordering used within 2 sets is not + * necessarily the same. + */ + + if (tracks.size() == track_list.size()) { + bool missing = false; + + for (TrackViewList::const_iterator x = track_list.begin(); x != track_list.end(); ++x) { + if (find (tracks.begin(), tracks.end(), *x) == tracks.end()) { + missing = true; + } + } + + if (!missing) { + /* already same selection: nothing to do */ + return; + } + } + + /* argument is different from existing selection */ + + for (TrackViewList::iterator x = tracks.begin(); x != tracks.end(); ++x) { + (*x)->set_selected (false); + } + + tracks.clear (); + } + add (track_list); } @@ -1551,9 +1582,3 @@ Selection::remove_regions (TimeAxisView* t) i = tmp; } } - -void -Selection::block_tracks_changed (bool yn) -{ - _no_tracks_changed = yn; -} -- cgit v1.2.3