summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_ops.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2012-06-20 14:14:27 +0000
committerCarl Hetherington <carl@carlh.net>2012-06-20 14:14:27 +0000
commit3c7f6a4a4cb46b50a4d5b239f2d2d6dfef3525a5 (patch)
tree7b9db403f25e87e58b8d02c05e363ee7fc012950 /gtk2_ardour/editor_ops.cc
parent0fba3e073cc274b6cd3d6ac02d1eecf7bbd5cc5a (diff)
Unify clamping of frames-per-unit values during zoom; should help with #3514.
git-svn-id: svn://localhost/ardour2/branches/3.0@12796 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_ops.cc')
-rw-r--r--gtk2_ardour/editor_ops.cc33
1 files changed, 25 insertions, 8 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index eacf0c51bd..46a69ce6af 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -1327,14 +1327,30 @@ Editor::tav_zoom_smooth (bool coarser, bool force_all)
_routes->resume_redisplay ();
}
+bool
+Editor::clamp_frames_per_unit (double& fpu) const
+{
+ bool clamped = false;
+
+ if (fpu < 2.0) {
+ fpu = 2.0;
+ clamped = true;
+ }
+
+ if (max_framepos / fpu < 800) {
+ fpu = max_framepos / 800.0;
+ clamped = true;
+ }
+
+ return clamped;
+}
+
void
Editor::temporal_zoom_step (bool coarser)
{
ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_step, coarser)
- double nfpu;
-
- nfpu = frames_per_unit;
+ double nfpu = frames_per_unit;
if (coarser) {
nfpu = min (9e6, nfpu * 1.61803399);
@@ -1346,9 +1362,11 @@ Editor::temporal_zoom_step (bool coarser)
}
void
-Editor::temporal_zoom (gdouble fpu)
+Editor::temporal_zoom (double fpu)
{
- if (!_session) return;
+ if (!_session) {
+ return;
+ }
framepos_t current_page = current_page_frames();
framepos_t current_leftmost = leftmost_frame;
@@ -1362,9 +1380,8 @@ Editor::temporal_zoom (gdouble fpu)
double nfpu;
double l;
- /* XXX this limit is also in ::set_frames_per_unit() */
-
- if (frames_per_unit <= 1.0 && fpu <= frames_per_unit) {
+ clamp_frames_per_unit (fpu);
+ if (fpu == frames_per_unit) {
return;
}