From 48063c15df30d7616739fd001f09e33720ccfa29 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 10 Aug 2010 01:52:49 +0000 Subject: [PATCH] Improve ctrl-click behaviour of automation points. Should fix #3385. git-svn-id: svn://localhost/ardour2/branches/3.0@7584 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/automation_line.cc | 17 +++++++++++++++-- gtk2_ardour/editor.h | 2 +- gtk2_ardour/editor_drag.cc | 6 +++--- gtk2_ardour/editor_markers.cc | 2 +- gtk2_ardour/editor_mouse.cc | 4 +--- gtk2_ardour/editor_selection.cc | 25 ++++++++++++++++--------- 6 files changed, 37 insertions(+), 19 deletions(-) diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index eca2b705ce..9a22c1ebad 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -990,7 +990,13 @@ AutomationLine::get_selectables ( if (collecting) { - results.push_back (new AutomationSelectable (nstart, nend, botfrac, topfrac, &trackview)); + AutomationSelectable* s = new AutomationSelectable (nstart, nend, botfrac, topfrac, &trackview); + PointSelection& ps = trackview.editor().get_selection().points; + if (find (ps.begin(), ps.end(), *s) != ps.end()) { + s->set_selected (true); + } + + results.push_back (s); collecting = false; nstart = DBL_MAX; nend = 0; @@ -1000,7 +1006,14 @@ AutomationLine::get_selectables ( } if (collecting) { - results.push_back (new AutomationSelectable (nstart, nend, botfrac, topfrac, &trackview)); + AutomationSelectable* s = new AutomationSelectable (nstart, nend, botfrac, topfrac, &trackview); + + PointSelection& ps = trackview.editor().get_selection().points; + if (find (ps.begin(), ps.end(), *s) != ps.end()) { + s->set_selected (true); + } + + results.push_back (s); } } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index ecd13778a1..755d0344cd 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1657,7 +1657,7 @@ public: /* object rubberband select process */ - bool select_all_within (nframes64_t, nframes64_t, double, double, TrackViewList const &, Selection::Operation op); + bool select_all_within (nframes64_t, nframes64_t, double, double, TrackViewList const &, Selection::Operation, bool); ArdourCanvas::SimpleRect *rubberband_rect; diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 09a1573829..98ceca5b8a 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -3107,9 +3107,9 @@ RubberbandSelectDrag::finished (GdkEvent* event, bool movement_occurred) _editor->begin_reversible_command (_("rubberband selection")); if (grab_frame() < last_pointer_frame()) { - committed = _editor->select_all_within (grab_frame(), last_pointer_frame() - 1, y1, y2, _editor->track_views, op); + committed = _editor->select_all_within (grab_frame(), last_pointer_frame() - 1, y1, y2, _editor->track_views, op, false); } else { - committed = _editor->select_all_within (last_pointer_frame(), grab_frame() - 1, y1, y2, _editor->track_views, op); + committed = _editor->select_all_within (last_pointer_frame(), grab_frame() - 1, y1, y2, _editor->track_views, op, false); } if (!committed) { @@ -3662,7 +3662,7 @@ RangeMarkerBarDrag::finished (GdkEvent* event, bool movement_occurred) switch (_editor->mouse_mode) { case MouseObject: /* find the two markers on either side and then make the selection from it */ - _editor->select_all_within (start, end, 0.0f, FLT_MAX, _editor->track_views, Selection::Set); + _editor->select_all_within (start, end, 0.0f, FLT_MAX, _editor->track_views, Selection::Set, false); break; case MouseRange: diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 23332047bd..ae97d5c38f 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -764,7 +764,7 @@ Editor::marker_menu_select_all_selectables_using_range () bool is_start; if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) { - select_all_within (l->start(), l->end() - 1, 0, DBL_MAX, track_views, Selection::Set); + select_all_within (l->start(), l->end() - 1, 0, DBL_MAX, track_views, Selection::Set, false); } } diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 3cc3129bf6..11de83c6a0 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -1070,8 +1070,6 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp return true; } - button_selection (item, event, item_type); - if (!_drags->active () && (Keyboard::is_delete_event (&event->button) || Keyboard::is_context_menu_event (&event->button) || @@ -1113,7 +1111,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT return true; } - /* first, see if we're finishing a drag ... */ + /* see if we're finishing a drag */ bool were_dragging = false; if (_drags->active ()) { diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index f8555505b2..53ce04351d 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -241,13 +241,6 @@ Editor::set_selected_control_point_from_click (Selection::Operation op, bool /*n return false; } - if (clicked_control_point->selected()) { - /* the clicked control point is already selected; others may be as well, so - don't change the selection. - */ - return true; - } - /* We know the ControlPoint that was clicked, but (as discussed in automation_selectable.h) * selected automation data are described by areas on the AutomationLine. A ControlPoint * represents any model points in the space that it takes up, so the AutomationSelectable @@ -270,7 +263,7 @@ Editor::set_selected_control_point_from_click (Selection::Operation op, bool /*n _trackview_group->w2i (dummy, y2); /* and set up the selection */ - return select_all_within (x1, x2, y1, y2, selection->tracks, op); + return select_all_within (x1, x2, y1, y2, selection->tracks, op, true); } void @@ -983,9 +976,12 @@ Editor::invert_selection () * @param end End time in session frames. * @param top Top (lower) y limit in trackview coordinates (ie 0 at the top of the track view) * @param bottom Bottom (higher) y limit in trackview coordinates (ie 0 at the top of the track view) + * @param preserve_if_selected true to leave the current selection alone if all of the selectables within the region are already selected. */ bool -Editor::select_all_within (framepos_t start, framepos_t end, double top, double bot, const TrackViewList& tracklist, Selection::Operation op) +Editor::select_all_within ( + framepos_t start, framepos_t end, double top, double bot, const TrackViewList& tracklist, Selection::Operation op, bool preserve_if_selected + ) { list found; @@ -1002,6 +998,17 @@ Editor::select_all_within (framepos_t start, framepos_t end, double top, double return false; } + if (preserve_if_selected) { + list::iterator i = found.begin(); + while (i != found.end() && (*i)->get_selected()) { + ++i; + } + + if (i == found.end()) { + return false; + } + } + begin_reversible_command (_("select all within")); switch (op) { case Selection::Add: