make shift-click (extend) selection operation on track headers etc. work
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 19 Dec 2006 20:11:42 +0000 (20:11 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 19 Dec 2006 20:11:42 +0000 (20:11 +0000)
git-svn-id: svn://localhost/ardour2/trunk@1233 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour.bindings
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_mouse.cc
gtk2_ardour/public_editor.h
gtk2_ardour/route_time_axis.cc
svn_revision.h

index 86f50e139f7b6d5c7c37cddca8b1cf4314efda35..bf5df40e9ec439430f0a9f5cf3a08d4d51a7d5b9 100644 (file)
 ; (gtk_accel_path "<Actions>/Editor/EditSelectRegionOptions" "")
 (gtk_accel_path "<Actions>/Editor/crop" "c")
 ; (gtk_accel_path "<Actions>/redirectmenu/newsend" "")
+; (gtk_accel_path "<Actions>/Editor/ToggleGeneric MIDISurfaceSubMenu" "")
 ; (gtk_accel_path "<Actions>/Editor/MeterFalloff" "")
 ; (gtk_accel_path "<Actions>/RegionList/rlRemove" "")
 (gtk_accel_path "<Actions>/Transport/GotoStart" "Home")
 ; (gtk_accel_path "<Actions>/Editor/Subframes80" "")
 ; (gtk_accel_path "<Actions>/options/FileHeaderFormatCAF" "")
 (gtk_accel_path "<Actions>/Common/ToggleLocations" "<Alt>l")
+; (gtk_accel_path "<Actions>/Editor/ToggleGeneric MIDISurface" "")
 (gtk_accel_path "<Actions>/Editor/editor-delete" "Delete")
 ; (gtk_accel_path "<Actions>/JACK/JACKLatency256" "")
 (gtk_accel_path "<Actions>/Editor/select-all-between-cursors" "u")
 ; (gtk_accel_path "<Actions>/Snap/snap-to-region-sync" "")
 (gtk_accel_path "<Actions>/Editor/edit-cursor-to-previous-region-sync" "apostrophe")
 ; (gtk_accel_path "<Actions>/redirectmenu/clear" "")
+; (gtk_accel_path "<Actions>/Editor/ToggleGeneric MIDISurfaceFeedback" "")
 ; (gtk_accel_path "<Actions>/Editor/PullupPlus4Minus1" "")
 ; (gtk_accel_path "<Actions>/JACK/JACKLatency512" "")
 (gtk_accel_path "<Actions>/Editor/edit-cursor-to-next-region-end" "<Control>bracketright")
index 23995529e4d6aebcdbe80644f5dceb5b9615cdb1..27c2802180c82fe843aa1dd4d0dd39412501e43c 100644 (file)
@@ -2861,6 +2861,114 @@ Editor::commit_reversible_command ()
        }
 }
 
+struct TrackViewByPositionSorter
+{
+    bool operator() (const TimeAxisView* a, const TimeAxisView *b) {
+           return a->y_position < b->y_position;
+    }
+};
+
+bool
+Editor::extend_selection_to_track (TimeAxisView& view)
+{
+       if (selection->tracks.empty()) {
+
+               if (!selection->selected (&view)) {
+                       selection->set (&view);
+                       return true;
+               } else {
+                       return false;
+               }
+       } 
+
+       /* something is already selected, so figure out which range of things to add */
+       
+       TrackViewList to_be_added;
+       TrackViewList sorted = track_views;
+       TrackViewByPositionSorter cmp;
+       bool passed_clicked = false;
+       bool forwards;
+
+       sorted.sort (cmp);
+
+       if (!selection->selected (&view)) {
+               to_be_added.push_back (&view);
+       }
+
+       /* figure out if we should go forward or backwards */
+
+       for (TrackViewList::iterator i = sorted.begin(); i != sorted.end(); ++i) {
+
+               if ((*i) == &view) {
+                       passed_clicked = true;
+               }
+
+               if (selection->selected (*i)) {
+                       if (passed_clicked) {
+                               forwards = true;
+                       } else {
+                               forwards = false;
+                       }
+                       break;
+               }
+       }
+                       
+       passed_clicked = false;
+
+       if (forwards) {
+
+               for (TrackViewList::iterator i = sorted.begin(); i != sorted.end(); ++i) {
+                                       
+                       if ((*i) == &view) {
+                               passed_clicked = true;
+                               continue;
+                       }
+                                       
+                       if (passed_clicked) {
+                               if ((*i)->hidden()) {
+                                       continue;
+                               }
+                               if (selection->selected (*i)) {
+                                       break;
+                               } else if (!(*i)->hidden()) {
+                                       to_be_added.push_back (*i);
+                               }
+                       }
+               }
+
+       } else {
+
+               for (TrackViewList::reverse_iterator r = sorted.rbegin(); r != sorted.rend(); ++r) {
+                                       
+                       if ((*r) == &view) {
+                               passed_clicked = true;
+                               continue;
+                       }
+                                       
+                       if (passed_clicked) {
+                                               
+                               if ((*r)->hidden()) {
+                                       continue;
+                               }
+                                               
+                               if (selection->selected (*r)) {
+                                       break;
+                               } else if (!(*r)->hidden()) {
+                                       to_be_added.push_back (*r);
+                               }
+                       }
+               }
+       }
+                       
+       if (!to_be_added.empty()) {
+               selection->add (to_be_added);
+               return true;
+       }
+       
+       return false;
+}
+
+
 bool
 Editor::set_selected_track (TimeAxisView& view, Selection::Operation op, bool no_remove)
 {
@@ -2889,13 +2997,14 @@ Editor::set_selected_track (TimeAxisView& view, Selection::Operation op, bool no
        case Selection::Set:
                if (selection->selected (&view) && selection->tracks.size() == 1) {
                        /* no commit necessary */
-               } 
-
-               selection->set (&view);
+               } else {
+                       selection->set (&view);
+                       commit = true;
+               }
                break;
                
        case Selection::Extend:
-               /* not defined yet */
+               commit = extend_selection_to_track (view);
                break;
        }
 
