diff options
author | Carl Hetherington <carl@carlh.net> | 2011-05-25 16:38:49 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-05-25 16:38:49 +0000 |
commit | fb39b47861a69a774a5f9f2029e7644811af7339 (patch) | |
tree | 9911e943141814c27f8a03b94e384a215f1c7b8f /gtk2_ardour/editor_drag.cc | |
parent | 711db34a81eed3748684bc52b17a56292ffe4092 (diff) |
Zoom session when the mouse pointer is moved up and down during a playhead drag.
git-svn-id: svn://localhost/ardour2/branches/3.0@9586 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_drag.cc')
-rw-r--r-- | gtk2_ardour/editor_drag.cc | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 1784e59944..f8078475d3 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -2082,6 +2082,8 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c) { Drag::start_grab (event, c); + _grab_zoom = _editor->frames_per_unit; + framepos_t where = _editor->event_frame (event, 0, 0); _editor->snap_to_with_modifier (where, event); @@ -2110,17 +2112,46 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c) void CursorDrag::motion (GdkEvent* event, bool) { - framepos_t const adjusted_frame = adjusted_current_frame (event); + if (_drags->current_pointer_y() != last_pointer_y()) { - if (adjusted_frame == last_pointer_frame()) { - return; - } + /* zoom when we move the pointer up and down */ - fake_locate (adjusted_frame); - + /* y range to operate over (pixels) */ + double const y_range = 256; + /* we will multiply the grab zoom by a factor between scale_range and scale_range^-1 */ + double const scale_range = 4; + /* dead zone around the grab point in which to do no zooming (pixels) */ + double const dead_zone = 16; + + /* current dy */ + double dy = _drags->current_pointer_y() - grab_y(); + + if (dy < -dead_zone || dy > dead_zone) { + /* we are outside the dead zone; remove it from our calculation */ + if (dy < 0) { + dy += dead_zone; + } else { + dy -= dead_zone; + } + + /* get a number from -1 to 1 as dy ranges from -y_range to y_range */ + double udy = max (min (dy / y_range, 1.0), -1.0); + + /* and zoom, using playhead focus temporarily */ + Editing::ZoomFocus const zf = _editor->get_zoom_focus (); + _editor->set_zoom_focus (Editing::ZoomFocusPlayhead); + _editor->temporal_zoom (_grab_zoom * pow (scale_range, -udy)); + _editor->set_zoom_focus (zf); + } + } + + framepos_t const adjusted_frame = adjusted_current_frame (event); + if (adjusted_frame != last_pointer_frame()) { + fake_locate (adjusted_frame); #ifdef GTKOSX - _editor->update_canvas_now (); + _editor->update_canvas_now (); #endif + } } void |