From b59990cdf2d36b63c489f70e7cab8700db848ea7 Mon Sep 17 00:00:00 2001 From: YPozdnyakov Date: Mon, 9 Feb 2015 15:37:02 +0200 Subject: [PATCH] [Summary]: add check of max/min value of temporal zoom tool --- gtk2_ardour/editor.h | 2 ++ gtk2_ardour/editor_ops.cc | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 56fd23f93f..d2e10ffea1 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -2203,6 +2203,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void midi_output_chosen (WavesDropdown*, int); void populate_midi_inout_dropdowns (); void populate_midi_inout_dropdown (bool playback); + + int64_t get_zoom_from_temporal_adjustment_value (double); Gtk::Image& midi_marker_input_activity_image; Gtk::Image& midi_marker_output_activity_image; diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 03c14dc5a8..aaa3a98b8c 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -1858,8 +1858,12 @@ Editor::temporal_zoom_to_frame (bool coarser, framepos_t frame) range_before /= 2; } - - if (new_spp == 0) { + + int64_t upper_value_spp = get_zoom_from_temporal_adjustment_value (_temporal_zoom_adjustment.get_upper ()); + int64_t lower_value_spp = get_zoom_from_temporal_adjustment_value (_temporal_zoom_adjustment.get_lower ()); + if (new_spp > upper_value_spp || new_spp < lower_value_spp) { + // we shouldn't change temporal zoom value + // if we out of range return; } @@ -1881,6 +1885,12 @@ Editor::temporal_zoom_to_frame (bool coarser, framepos_t frame) reposition_and_zoom (new_leftmost, new_spp); } +int64_t +Editor::get_zoom_from_temporal_adjustment_value (double temporal_adjustment_value) +{ + return (int64_t)(pow (2.0f, (int)temporal_adjustment_value) + 0.001); +} + void Editor::temporal_zoom_by_slider () { @@ -1890,8 +1900,8 @@ Editor::temporal_zoom_by_slider () _zoom_tool_was_used = false; return ; } - double value = _temporal_zoom_adjustment.get_value(); - int64_t spp = (int64_t)(pow (2.0f, (int)value) + 0.001); + + int64_t spp = get_zoom_from_temporal_adjustment_value (_temporal_zoom_adjustment.get_value ()); set_zoom_focus (ZoomFocusPlayhead); temporal_zoom (spp); }