From c6805c1454f9dea518d7ba0f0eb4ecee1a1c6906 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Thu, 7 Jan 2016 10:30:29 +1000 Subject: Refactor scrolling track canvas in Editor class into two utility methods --- gtk2_ardour/editor.h | 3 +++ gtk2_ardour/editor_canvas_events.cc | 17 ++++------------- gtk2_ardour/editor_ops.cc | 25 +++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 13 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 77156cbb4c..b9a393f857 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -374,6 +374,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD bool scroll_up_one_track (bool skip_child_views = false); bool scroll_down_one_track (bool skip_child_views = false); + void scroll_left_step (); + void scroll_right_step (); + void prepare_for_cleanup (); void finish_cleanup (); diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc index 77cfde08e1..c889de072d 100644 --- a/gtk2_ardour/editor_canvas_events.cc +++ b/gtk2_ardour/editor_canvas_events.cc @@ -64,7 +64,6 @@ using Gtkmm2ext::Keyboard; bool Editor::track_canvas_scroll (GdkEventScroll* ev) { - framepos_t xdelta; int direction = ev->direction; /* this event arrives without transformation by the canvas, so we have @@ -134,21 +133,13 @@ Editor::track_canvas_scroll (GdkEventScroll* ev) break; case GDK_SCROLL_LEFT: - xdelta = (current_page_samples() / 8); - if (leftmost_frame > xdelta) { - reset_x_origin (leftmost_frame - xdelta); - } else { - reset_x_origin (0); - } + scroll_left_step (); + return true; break; case GDK_SCROLL_RIGHT: - xdelta = (current_page_samples() / 8); - if (max_framepos - xdelta > leftmost_frame) { - reset_x_origin (leftmost_frame + xdelta); - } else { - reset_x_origin (max_framepos - current_page_samples()); - } + scroll_right_step (); + return true; break; default: diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index cb67f1fc20..33e5e80efa 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -1589,6 +1589,31 @@ Editor::scroll_up_one_track (bool skip_child_views) return false; } +void +Editor::scroll_left_step () +{ + framepos_t xdelta = (current_page_samples() / 8); + + if (leftmost_frame > xdelta) { + reset_x_origin (leftmost_frame - xdelta); + } else { + reset_x_origin (0); + } +} + + +void +Editor::scroll_right_step () +{ + framepos_t xdelta = (current_page_samples() / 8); + + if (max_framepos - xdelta > leftmost_frame) { + reset_x_origin (leftmost_frame + xdelta); + } else { + reset_x_origin (max_framepos - current_page_samples()); + } +} + /* ZOOM */ void -- cgit v1.2.3