red-border selection for tracks, regions, and processors. requesting comments
[ardour.git] / gtk2_ardour / editor_canvas.cc
index 45292849523f8e7022cf0c5ad0b0df0f0cd4cd35..66caeb7bc6d72ab55899873d6bb4f22320070943 100644 (file)
@@ -805,7 +805,7 @@ Editor::entered_track_canvas (GdkEventCrossing */*ev*/)
 }
 
 void
-Editor::_ensure_time_axis_view_is_visible (TimeAxisView const & track, bool at_top)
+Editor::ensure_time_axis_view_is_visible (TimeAxisView const & track, bool at_top)
 {
        if (track.hidden()) {
                return;
@@ -822,19 +822,28 @@ Editor::_ensure_time_axis_view_is_visible (TimeAxisView const & track, bool at_t
        double const track_max_y = track.y_position () + track.effective_height ();
 
        if (!at_top && 
-           (track_min_y > current_view_min_y &&
-            track_max_y <= current_view_max_y)) {
+           (track_min_y >= current_view_min_y &&
+            track_max_y < current_view_max_y)) {
+               /* already visible, and caller did not ask to place it at the
+                * top of the track canvas
+                */
                return;
        }
 
        double new_value;
 
-       if (track_min_y < current_view_min_y) {
-               // Track is above the current view
+       if (at_top) {
                new_value = track_min_y;
        } else {
-               // Track is below the current view
-               new_value = track.y_position () + track.effective_height() - vertical_adjustment.get_page_size();
+               if (track_min_y < current_view_min_y) {
+                       // Track is above the current view
+                       new_value = track_min_y;
+               } else if (track_max_y > current_view_max_y) {
+                       // Track is below the current view
+                       new_value = track.y_position () + track.effective_height() - vertical_adjustment.get_page_size();
+               } else {
+                       new_value = track_min_y;
+               }
        }
 
        vertical_adjustment.set_value(new_value);
@@ -1290,10 +1299,12 @@ Editor::choose_canvas_cursor_on_entry (GdkEventCrossing* /*event*/, ItemType typ
                        cursor = _cursors->cross_hair;
                        break;
                case LeftFrameHandle:
-                       cursor = which_trim_cursor (true);
+                       if ( effective_mouse_mode() == MouseObject )  // (smart mode): if the user is in the top half, override the trim cursor, since they are in the range zone
+                               cursor = which_trim_cursor (true);  //alternatively, one could argue that we _should_ allow trims here, and disallow range selection
                        break;
                case RightFrameHandle:
-                       cursor = which_trim_cursor (false);
+                       if ( effective_mouse_mode() == MouseObject )  //see above
+                               cursor = which_trim_cursor (false);
                        break;
                case StartCrossFadeItem:
                        cursor = _cursors->fade_in;
@@ -1341,3 +1352,13 @@ Editor::choose_canvas_cursor_on_entry (GdkEventCrossing* /*event*/, ItemType typ
                set_canvas_cursor (cursor, false);
        }
 }
+
+double
+Editor::trackviews_height() const
+{
+       if (!_trackview_group) {
+               return 0;
+       }
+
+       return _visible_canvas_height - _trackview_group->canvas_origin().y;
+}