update drobilla's fascistic dir-locals.el to force emacs users into whitespace submis...
[ardour.git] / gtk2_ardour / selection.cc
index 42f1a80f0b117671a9c75f7a873e52fce06ce672..d0b2cab5c7749a67ff763e3574886bf56c54aff8 100644 (file)
@@ -304,7 +304,7 @@ Selection::toggle (vector<RegionView*>& r)
 }
 
 long
-Selection::toggle (nframes_t start, nframes_t end)
+Selection::toggle (framepos_t start, framepos_t end)
 {
        AudioRangeComparator cmp;
 
@@ -400,7 +400,7 @@ Selection::add (vector<RegionView*>& v)
                if (find (regions.begin(), regions.end(), (*i)) == regions.end()) {
                        changed = regions.add ((*i));
                        if (Config->get_link_region_and_track_selection() && changed) {
-                               add (&(*i)->get_trackview());
+                               add (&(*i)->get_time_axis_view());
                        }
                }
        }
@@ -422,7 +422,7 @@ Selection::add (const RegionSelection& rs)
                if (find (regions.begin(), regions.end(), (*i)) == regions.end()) {
                        changed = regions.add ((*i));
                        if (Config->get_link_region_and_track_selection() && changed) {
-                               add (&(*i)->get_trackview());
+                               add (&(*i)->get_time_axis_view());
                        }
                }
        }
@@ -436,11 +436,13 @@ void
 Selection::add (RegionView* r)
 {
        if (find (regions.begin(), regions.end(), r) == regions.end()) {
-               regions.add (r);
-               if (Config->get_link_region_and_track_selection()) {
-                       add (&r->get_trackview());
-               }
-               RegionsChanged ();
+               bool changed = regions.add (r);
+                if (Config->get_link_region_and_track_selection() && changed) {
+                        add (&r->get_time_axis_view());
+                }
+                if (changed) {
+                        RegionsChanged ();
+                }
        }
 }
 
@@ -452,7 +454,7 @@ Selection::add (MidiRegionView* mrv)
                /* XXX should we do this? */
 #if 0
                if (Config->get_link_region_and_track_selection()) {
-                       add (&mrv->get_trackview());
+                       add (&mrv->get_time_axis_view());
                }
 #endif
                MidiRegionsChanged ();
@@ -460,7 +462,7 @@ Selection::add (MidiRegionView* mrv)
 }
 
 long
-Selection::add (nframes_t start, nframes_t end)
+Selection::add (framepos_t start, framepos_t end)
 {
        AudioRangeComparator cmp;
 
@@ -476,7 +478,7 @@ Selection::add (nframes_t start, nframes_t end)
 }
 
 void
-Selection::replace (uint32_t sid, nframes_t start, nframes_t end)
+Selection::replace (uint32_t sid, framepos_t start, framepos_t end)
 {
        for (list<AudioRange>::iterator i = time.begin(); i != time.end(); ++i) {
                if ((*i).id == sid) {
@@ -610,8 +612,8 @@ Selection::remove (RegionView* r)
                RegionsChanged ();
        }
 
-       if (Config->get_link_region_and_track_selection() && !regions.involves (r->get_trackview())) {
-               remove (&r->get_trackview());
+       if (Config->get_link_region_and_track_selection() && !regions.involves (r->get_time_axis_view())) {
+               remove (&r->get_time_axis_view());
        }
 }
 
@@ -627,8 +629,8 @@ Selection::remove (MidiRegionView* mrv)
 
 #if 0
        /* XXX fix this up ? */
-       if (Config->get_link_region_and_track_selection() && !regions.involves (r->get_trackview())) {
-               remove (&r->get_trackview());
+       if (Config->get_link_region_and_track_selection() && !regions.involves (r->get_time_axis_view())) {
+               remove (&r->get_time_axis_view());
        }
 #endif
 }
@@ -652,7 +654,7 @@ Selection::remove (uint32_t selection_id)
 }
 
 void
-Selection::remove (nframes_t /*start*/, nframes_t /*end*/)
+Selection::remove (framepos_t /*start*/, framepos_t /*end*/)
 {
 }
 
@@ -742,7 +744,7 @@ Selection::set (vector<RegionView*>& v)
  *  the list of tracks it applies to.
  */
 long
-Selection::set (nframes_t start, nframes_t end)
+Selection::set (framepos_t start, framepos_t end)
 {
        if ((start == 0 && end == 0) || end < start) {
                return 0;
@@ -1002,9 +1004,9 @@ Selection::add (const list<Marker*>& m)
 }
 
 void
-MarkerSelection::range (nframes64_t& s, nframes64_t& e)
+MarkerSelection::range (framepos_t& s, framepos_t& e)
 {
-       s = max_frames;
+       s = max_framepos;
        e = 0;
 
        for (MarkerSelection::iterator i = begin(); i != end(); ++i) {
@@ -1107,7 +1109,7 @@ Selection::get_state () const
                } else if (atv) {
                        XMLNode* t = node->add_child (X_("AutomationView"));
                        t->add_property (X_("id"), atoi (atv->parent_route()->id().to_s().c_str()));
-                       t->add_property (X_("parameter"), EventTypeMap::instance().to_symbol (atv->control()->parameter ()));
+                       t->add_property (X_("parameter"), EventTypeMap::instance().to_symbol (atv->parameter ()));
                }
        }
 
@@ -1129,8 +1131,9 @@ Selection::set_state (XMLNode const & node, int)
                        assert (prop_id);
                        PBD::ID id (prop_id->value ());
                        RouteTimeAxisView* rtv = editor->get_route_view_by_route_id (id);
-                       assert (rtv);
-                       add (rtv);
+                       if (rtv) {
+                               add (rtv);
+                       }
                        
                } else if ((*i)->name() == X_("AutomationView")) {
                        
@@ -1142,20 +1145,37 @@ Selection::set_state (XMLNode const & node, int)
 
                        PBD::ID id (prop_id->value ());
                        RouteTimeAxisView* rtv = editor->get_route_view_by_route_id (id);
-                       assert (rtv);
-                       
-                       boost::shared_ptr<AutomationTimeAxisView> atv = rtv->automation_child (EventTypeMap::instance().new_parameter (prop_parameter->value ()));
+
+                       if (rtv) {
+                               boost::shared_ptr<AutomationTimeAxisView> atv = rtv->automation_child (EventTypeMap::instance().new_parameter (prop_parameter->value ()));
                         
-                        /* the automation could be for an entity that was never saved
-                           in the session file. Don't freak out if we can't find
-                           it.
-                        */
-
-                        if (atv) {
-                                add (atv.get());
-                        }
+                               /* the automation could be for an entity that was never saved
+                                  in the session file. Don't freak out if we can't find
+                                  it.
+                               */
+                               
+                               if (atv) {
+                                       add (atv.get());
+                               }
+                       }
                }
        }
 
        return 0;
 }
+
+void
+Selection::remove_regions (TimeAxisView* t)
+{
+       RegionSelection::iterator i = regions.begin();
+       while (i != regions.end ()) {
+               RegionSelection::iterator tmp = i;
+               ++tmp;
+
+               if (&(*i)->get_time_axis_view() == t) {
+                       remove (*i);
+               }
+
+               i = tmp;
+       }
+}