Editor Summary: implement summary_zoom_step() to lessen redundant code.

This commit is contained in:
Ben Loftis 2017-07-19 08:12:25 -05:00
parent 1955ff3ad2
commit 255d633edd
2 changed files with 25 additions and 25 deletions

View File

@ -544,6 +544,25 @@ EditorSummary::set_cursor (Position p)
}
}
void
EditorSummary::summary_zoom_step ( int steps /* negative steps to zoom "out" , positive steps to zoom "in" */ )
{
pair<double, double> xn;
get_editor (&xn);
// {
// xn.first = (_editor->leftmost_sample () - _start) * _x_scale;
// xn.second = xn.first + _editor->current_page_samples() * _x_scale;
// }
xn.first += steps;
xn.second -= steps;
set_overlays_dirty ();
set_editor_x (xn);
}
bool
EditorSummary::on_motion_notify_event (GdkEventMotion* ev)
{
@ -570,14 +589,7 @@ EditorSummary::on_motion_notify_event (GdkEventMotion* ev)
double const dy = ev->y - _zoom_last_y;
pair<double, double> xn;
get_editor (&xn);
xn.first -= dy;
xn.second += dy;
set_overlays_dirty ();
set_editor_x (xn);
summary_zoom_step( dy );
_zoom_last_y = ev->y;
@ -675,29 +687,15 @@ EditorSummary::on_scroll_event (GdkEventScroll* ev)
switch (ev->direction) {
case GDK_SCROLL_UP: {
//ToDo: use function summary_zoom_in/out
pair<double, double> xn;
get_editor (&xn);
xn.first += 2;
xn.second -= 2;
set_overlays_dirty ();
set_editor_x (xn);
summary_zoom_step( -2 );
return true;
} break;
case GDK_SCROLL_DOWN: {
pair<double, double> xn;
get_editor (&xn);
xn.first -= 2;
xn.second += 2;
set_overlays_dirty ();
set_editor_x (xn);
summary_zoom_step( 2 );
return true;
} break;

View File

@ -83,6 +83,8 @@ private:
framepos_t position_to_playhead_frame_to_position (double pos) const;
void set_overlays_dirty (int, int, int, int);
void summary_zoom_step ( int steps );
framepos_t _start; ///< start frame of the overview
framepos_t _end; ///< end frame of the overview