: tracks (e)
, editor (e)
, next_time_id (0)
+ , _no_tracks_changed (false)
{
clear ();
/* we have disambiguate which remove() for the compiler */
void (Selection::*track_remove)(TimeAxisView*) = &Selection::remove;
- TimeAxisView::CatchDeletion.connect (*this, MISSING_INVALIDATOR, ui_bind (track_remove, this, _1), gui_context());
+ TimeAxisView::CatchDeletion.connect (*this, MISSING_INVALIDATOR, boost::bind (track_remove, this, _1), gui_context());
void (Selection::*marker_remove)(Marker*) = &Selection::remove;
- Marker::CatchDeletion.connect (*this, MISSING_INVALIDATOR, ui_bind (marker_remove, this, _1), gui_context());
+ Marker::CatchDeletion.connect (*this, MISSING_INVALIDATOR, boost::bind (marker_remove, this, _1), gui_context());
+
+ void (Selection::*point_remove)(ControlPoint*) = &Selection::remove;
+ ControlPoint::CatchDeletion.connect (*this, MISSING_INVALIDATOR, boost::bind (point_remove, this, _1), gui_context());
}
#if 0
clear_playlists ();
clear_midi_notes ();
clear_midi_regions ();
+ clear_markers ();
}
void
if (!regions.empty()) {
regions.clear_all ();
RegionsChanged();
+ if (Config->get_link_region_and_track_selection()) {
+ clear_tracks ();
+ }
}
}
{
if (!tracks.empty()) {
tracks.clear ();
- TracksChanged();
+ if (!_no_tracks_changed) {
+ TracksChanged();
+ }
}
}
tracks.erase (i);
}
- TracksChanged();
+ if (!_no_tracks_changed) {
+ TracksChanged();
+ }
}
void
TrackViewList added = tracks.add (track_list);
if (!added.empty()) {
- TracksChanged ();
+ if (!_no_tracks_changed) {
+ TracksChanged ();
+ }
}
}
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);
list<TimeAxisView*>::iterator i;
if ((i = find (tracks.begin(), tracks.end(), track)) != tracks.end()) {
tracks.erase (i);
- TracksChanged();
+ if (!_no_tracks_changed) {
+ TracksChanged();
+ }
+ }
+}
+
+void
+Selection::remove (ControlPoint* p)
+{
+ PointSelection::iterator i = find (points.begin(), points.end(), p);
+ if (i != points.end ()) {
+ points.erase (i);
}
}
}
if (changed) {
- TracksChanged();
+ if (!_no_tracks_changed) {
+ TracksChanged();
+ }
}
}
Selection::set (RegionView* r, bool also_clear_tracks)
{
clear_regions ();
- if (also_clear_tracks) {
+ if (also_clear_tracks && !Config->get_link_region_and_track_selection()) {
+ /* clear_regions() will have done this if the link preference
+ * is enabled
+ */
clear_tracks ();
}
add (r);
void
Selection::set (vector<RegionView*>& v)
{
+ bool had_regions = !regions.empty();
+
clear_regions ();
+
if (Config->get_link_region_and_track_selection()) {
- clear_tracks ();
- // make sure to deselect any automation selections
- clear_points();
+ if (had_regions) {
+ /* there were regions before, so we're changing the
+ * region selection (likely), thus link region/track
+ * selection. relevant tracks will get selected
+ * as we ::add() below.
+ */
+ clear_tracks ();
+ // make sure to deselect any automation selections
+ clear_points();
+ }
}
add (v);
}
return find (regions.begin(), regions.end(), rv) != regions.end();
}
+bool
+Selection::selected (ControlPoint* cp)
+{
+ return find (points.begin(), points.end(), cp) != points.end();
+}
+
bool
Selection::empty (bool internal_selection)
{
Selection::toggle (ControlPoint* cp)
{
cp->set_selected (!cp->get_selected ());
- set_point_selection_from_line (cp->line ());
+ PointSelection::iterator i = find (points.begin(), points.end(), cp);
+ if (i == points.end()) {
+ points.push_back (cp);
+ } else {
+ points.erase (i);
+ }
+
+ PointsChanged (); /* EMIT SIGNAL */
}
void
Selection::toggle (vector<ControlPoint*> const & cps)
{
for (vector<ControlPoint*>::const_iterator i = cps.begin(); i != cps.end(); ++i) {
- (*i)->set_selected (!(*i)->get_selected ());
+ toggle (*i);
}
-
- set_point_selection_from_line (cps.front()->line ());
}
void
add (selectables);
}
+void
+Selection::add (PointSelection const & s)
+{
+ for (PointSelection::const_iterator i = s.begin(); i != s.end(); ++i) {
+ points.push_back (*i);
+ }
+}
void
Selection::add (list<Selectable*> const & selectables)
Selection::add (ControlPoint* cp)
{
cp->set_selected (true);
- set_point_selection_from_line (cp->line ());
+ points.push_back (cp);
+ PointsChanged (); /* EMIT SIGNAL */
}
void
Selection::add (vector<ControlPoint*> const & cps)
{
for (vector<ControlPoint*>::const_iterator i = cps.begin(); i != cps.end(); ++i) {
- (*i)->set_selected (true);
+ add (*i);
}
-
- set_point_selection_from_line (cps.front()->line ());
}
void
return;
}
- /* We're going to set up the PointSelection from the selected ControlPoints
- on this point's line, so we need to deselect all ControlPoints before
- we re-add this one.
- */
-
for (uint32_t i = 0; i < cp->line().npoints(); ++i) {
cp->line().nth (i)->set_selected (false);
}
- vector<ControlPoint*> cps;
- cps.push_back (cp);
- add (cps);
+ clear_points ();
+ add (cp);
}
void
Selection::add (const list<Marker*>& m)
{
markers.insert (markers.end(), m.begin(), m.end());
+ markers.sort ();
+ markers.unique ();
+
MarkersChanged ();
}
e = std::max (s, e);
}
-/** Automation control point selection is mostly manipulated using the selected state
- * of the ControlPoints themselves. For example, to add a point to a selection, its
- * ControlPoint is marked as selected and then this method is called. It sets up
- * our PointSelection from the selected ControlPoints of a given AutomationLine.
- *
- * We can't use ControlPoints directly in the selection, as we need to express a
- * selection of not just a visible ControlPoint but also (possibly) some invisible
- * points nearby. Hence the selection stores AutomationRanges, and these are synced
- * with ControlPoint selection state using AutomationLine::set_selected_points.
- */
-
-void
-Selection::set_point_selection_from_line (AutomationLine const & line)
-{
- points.clear ();
-
- AutomationRange current (DBL_MAX, 0, 1, 0, &line.trackview);
-
- for (uint32_t i = 0; i < line.npoints(); ++i) {
- ControlPoint const * cp = line.nth (i);
-
- if (cp->get_selected()) {
- /* x and y position of this control point in coordinates suitable for
- an AutomationRange (ie model time and fraction of track height)
- */
- double const x = (*(cp->model()))->when;
- double const y = 1 - (cp->get_y() / line.trackview.current_height ());
-
- /* work out the position of a rectangle the size of a control point centred
- on this point
- */
-
- double const size = cp->size ();
- double const x_size = line.time_converter().from (line.trackview.editor().pixel_to_frame (size));
- double const y_size = size / line.trackview.current_height ();
-
- double const x1 = max (0.0, x - x_size / 2);
- double const x2 = x + x_size / 2;
- double const y1 = max (0.0, y - y_size / 2);
- double const y2 = y + y_size / 2;
-
- /* extend the current AutomationRange to put this point in */
- current.start = min (current.start, x1);
- current.end = max (current.end, x2);
- current.low_fract = min (current.low_fract, y1);
- current.high_fract = max (current.high_fract, y2);
-
- } else {
- /* this point isn't selected; if the current AutomationRange has some
- stuff in it, push it onto the list and make a new one
- */
- if (current.start < DBL_MAX) {
- points.push_back (current);
- current = AutomationRange (DBL_MAX, 0, 1, 0, &line.trackview);
- }
- }
- }
-
- /* Maybe push the current AutomationRange, as above */
- if (current.start < DBL_MAX) {
- points.push_back (current);
- current = AutomationRange (DBL_MAX, 0, 1, 0, &line.trackview);
- }
-
- PointsChanged (); /* EMIT SIGNAL */
-}
-
XMLNode&
Selection::get_state () const
{
}
}
+ for (MarkerSelection::const_iterator i = markers.begin(); i != markers.end(); ++i) {
+ XMLNode* t = node->add_child (X_("Marker"));
+
+ bool is_start;
+ Location* loc = editor->find_location_from_marker (*i, is_start);
+
+ t->add_property (X_("id"), atoi (loc->id().to_s().c_str()));
+ t->add_property (X_("start"), is_start ? X_("yes") : X_("no"));
+ }
+
return *node;
}
add (atv.get());
}
}
+
+ } else if ((*i)->name() == X_("Marker")) {
+
+ XMLProperty* prop_id = (*i)->property (X_("id"));
+ XMLProperty* prop_start = (*i)->property (X_("start"));
+ assert (prop_id);
+ assert (prop_start);
+
+ PBD::ID id (prop_id->value ());
+ Marker* m = editor->find_marker_from_location_id (id, string_is_affirmative (prop_start->value ()));
+ if (m) {
+ add (m);
+ }
+
}
+
}
return 0;
i = tmp;
}
}
+
+void
+Selection::block_tracks_changed (bool yn)
+{
+ _no_tracks_changed = yn;
+}