More cleanup
authornick_m <mainsbridge@gmail.com>
Thu, 21 May 2015 18:26:16 +0000 (04:26 +1000)
committernick_m <mainsbridge@gmail.com>
Thu, 21 May 2015 18:26:16 +0000 (04:26 +1000)
- remove "no_magnets" ugh.

gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_drag.cc
gtk2_ardour/midi_region_view.cc
gtk2_ardour/midi_region_view.h
gtk2_ardour/public_editor.h
gtk2_ardour/region_view.cc
gtk2_ardour/region_view.h

index 05f9b0ca93075c640a3a2098b3d946e723d61276..45c7ca94b09161a15c250d6ccf375ebc5ea7a790 100644 (file)
@@ -2609,23 +2609,13 @@ Editor::snap_to_with_modifier (framepos_t& start, GdkEvent const * event, RoundM
 }
 
 void
-Editor::snap_to (framepos_t& start, RoundMode direction, bool for_mark)
+Editor::snap_to (framepos_t& start, RoundMode direction, bool for_mark, bool explicitly)
 {
        if (!_session || _snap_mode == SnapOff) {
                return;
        }
 
-       snap_to_internal (start, direction, for_mark);
-}
-
-void
-Editor::snap_to_no_magnets (framepos_t& start, RoundMode direction, bool for_mark)
-{
-       if (!_session || _snap_mode == SnapOff) {
-               return;
-       }
-
-       snap_to_internal (start, direction, for_mark, true);
+       snap_to_internal (start, direction, for_mark, explicitly);
 }
 
 void
@@ -2695,7 +2685,7 @@ Editor::timecode_snap_to_internal (framepos_t& start, RoundMode direction, bool
 }
 
 void
-Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark, bool no_magnets)
+Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark, bool explicitly)
 {
        const framepos_t one_second = _session->frame_rate();
        const framepos_t one_minute = _session->frame_rate() * 60;
@@ -2865,7 +2855,7 @@ Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark,
 
        case SnapMagnetic:
 
-               if (no_magnets) {
+               if (explicitly) {
                        return;
                }
 
index 8362b00551e229a67b4eb854a7d95485a009528d..663a97a56dbda292a826c9847484fbf38247968e 100644 (file)
@@ -436,11 +436,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void snap_to (framepos_t&       first,
                      ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
-                     bool              for_mark  = false);
-
-       void snap_to_no_magnets (framepos_t&       first,
-                     ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
-                     bool              for_mark  = false);
+                     bool              for_mark  = false,
+                     bool              explicitly = false);
 
        void snap_to_with_modifier (framepos_t&       first,
                                    GdkEvent const *  ev,
@@ -2136,7 +2133,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void snap_to_internal (framepos_t&       first,
                               ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
                               bool              for_mark  = false,
-                              bool              no_magnets = false);
+                              bool              explicitly = false);
 
        void timecode_snap_to_internal (framepos_t&       first,
                                        ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
index 18a3b5115be3ec90e2a509982bebe7a699ad19e6..3f08a8c75054ae87f6f62ccea399c714d2588485 100644 (file)
@@ -366,7 +366,7 @@ void
 Drag::setup_snap_delta (framepos_t pos)
 {
        framepos_t temp = pos;
-       _editor->snap_to_no_magnets (temp);
+       _editor->snap_to (temp, ARDOUR::RoundNearest, false, true);
        _snap_delta = temp - pos;
 }
 
@@ -2347,7 +2347,7 @@ NoteResizeDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*ignored*/)
        region = &cnote->region_view();
 
        double temp;
-       temp = region->snap_to_pixel_no_magnets (cnote->x0 ());
+       temp = region->snap_to_pixel (cnote->x0 (), true);
        _snap_delta = temp - cnote->x0 ();
 
        _item->grab ();
index be280001d23ce36af866d3448c54875965273de5..2fa8f4a3cdbf5c2f948c190515ffe66b68bb5567 100644 (file)
@@ -2627,38 +2627,19 @@ MidiRegionView::note_dropped(NoteBase *, frameoffset_t dt, int8_t dnote)
  *  @return Snapped frame relative to the region position.
  */
 framepos_t
-MidiRegionView::snap_pixel_to_sample(double x)
+MidiRegionView::snap_pixel_to_sample(double x, bool explicitly)
 {
        PublicEditor& editor (trackview.editor());
-       return snap_frame_to_frame (editor.pixel_to_sample (x));
-}
-
-/** @param x Pixel relative to the region position explicitly (no magnetic snap)
- *  @return Snapped frame relative to the region position.
- */
-framepos_t
-MidiRegionView::snap_pixel_to_sample_no_magnets (double x)
-{
-       PublicEditor& editor (trackview.editor());
-       return snap_frame_to_frame_no_magnets (editor.pixel_to_sample (x));
+       return snap_frame_to_frame (editor.pixel_to_sample (x), explicitly);
 }
 
 /** @param x Pixel relative to the region position.
  *  @return Snapped pixel relative to the region position.
  */
 double
-MidiRegionView::snap_to_pixel(double x)
-{
-       return (double) trackview.editor().sample_to_pixel(snap_pixel_to_sample(x));
-}
-
-/** @param x Pixel relative to the region position.
- *  @return Explicitly snapped pixel relative to the region position (no magnetic snap).
- */
-double
-MidiRegionView::snap_to_pixel_no_magnets (double x)
+MidiRegionView::snap_to_pixel(double x, bool explicitly)
 {
-       return (double) trackview.editor().sample_to_pixel(snap_pixel_to_sample_no_magnets(x));
+       return (double) trackview.editor().sample_to_pixel(snap_pixel_to_sample(x, explicitly));
 }
 
 double
index 7329c6facc02c3b18379acf35b48bb63fa275a8b..37a66aa39878f5c58205d446d1ba4532874c6ec5 100644 (file)
@@ -250,27 +250,17 @@ public:
 
        /** Snap a region relative pixel coordinate to pixel units.
         * @param x a pixel coordinate relative to region start
+        * @param explicitly do not use magnetic snap (required for snap delta calculation)
         * @return the snapped pixel coordinate relative to region start
         */
-       double snap_to_pixel(double x);
-
-       /** Snap a region relative pixel coordinate to pixel units explicitly (no magnetic snap).
-        * @param x a pixel coordinate relative to region start
-        * @return the explicitly snapped pixel coordinate relative to region start
-        */
-       double snap_to_pixel_no_magnets (double x);
+       double snap_to_pixel(double x, bool explicitly = false);
 
        /** Snap a region relative pixel coordinate to frame units.
         * @param x a pixel coordinate relative to region start
+        * @param explicitly do not use magnetic snap (required for snap delta calculation)
         * @return the snapped framepos_t coordinate relative to region start
         */
-       framepos_t snap_pixel_to_sample(double x);
-
-       /** Explicitly snap a region relative pixel coordinate to frame units (no magnetic snap).
-        * @param x a pixel coordinate relative to region start
-        * @return the explicitly snapped framepos_t coordinate relative to region start
-        */
-       framepos_t snap_pixel_to_sample_no_magnets (double x);
+       framepos_t snap_pixel_to_sample(double x, bool explicitly = false);
 
        /** Convert a timestamp in beats into frames (both relative to region position) */
        framepos_t region_beats_to_region_frames(Evoral::Beats beats) const;
index a89993a4795c1593fb78c30ce9599534e468c01e..463d7614d27acc00083d89960d3a76fb94580f3f 100644 (file)
@@ -144,11 +144,8 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi
        /** Snap a value according to the current snap setting. */
        virtual void snap_to (framepos_t&       first,
                              ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
-                             bool              for_mark  = false) = 0;
-       /** Snap a value according to the current snap setting. */
-       virtual void snap_to_no_magnets (framepos_t&       first,
-                             ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
-                             bool              for_mark  = false) = 0;
+                             bool              for_mark  = false,
+                             bool              explicitly = false) = 0;
 
        /** Undo some transactions.
         * @param n Number of transactions to undo.
index cd83154a9fde7c9b591e90626d590cb10173ef85..5a8e3f235bba9810798f53e1656a5b74cbefd445 100644 (file)
@@ -942,7 +942,7 @@ RegionView::move_contents (frameoffset_t distance)
  *  @return Snapped frame offset from this region's position.
  */
 frameoffset_t
