13
0

Refactor scrolling track canvas in Editor class into two utility methods

This commit is contained in:
Tim Mayberry 2016-01-07 10:30:29 +10:00
parent cd377f1278
commit c6805c1454
3 changed files with 32 additions and 13 deletions

View File

@ -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 ();

View File

@ -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:

View File

@ -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