Improve ctrl-click behaviour of automation points. Should fix #3385.
authorCarl Hetherington <carl@carlh.net>
Tue, 10 Aug 2010 01:52:49 +0000 (01:52 +0000)
committerCarl Hetherington <carl@carlh.net>
Tue, 10 Aug 2010 01:52:49 +0000 (01:52 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7584 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/automation_line.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_markers.cc
gtk2_ardour/editor_mouse.cc
gtk2_ardour/editor_selection.cc

index eca2b705cecc48936f24179f0a73e33a0179a057..9a22c1ebad34f02cfd0cc468daefbd05fb46a604 100644 (file)
@@ -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);
        }
 
 }
index ecd13778a145859bab47f461cc62c2e51d00e2a0..755d0344cd767a26d89f50f9610e95f5ebeb1390 100644 (file)
@@ -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;
 
index 09a1573829308fb7e1a400d2d9783f70d3c38d02..98ceca5b8ae0330201bc8ba703e2a7690dda3001 100644 (file)
@@ -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:
index 23332047bd6bd8152c224ecec446cd829ab1d63f..ae97d5c38ffcb7821401fede87fb430a4abe7cd6 100644 (file)
@@ -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);
        }
 
 }
index 3cc3129bf6e86afbfeb1293950cc40d828c27c00..11de83c6a018bde6ad6af7a13a162e589408c1b9 100644 (file)
@@ -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 ()) {
index f8555505b29ec31c4cefcca70e97e387bafe505d..53ce04351d3f2f98f7538a1dc77f280422fde1f9 100644 (file)
@@ -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<Selectable*> 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<Selectable*>::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: