summaryrefslogtreecommitdiff
path: root/gtk2_ardour/selection.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2017-01-27 19:18:33 +0100
committerPaul Davis <paul@linuxaudiosystems.com>2017-01-27 22:17:53 +0100
commitcc82fc675b096c3dfec76d0c45671b78c85007cf (patch)
tree4acd88079a01f3f52f624818186c6db14b83e0c7 /gtk2_ardour/selection.cc
parent4821def1736c55866fc6f354dcd98a61c3451101 (diff)
remove editor/mixer selection change signals; make editor and mixer use PresentationInfo::Change more correctly; make Selection a bit smarter when setting track selection
Diffstat (limited to 'gtk2_ardour/selection.cc')
-rw-r--r--gtk2_ardour/selection.cc89
1 files changed, 57 insertions, 32 deletions
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<boost::shared_ptr<Playlist> >& 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<T>::operator== (set<T> 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;
-}