X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fselection.cc;h=3f6c282d3afbfd6f018fc7e721e670baa7af200c;hb=beb3eea62bf217d0a7b2a86a96d5c375329df10a;hp=fac18393af076d435a10ff34f444369610470d20;hpb=bb457bb960c5bd7ed538f9d31477293415739f68;p=ardour.git diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc index fac18393af..3f6c282d3a 100644 --- a/gtk2_ardour/selection.cc +++ b/gtk2_ardour/selection.cc @@ -296,32 +296,36 @@ Selection::add (TimeAxisView* track) } void -Selection::add (const RegionSelection& rs) +Selection::add (vector& v) { - if (!rs.empty()) { - regions.insert (regions.end(), rs.begin(), rs.end()); - RegionsChanged(); /* EMIT SIGNAL */ - } -} + /* XXX This method or the add (const RegionSelection&) needs to go + */ -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()); + bool changed = false; + + for (vector::iterator i = v.begin(); i != v.end(); ++i) { + 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()); + } } + } + + if (changed) { RegionsChanged (); } } void -Selection::add (vector& v) +Selection::add (const RegionSelection& rs) { - bool changed = false; + /* XXX This method or the add (const vector&) needs to go + */ - for (vector::iterator i = v.begin(); i != v.end(); ++i) { + bool changed = false; + + for (RegionSelection::const_iterator i = rs.begin(); i != rs.end(); ++i) { if (find (regions.begin(), regions.end(), (*i)) == regions.end()) { changed = regions.add ((*i)); if (Config->get_link_region_and_track_selection() && changed) { @@ -329,13 +333,25 @@ Selection::add (vector& v) } } } - + if (changed) { select_edit_group_regions (); RegionsChanged (); } } +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 (); + } +} + long Selection::add (nframes_t start, nframes_t end) { @@ -373,10 +389,17 @@ Selection::replace (uint32_t sid, nframes_t start, nframes_t end) } void -Selection::add (AutomationList* ac) +Selection::add (boost::shared_ptr cl) { - if (find (lines.begin(), lines.end(), ac) == lines.end()) { - lines.push_back (ac); + boost::shared_ptr al + = boost::dynamic_pointer_cast(cl); + if (!al) { + warning << "Programming error: Selected list is not an ARDOUR::AutomationList" << endmsg; + return; + return; + } + if (find (lines.begin(), lines.end(), al) == lines.end()) { + lines.push_back (al); LinesChanged(); } } @@ -477,9 +500,9 @@ Selection::remove (nframes_t start, nframes_t end) } void -Selection::remove (AutomationList *ac) +Selection::remove (boost::shared_ptr ac) { - list::iterator i; + AutomationSelection::iterator i; if ((i = find (lines.begin(), lines.end(), ac)) != lines.end()) { lines.erase (i); LinesChanged(); @@ -579,12 +602,18 @@ Selection::set (TimeAxisView* track, nframes_t start, nframes_t end) } void -Selection::set (AutomationList *ac) +Selection::set (boost::shared_ptr ac) { lines.clear(); add (ac); } +bool +Selection::selected (Marker* m) +{ + return find (markers.begin(), markers.end(), m) != markers.end(); +} + bool Selection::selected (TimeAxisView* tv) { @@ -778,3 +807,31 @@ Selection::add (Marker* m) MarkersChanged(); } } + +void +Selection::add (const list& m) +{ + markers.insert (markers.end(), m.begin(), m.end()); + MarkersChanged (); +} + +void +MarkerSelection::range (nframes64_t& s, nframes64_t& e) +{ + s = max_frames; + e = 0; + + for (MarkerSelection::iterator i = begin(); i != end(); ++i) { + + if ((*i)->position() < s) { + s = (*i)->position(); + } + + if ((*i)->position() > e) { + e = (*i)->position(); + } + } + + s = std::min (s, e); + e = std::max (s, e); +}