diff options
author | Carl Hetherington <carl@carlh.net> | 2011-11-20 19:38:37 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-11-20 19:38:37 +0000 |
commit | fe145ce380074f0e44e722d86ec82231f9281442 (patch) | |
tree | 6a291f6b2604671209a16f6c6c6e455025283b77 /gtk2_ardour | |
parent | f97151834544c364c5f7a194e7a6d4de0bbb5f49 (diff) |
Start autoscroll in from the right-hand edge of the screen if the editor list is not in view, so that autoscroll kind-of works in this situation (#4473 and #4216).
git-svn-id: svn://localhost/ardour2/branches/3.0@10718 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/editor.h | 3 | ||||
-rw-r--r-- | gtk2_ardour/editor_canvas.cc | 57 |
2 files changed, 59 insertions, 1 deletions
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index cc6917cf77..0450054bf0 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1696,6 +1696,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD framecnt_t autoscroll_x_distance; double autoscroll_y_distance; + bool _autoscroll_fudging; + int autoscroll_fudge_threshold () const; + static gint _autoscroll_canvas (void *); bool autoscroll_canvas (); void start_canvas_autoscroll (int x, int y); diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index 4d6945d6c0..ddbb1f0a12 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -479,12 +479,44 @@ Editor::drop_regions (const RefPtr<Gdk::DragContext>& /*context*/, _drags->end_grab (0); } +/** If the editor window is arranged such that the edge of the trackview is right up + * against the edge of the screen, autoscroll will not work very well. In this situation, + * we start autoscrolling some distance in from the right-hand-side of the screen edge; + * this is the distance at which that happens. + */ +int +Editor::autoscroll_fudge_threshold () const +{ + return current_page_frames() / 6; +} + void Editor::maybe_autoscroll (bool allow_horiz, bool allow_vert) { - framepos_t rightmost_frame = leftmost_frame + current_page_frames(); bool startit = false; + /* Work out the distance between the right hand edge of the trackview and the edge of + the monitor that it is on. + */ + + Glib::RefPtr<Gdk::Window> gdk_window = get_window (); + Gdk::Rectangle window_rect; + gdk_window->get_frame_extents (window_rect); + + Glib::RefPtr<Gdk::Screen> screen = get_screen (); + Gdk::Rectangle root_rect; + screen->get_root_window()->get_frame_extents (root_rect); + + Gtk::Allocation editor_list = _the_notebook.get_allocation (); + + int distance = root_rect.get_x() + root_rect.get_width() - window_rect.get_x() - window_rect.get_width(); + if (_the_notebook.is_visible ()) { + distance += editor_list.get_width(); + } + + /* Note whether we're fudging the autoscroll (see autoscroll_fudge_threshold) */ + _autoscroll_fudging = (distance < autoscroll_fudge_threshold ()); + double const ty = _drags->current_pointer_y() - get_trackview_group_vertical_offset (); autoscroll_y = 0; @@ -497,6 +529,11 @@ Editor::maybe_autoscroll (bool allow_horiz, bool allow_vert) startit = true; } + framepos_t rightmost_frame = leftmost_frame + current_page_frames(); + if (_autoscroll_fudging) { + rightmost_frame -= autoscroll_fudge_threshold (); + } + if (_drags->current_pointer_frame() > rightmost_frame && allow_horiz) { if (rightmost_frame < max_framepos) { autoscroll_x = 1; @@ -536,10 +573,28 @@ Editor::autoscroll_canvas () double new_pixel; double target_pixel; + /* Work out whether the right-hand side of this window is next to the edge of the screen */ + + Glib::RefPtr<Gdk::Window> gdk_window = get_window (); + Gdk::Rectangle window_rect; + gdk_window->get_frame_extents (window_rect); + + Glib::RefPtr<Gdk::Screen> screen = get_screen (); + Gdk::Rectangle root_rect; + screen->get_root_window()->get_frame_extents (root_rect); + + int distance = root_rect.get_x() + root_rect.get_width() - window_rect.get_x() - window_rect.get_width(); + if (_the_notebook.is_visible ()) { + distance += _the_notebook.get_allocation().get_width(); + } + if (autoscroll_x_distance != 0) { if (autoscroll_x > 0) { autoscroll_x_distance = (_drags->current_pointer_frame() - (leftmost_frame + current_page_frames())) / 3; + if (_autoscroll_fudging) { + autoscroll_x_distance += autoscroll_fudge_threshold () / 3; + } } else if (autoscroll_x < 0) { autoscroll_x_distance = (leftmost_frame - _drags->current_pointer_frame()) / 3; |