-RegionView::snap_frame_to_frame (frameoffset_t x) const
+RegionView::snap_frame_to_frame (frameoffset_t x, bool explicitly) const
 {
        PublicEditor& editor = trackview.editor();
 
@@ -951,38 +951,12 @@ RegionView::snap_frame_to_frame (frameoffset_t x) const
 
        /* try a snap in either direction */
        framepos_t frame = session_frame;
-       editor.snap_to (frame, RoundNearest);
+       editor.snap_to (frame, RoundNearest, false, explicitly);
 
        /* if we went off the beginning of the region, snap forwards */
        if (frame < _region->position ()) {
                frame = session_frame;
-               editor.snap_to (frame, RoundUpAlways);
-       }
-
-       /* back to region relative */
-       return frame - _region->position();
-}
-
-/** Snap a frame offset within our region using the current snap settings.
- *  @param x Frame offset from this region's position.
- *  @return Snapped frame offset from this region's position.
- */
-frameoffset_t
-RegionView::snap_frame_to_frame_no_magnets (frameoffset_t x) const
-{
-       PublicEditor& editor = trackview.editor();
-
-       /* x is region relative, convert it to global absolute frames */
-       framepos_t const session_frame = x + _region->position();
-
-       /* try a snap in either direction */
-       framepos_t frame = session_frame;
-       editor.snap_to_no_magnets (frame, RoundNearest);
-
-       /* if we went off the beginning of the region, snap forwards */
-       if (frame < _region->position ()) {
-               frame = session_frame;
-               editor.snap_to_no_magnets (frame, RoundUpAlways);
+               editor.snap_to (frame, RoundUpAlways, false, explicitly);
        }
 
        /* back to region relative */
index 77abb5e2a96437771f26249442e751915ffebecf..23b08f4b12d7f838325b4db759ec56e2442c3708 100644 (file)
@@ -121,8 +121,7 @@ class RegionView : public TimeAxisViewItem
                }
        };
 
-       ARDOUR::frameoffset_t snap_frame_to_frame (ARDOUR::frameoffset_t) const;
-       ARDOUR::frameoffset_t snap_frame_to_frame_no_magnets (ARDOUR::frameoffset_t) const;
+       ARDOUR::frameoffset_t snap_frame_to_frame (ARDOUR::frameoffset_t, bool explicitly = false) const;
        
   protected: