From 5bdc03ab5ce43722e175b5bc139f768e9cb0a744 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 16 Jan 2010 00:44:56 +0000 Subject: [PATCH] When dragging the summary viewbox with a click outside the viewbox, clamp x and y if the drag started below/above or to the left/right of the box, respectively. Also scale maximum track height in the summary according to the summary's height. git-svn-id: svn://localhost/ardour2/branches/3.0@6504 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor_summary.cc | 34 ++++++++++++++++++++++++++++------ gtk2_ardour/editor_summary.h | 5 +++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/gtk2_ardour/editor_summary.cc b/gtk2_ardour/editor_summary.cc index aae814d8e5..a6168fee2a 100644 --- a/gtk2_ardour/editor_summary.cc +++ b/gtk2_ardour/editor_summary.cc @@ -153,11 +153,10 @@ EditorSummary::render (cairo_t* cr) _y_scale = static_cast (_height) / h; /* tallest a region should ever be in the summary, in pixels */ - int const tallest_region_pixels = 4; + int const tallest_region_pixels = _height / 16; if (max_height * _y_scale > tallest_region_pixels) { _y_scale = static_cast (tallest_region_pixels) / max_height; - } /* render regions */ @@ -292,6 +291,22 @@ EditorSummary::on_button_press_event (GdkEventButton* ev) _start_mouse_x = ev->x; _start_mouse_y = ev->y; + if ( + _start_editor_x.first <= _start_mouse_x && _start_mouse_x <= _start_editor_x.second && + _start_editor_y.first <= _start_mouse_y && _start_mouse_y <= _start_editor_y.second + ) { + + _start_position = IN_VIEWBOX; + + } else if (_start_editor_x.first <= _start_mouse_x && _start_mouse_x <= _start_editor_x.second) { + + _start_position = BELOW_OR_ABOVE_VIEWBOX; + + } else { + + _start_position = TO_LEFT_OR_RIGHT_OF_VIEWBOX; + } + if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { /* primary-modifier-click: start a zoom drag */ @@ -358,10 +373,17 @@ EditorSummary::on_motion_notify_event (GdkEventMotion* ev) _moved = true; - xr.first += ev->x - _start_mouse_x; - xr.second += ev->x - _start_mouse_x; - yr.first += ev->y - _start_mouse_y; - yr.second += ev->y - _start_mouse_y; + /* don't alter x if we clicked outside and above or below the viewbox */ + if (_start_position == IN_VIEWBOX || _start_position == TO_LEFT_OR_RIGHT_OF_VIEWBOX) { + xr.first += ev->x - _start_mouse_x; + xr.second += ev->x - _start_mouse_x; + } + + /* don't alter y if we clicked outside and to the left or right of the viewbox */ + if (_start_position == IN_VIEWBOX || _start_position == BELOW_OR_ABOVE_VIEWBOX) { + yr.first += ev->y - _start_mouse_y; + yr.second += ev->y - _start_mouse_y; + } if (xr.first < 0) { xr.second -= xr.first; diff --git a/gtk2_ardour/editor_summary.h b/gtk2_ardour/editor_summary.h index c59210e657..369a72fc28 100644 --- a/gtk2_ardour/editor_summary.h +++ b/gtk2_ardour/editor_summary.h @@ -70,6 +70,11 @@ private: std::pair _start_editor_y; double _start_mouse_x; double _start_mouse_y; + enum { + IN_VIEWBOX, + BELOW_OR_ABOVE_VIEWBOX, + TO_LEFT_OR_RIGHT_OF_VIEWBOX + } _start_position; bool _move_dragging; double _x_offset;