fix horiz alignment (corner-radius is added to layout)
[ardour.git] / gtk2_ardour / editor_selection.cc
index 20ab6673a8702f5cd6a5488565bd03e3de1d83e8..7b08eaeaa6765aea2db48504efd9a6fa9a09037e 100644 (file)
 
 #include "pbd/stacktrace.h"
 
-#include "ardour/session.h"
+#include "ardour/midi_region.h"
 #include "ardour/playlist.h"
-#include "ardour/route_group.h"
 #include "ardour/profile.h"
-#include "ardour/midi_region.h"
-#include "ardour/audioplaylist.h"
+#include "ardour/route_group.h"
+#include "ardour/session.h"
 
 #include "control_protocol/control_protocol.h"
 
@@ -264,7 +263,6 @@ Editor::set_selected_track_as_side_effect (Selection::Operation op)
 
        case Selection::Extend:
                selection->clear();
-               cerr << ("Editor::set_selected_track_as_side_effect  case  Selection::Add  not yet implemented\n");
                break;
        }
 }
@@ -320,19 +318,39 @@ Editor::set_selected_control_point_from_click (bool press, Selection::Operation
                return false;
        }
 
-       if (!press) {
-               return true;
-       }
-
        switch (op) {
        case Selection::Set:
-               selection->set (clicked_control_point);
+               if (press) {
+                       selection->set (clicked_control_point);
+               }
                break;
        case Selection::Add:
-               selection->add (clicked_control_point);
+               if (press) {
+                       selection->add (clicked_control_point);
+               }
                break;
        case Selection::Toggle:
-               selection->toggle (clicked_control_point);
+               /* This is a bit of a hack; if we Primary-Click-Drag a control
+                  point (for push drag) we want the point we clicked on to be
+                  selected, otherwise we end up confusingly dragging an
+                  unselected point.  So here we ensure that the point is selected
+                  after the press, and if we subsequently get a release (meaning no
+                  drag occurred) we set things up so that the toggle has happened.
+               */
+               if (press && !selection->selected (clicked_control_point)) {
+                       /* This is the button press, and the control point is not selected; make it so,
+                          in case this press leads to a drag.  Also note that having done this, we don't
+                          need to toggle again on release.
+                       */
+                       selection->toggle (clicked_control_point);
+                       _control_point_toggled_on_press = true;
+               } else if (!press && !_control_point_toggled_on_press) {
+                       /* This is the release, and the point wasn't toggled on the press, so do it now */
+                       selection->toggle (clicked_control_point);
+               } else {
+                       /* Reset our flag */
+                       _control_point_toggled_on_press = false;
+               }
                break;
        case Selection::Extend:
                /* XXX */
@@ -761,7 +779,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op)
 
                                        RouteTimeAxisView* closest = 0;
                                        int distance = INT_MAX;
-                                       int key = rtv->route()->order_key ("editor");
+                                       int key = rtv->route()->order_key (EditorSort);
 
                                        for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
 
@@ -776,7 +794,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op)
                                                        if (result.second) {
                                                                /* newly added to already_in_selection */
 
-                                                               int d = artv->route()->order_key ("editor");
+                                                               int d = artv->route()->order_key (EditorSort);
 
                                                                d -= key;
 
@@ -792,7 +810,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op)
 
                                                /* now add all tracks between that one and this one */
 
-                                               int okey = closest->route()->order_key ("editor");
+                                               int okey = closest->route()->order_key (EditorSort);
 
                                                if (okey > key) {
                                                        swap (okey, key);
@@ -802,7 +820,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op)
                                                        RouteTimeAxisView* artv = dynamic_cast<RouteTimeAxisView*>(*x);
                                                        if (artv && artv != rtv) {
 
-                                                               int k = artv->route()->order_key ("editor");
+                                                               int k = artv->route()->order_key (EditorSort);
 
                                                                if (k >= okey && k <= key) {
 
@@ -1018,19 +1036,6 @@ Editor::sensitize_all_region_actions (bool s)
 void
 Editor::sensitize_the_right_region_actions ()
 {
-       if ((mouse_mode == MouseRange) || (mouse_mode != MouseObject && _join_object_range_state == JOIN_OBJECT_RANGE_RANGE)) {
-               sensitize_all_region_actions (false);
-               if (!selection->time.empty()) {
-                       _region_actions->get_action("split-region")->set_sensitive (true);
-               }
-               return;
-
-       } else if (mouse_mode != MouseObject) {
-               sensitize_all_region_actions (false);
-               return;
-       }
-
-       /* We get here if we are in Object mode */
 
        RegionSelection rs = get_regions_from_selection_and_entered ();
        sensitize_all_region_actions (!rs.empty ());