non-copy region drag now creates a new track when a region is dragged to the drop...
[ardour.git] / gtk2_ardour / selection.cc
index 146d9a65c50f9c2da169a66bdc44b8a7988e0aac..6465bb4d44592d1ecd2748c71bdf6d9ddddc7bd7 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <algorithm>
 #include <sigc++/bind.h>
+
 #include "pbd/error.h"
 #include "pbd/stacktrace.h"
 
@@ -125,6 +126,9 @@ void
 Selection::clear_tracks ()
 {
        if (!tracks.empty()) {
+               for (TrackViewList::iterator x = tracks.begin(); x != tracks.end(); ++x) {
+                       (*x)->set_selected (false);
+               }
                tracks.clear ();
                if (!_no_tracks_changed) {
                        TracksChanged();
@@ -249,8 +253,10 @@ Selection::toggle (TimeAxisView* track)
        TrackSelection::iterator i;
 
        if ((i = find (tracks.begin(), tracks.end(), track)) == tracks.end()) {
+               track->set_selected (true);
                tracks.push_back (track);
        } else {
+               track->set_selected (false);
                tracks.erase (i);
        }
 
@@ -392,6 +398,9 @@ Selection::add (const TrackViewList& track_list)
        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 ();
                }
@@ -402,6 +411,7 @@ void
 Selection::add (TimeAxisView* track)
 {
        TrackViewList tr;
+       track->set_selected (true);
        tr.push_back (track);
        add (tr);
 }
@@ -589,6 +599,7 @@ Selection::remove (TimeAxisView* track)
 {
        list<TimeAxisView*>::iterator i;
        if ((i = find (tracks.begin(), tracks.end(), track)) != tracks.end()) {
+               track->set_selected (false);
                tracks.erase (i);
                if (!_no_tracks_changed) {
                        TracksChanged();
@@ -596,15 +607,6 @@ Selection::remove (TimeAxisView* track)
        }
 }
 
-void
-Selection::remove (ControlPoint* p)
-{
-       PointSelection::iterator i = find (points.begin(), points.end(), p);
-       if (i != points.end ()) {
-               points.erase (i);
-       }
-}
-
 void
 Selection::remove (const TrackViewList& track_list)
 {
@@ -614,6 +616,7 @@ Selection::remove (const TrackViewList& track_list)
 
                TrackViewList::iterator x = find (tracks.begin(), tracks.end(), *i);
                if (x != tracks.end()) {
+                       (*i)->set_selected (false);
                        tracks.erase (x);
                        changed = true;
                }
@@ -626,6 +629,15 @@ Selection::remove (const TrackViewList& track_list)
        }
 }
 
+void
+Selection::remove (ControlPoint* p)
+{
+       PointSelection::iterator i = find (points.begin(), points.end(), p);
+       if (i != points.end ()) {
+               points.erase (i);
+       }
+}
+
 void
 Selection::remove (const MidiNoteSelection& midi_list)
 {
@@ -924,7 +936,7 @@ Selection::selected (Marker* m)
 bool
 Selection::selected (TimeAxisView* tv)
 {
-       return find (tracks.begin(), tracks.end(), tv) != tracks.end();
+       return tv->get_selected ();
 }
 
 bool