simplify zooming, remove Editor::clamp_samples_per_pixel(), fix getting "stuck" at...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 2 Jul 2014 19:53:24 +0000 (15:53 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 2 Jul 2014 19:53:24 +0000 (15:53 -0400)
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_ops.cc

index 286c3a8fb8c9f99b74835c19f8599b9409818426..f1c3c1e7026cacd816b451ce22decfa0215b7b26 100644 (file)
@@ -3335,7 +3335,7 @@ Editor::cycle_edit_mode ()
                        Config->set_edit_mode (Ripple);
                }
                break;
-//     case Splice:
+       case Splice:
        case Ripple:
                Config->set_edit_mode (Lock);
                break;
@@ -4056,8 +4056,6 @@ Editor::reset_y_origin (double y)
 void
 Editor::reset_zoom (framecnt_t spp)
 {
-       clamp_samples_per_pixel (spp);
-
        if (spp == samples_per_pixel) {
                return;
        }
@@ -4169,12 +4167,26 @@ Editor::use_visual_state (VisualState& vs)
 
 /** This is the core function that controls the zoom level of the canvas. It is called
  *  whenever one or more calls are made to reset_zoom().  It executes in an idle handler.
- *  @param fpu New frames per unit; should already have been clamped so that it is sensible.
+ *  @param spp new number of samples per pixel
  */
 void
 Editor::set_samples_per_pixel (framecnt_t spp)
 {
-       clamp_samples_per_pixel (spp);
+       if (spp < 1) {
+               return;
+       }
+
+       const framecnt_t three_days = 3 * 24 * 60 * 60 * (_session ? _session->frame_rate() : 48000);
+       const framecnt_t lots_of_pixels = 4000;
+
+       /* if the zoom level is greater than what you'd get trying to display 3
+        * days of audio on a really big screen, then it's too big.
+        */
+
+       if (spp * lots_of_pixels > three_days) {
+               return;
+       }
+
        samples_per_pixel = spp;
 
        if (tempo_lines) {
index c7918eff3f4a1b51cc3fe93b7ed17158676284fe..e8f3804fd5fc8d75546a2d8cc87891fdcc293f3e 100644 (file)
@@ -520,7 +520,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Editing::ZoomFocus zoom_focus;
 
        void set_samples_per_pixel (framecnt_t);
-        bool clamp_samples_per_pixel (framecnt_t &) const;
 
        Editing::MouseMode mouse_mode;
        Editing::MouseMode pre_internal_mouse_mode;
index 45568bdb3c9e1666608edf676c172548602ca5ef..b7a246d5895c69ffa6faa9d898eca16afba53b71 100644 (file)
@@ -1448,38 +1448,6 @@ Editor::tav_zoom_smooth (bool coarser, bool force_all)
        }
 }
 
-bool
-Editor::clamp_samples_per_pixel (framecnt_t& fpp) const
-{
-       bool clamped = false;
-       
-       if (fpp < 1) {
-               fpp = 1;
-               clamped = true;
-       }
-
-       framecnt_t sr;
-
-       if (_session) {
-               sr = _session->frame_rate ();
-       } else {
-               sr = 48000;
-       }
-
-       const framecnt_t three_days = 3 * 24 * 60 * 60 * sr;
-       const framecnt_t lots_of_pixels = 4000;
-
-       /* if the zoom level is greater than what you'd get trying to display 3
-        * days of audio on a really big screen, scale it down.
-        */
-
-       if (fpp * lots_of_pixels > three_days) {
-               fpp = three_days / _track_canvas->width();
-               clamped = true;
-       }
-
-       return clamped;
-}
 
 void
 Editor::temporal_zoom_step (bool coarser)
@@ -1516,7 +1484,6 @@ Editor::temporal_zoom (framecnt_t fpp)
        framecnt_t nfpp;
        double l;
 
-       clamp_samples_per_pixel (fpp);
        if (fpp == samples_per_pixel) {
                return;
        }
@@ -1806,8 +1773,7 @@ Editor::temporal_zoom_to_frame (bool coarser, framepos_t frame)
                        new_spp = samples_per_pixel - (samples_per_pixel/2);
                } else {
                        /* could bail out here since we cannot zoom any finer,
-                          but leave that to the clamp_samples_per_pixel() and
-                          equality test below
+                          but leave that to the equality test below
                        */
                        new_spp = samples_per_pixel;
                }
@@ -1815,8 +1781,6 @@ Editor::temporal_zoom_to_frame (bool coarser, framepos_t frame)
                range_before -= range_before/2;
        }
 
-       clamp_samples_per_pixel (new_spp);
-
        if (new_spp == samples_per_pixel)  {
                return;
        }