index 2f435336caa8161171941e8b5ac280b5e1d084aa..6e302b93d6090fa45fd725b39f982ba6284a08ab 100644 (file)
@@ -217,6 +217,8 @@ class Editor : public PublicEditor
        Selection& get_selection() const { return *selection; }
        Selection& get_cut_buffer() const { return *cut_buffer; }
 
+       bool extend_selection_to_track (TimeAxisView&);
+
        void play_selection ();
        void select_all_in_track (Selection::Operation op);
        void select_all (Selection::Operation op);
index 1df4910d8cd0bd4e1b32b69a5e1e32f4063809b0..4752ae16a280dc4fcb52ca8e0d83dac1ce96f29a 100644 (file)
@@ -316,6 +316,7 @@ Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType it
 
        switch (item_type) {
        case RegionItem:
+               /* XXX make tying track/region selection optional */
                c1 = set_selected_track_from_click (op, true);
                c2 = set_selected_regionview_from_click (press, op, true);
                commit = (c1 || c2);
@@ -323,6 +324,7 @@ Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType it
                
        case RegionViewNameHighlight:
        case RegionViewName:
+               /* XXX make tying track/region selection optional */
                c1 = set_selected_track_from_click (op, true);
                c2 = set_selected_regionview_from_click (press, op, true);
                commit = (c1 || c2);
@@ -331,6 +333,7 @@ Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType it
        case GainAutomationControlPointItem:
        case PanAutomationControlPointItem:
        case RedirectAutomationControlPointItem:
+               /* XXX make tying track/region selection optional */
                c1 = set_selected_track_from_click (op, true);
                c2 = set_selected_control_point_from_click (op, false);
                commit = (c1 || c2);
index 8a105cd0aacfeb64429c6fb6e5f8aebb601ea4c1..1e93e177358d810ba798569052379b4e0cb8a994 100644 (file)
@@ -93,6 +93,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway
        virtual gulong frame_to_pixel (nframes_t frame) = 0;
        virtual Selection& get_selection() const = 0;
        virtual Selection& get_cut_buffer() const = 0;
+       virtual bool extend_selection_to_track (TimeAxisView&) = 0;
        virtual void play_selection () = 0;
        virtual void set_show_measures (bool yn) = 0;
        virtual bool show_measures () const = 0;
index b3a95711f1caeca0b17649a46821460f7a790936..87f5e8e7cc3e23b2cba96dff1abb668a77840c6e 100644 (file)
@@ -1012,7 +1012,13 @@ RouteTimeAxisView::selection_click (GdkEventButton* ev)
                break;
 
        case Selection::Extend:
-               /* not defined yet */
+               if (tracks->size() > 1) {
+                       /* add each one, do not "extend" */
+                       editor.get_selection().add (*tracks);
+               } else {
+                       /* extend to the single track */
+                       editor.extend_selection_to_track (*tracks->front());
+               }
                break;
 
        case Selection::Add:
index 89d7c9563a41078b37be2f1cad774eb44fded135..7d354bf298d3e8a1b720a2d14ecc9e99aa411b1a 100644 (file)
@@ -1,4 +1,4 @@
 #ifndef __ardour_svn_revision_h__
 #define __ardour_svn_revision_h__
-static const char* ardour_svn_revision = "1180";
+static const char* ardour_svn_revision = "1232";
 #endif