some fixes/improvements for track selection; add upload target to manual makefile...
[ardour.git] / gtk2_ardour / editor_mouse.cc
index 79581381e46da01fa9cae788aa8d6889a4578537..10f4c0eb032f354f3b9e3c7732984ace8dbe68a6 100644 (file)
@@ -290,8 +290,6 @@ void
 Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
 {
        bool commit = false;
-       bool c1; 
-       bool c2;
 
        /* in object/audition/timefx mode, any button press sets
           the selection if the object can be selected. this is a
@@ -303,11 +301,23 @@ Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType it
 
        if (((mouse_mode != MouseObject) &&
             (mouse_mode != MouseAudition || item_type != RegionItem) &&
-            (mouse_mode != MouseTimeFX || item_type != RegionItem)) ||
+            (mouse_mode != MouseTimeFX || item_type != RegionItem) &&
+            (mouse_mode != MouseRange)) ||
+
            (event->type != GDK_BUTTON_PRESS && event->type != GDK_BUTTON_RELEASE || event->button.button > 3)) {
                
                return;
        }
+
+       if (event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) {
+
+               if ((event->button.state & Keyboard::RelevantModifierKeyMask) && event->button.button != 1) {
+                       
+                       /* no selection action on modified button-2 or button-3 events */
+                       
+                       return;
+               }
+       }
            
        Selection::Operation op = Keyboard::selection_type (event->button.state);
        bool press = (event->type == GDK_BUTTON_PRESS);
@@ -316,70 +326,52 @@ 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);
+               if (mouse_mode != MouseRange) {
+                       commit = set_selected_regionview_from_click (press, op, true);
+               }
                break;
                
        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);
+               if (mouse_mode != MouseRange) {
+                       commit = set_selected_regionview_from_click (press, op, true);
+               }
                break;
 
        case FadeInHandleItem:
        case FadeInItem:
        case FadeOutHandleItem:
        case FadeOutItem:
-               /* 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);
+               if (mouse_mode != MouseRange) {
+                       commit = set_selected_regionview_from_click (press, op, true);
+               }
+               break;
                
        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);
+               if (mouse_mode != MouseRange) {
+                       commit = set_selected_control_point_from_click (op, false);
+               }
                break;
                
        case StreamItem:
-               commit = set_selected_track_from_click (op, true);
+               /* for context click or range selection, select track */
+               if (event->button.button == 3) {
+                       commit = set_selected_track_from_click (press, op, true);
+               } else if (event->type == GDK_BUTTON_PRESS && mouse_mode == MouseRange) {
+                       commit = set_selected_track_from_click (press, op, false);
+               }
                break;
                    
        case AutomationTrackItem:
-               commit = set_selected_track_from_click (op, true);
+               commit = set_selected_track_from_click (press, op, true);
                break;
                
        default:
                break;
        }
        
-#define SELECT_TRACK_FROM_CANVAS_IN_RANGE_MODE
-#ifdef  SELECT_TRACK_FROM_CANVAS_IN_RANGE_MODE
-       /* in range mode, button 1/2/3 press potentially selects a track */
-
-       if (mouse_mode == MouseRange && 
-           event->type == GDK_BUTTON_PRESS && 
-           event->button.button <= 3) {
-               
-               switch (item_type) {
-               case StreamItem:
-               case RegionItem:
-               case AutomationTrackItem:
-                       commit = set_selected_track_from_click (op, true);
-                       break;
-
-               default:
-                       break;
-               }
-       }
-#endif
        if (commit) {
                commit_reversible_command ();
        }
@@ -508,10 +500,9 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp
                        break;
                        
                case MouseObject:
-                       if (Keyboard::modifier_state_contains (event->button.state, 
-                                                              Keyboard::ModifierMask(Keyboard::Control|Keyboard::Alt))
-                               && event->type == GDK_BUTTON_PRESS) {
-
+                       if (Keyboard::modifier_state_contains (event->button.state, Keyboard::ModifierMask(Keyboard::Control|Keyboard::Alt)) &&
+                           event->type == GDK_BUTTON_PRESS) {
+                               
                                start_rubberband_select (item, event);
 
                        } else if (event->type == GDK_BUTTON_PRESS) {
@@ -4695,16 +4686,15 @@ Editor::drag_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event)
                return;
        }
 
-//     if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
-//             snap_to (drag_info.current_pointer_frame);
-               
-//             if (drag_info.first_move) {
-//                     snap_to (drag_info.grab_frame);
-//             }
-//     }
-               
+       if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
+               if (drag_info.first_move) {
+                       snap_to (drag_info.grab_frame);
+               } 
+               snap_to (drag_info.current_pointer_frame);
+       }
 
        /* base start and end on initial click position */
+
        if (drag_info.current_pointer_frame < drag_info.grab_frame) {
                start = drag_info.current_pointer_frame;
                end = drag_info.grab_frame;
@@ -4716,8 +4706,7 @@ Editor::drag_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event)
        if (drag_info.current_pointer_y < drag_info.grab_y) {
                y1 = drag_info.current_pointer_y;
                y2 = drag_info.grab_y;
-       }
-       else {
+       } else {
                y2 = drag_info.current_pointer_y;
                y1 = drag_info.grab_y;
        }
@@ -4764,7 +4753,7 @@ Editor::end_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event)
                Selection::Operation op = Keyboard::selection_type (event->button.state);
                bool commit;
 
-               begin_reversible_command (_("select regions"));
+               begin_reversible_command (_("rubberband selection"));
 
                if (drag_info.grab_frame < drag_info.last_pointer_frame) {
                        commit = select_all_within (drag_info.grab_frame, drag_info.last_pointer_frame, y1, y2, op);
@@ -4777,6 +4766,7 @@ Editor::end_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event)
                }
                
        } else {
+               selection->clear_tracks();
                selection->clear_regions();
                selection->clear_points ();
                selection->clear_lines ();