provide accessors to Editor::snap_{type,mode} ; when nudging notes, use grid in prefe...
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 26 Oct 2009 23:43:04 +0000 (23:43 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 26 Oct 2009 23:43:04 +0000 (23:43 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@5934 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_mouse.cc
gtk2_ardour/editor_ops.cc
gtk2_ardour/editor_rulers.cc
gtk2_ardour/midi_region_view.cc
gtk2_ardour/public_editor.h

index ac65d7bd411edbc5f2727d357e673fca614687a9..60d6c9a3a4c18ffc10db70eb30169e81d359cda0 100644 (file)
@@ -605,10 +605,10 @@ Editor::Editor ()
        setup_toolbar ();
        setup_midi_toolbar ();
 
-       snap_type = SnapToBeat;
-       set_snap_to (snap_type);
-       snap_mode = SnapOff;
-       set_snap_mode (snap_mode);
+       _snap_type = SnapToBeat;
+       set_snap_to (_snap_type);
+       _snap_mode = SnapOff;
+       set_snap_mode (_snap_mode);
        set_mouse_mode (MouseObject, true);
        set_edit_point_preference (EditAtMouse, true);
 
@@ -1176,7 +1176,7 @@ Editor::connect_to_session (Session *t)
 
        start_scrolling ();
 
-       switch (snap_type) {
+       switch (_snap_type) {
        case SnapToRegionStart:
        case SnapToRegionEnd:
        case SnapToRegionSync:
@@ -2103,16 +2103,28 @@ Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
        edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
 }
 
+SnapType
+Editor::snap_type() const
+{
+       return _snap_type;
+}
+
+SnapMode
+Editor::snap_mode() const
+{
+       return _snap_mode;
+}
+
 void
 Editor::set_snap_to (SnapType st)
 {
        unsigned int snap_ind = (unsigned int)st;
 
-       snap_type = st;
+       _snap_type = st;
 
        if (snap_ind > snap_type_strings.size() - 1) {
                snap_ind = 0;
-               snap_type = (SnapType)snap_ind;
+               _snap_type = (SnapType)snap_ind;
        }
 
        string str = snap_type_strings[snap_ind];
@@ -2123,7 +2135,7 @@ Editor::set_snap_to (SnapType st)
 
        instant_save ();
 
-       switch (snap_type) {
+       switch (_snap_type) {
        case SnapToAThirtysecondBeat:
        case SnapToASixteenthBeat:
        case SnapToAEighthBeat:
@@ -2149,7 +2161,7 @@ Editor::set_snap_to (SnapType st)
 void
 Editor::set_snap_mode (SnapMode mode)
 {
-       snap_mode = mode;
+       _snap_mode = mode;
        string str = snap_mode_strings[(int)mode];
 
        if (str != snap_mode_selector.get_active_text ()) {
@@ -2476,9 +2488,9 @@ Editor::get_state ()
        node->add_property ("zoom-focus", buf);
        snprintf (buf, sizeof(buf), "%f", frames_per_unit);
        node->add_property ("zoom", buf);
-       snprintf (buf, sizeof(buf), "%d", (int) snap_type);
+       snprintf (buf, sizeof(buf), "%d", (int) _snap_type);
        node->add_property ("snap-to", buf);
-       snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
+       snprintf (buf, sizeof(buf), "%d", (int) _snap_mode);
        node->add_property ("snap-mode", buf);
 
        node->add_property ("edit-point", enum_2_string (_edit_point));
@@ -2543,11 +2555,11 @@ Editor::snap_to_with_modifier (nframes64_t& start, GdkEvent const * event, int32
        }
 
        if (Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
-               if (snap_mode == SnapOff) {
+               if (_snap_mode == SnapOff) {
                        snap_to_internal (start, direction, for_mark);
                }
        } else {
-               if (snap_mode != SnapOff) {
+               if (_snap_mode != SnapOff) {
                        snap_to_internal (start, direction, for_mark);
                }
        }
@@ -2556,7 +2568,7 @@ Editor::snap_to_with_modifier (nframes64_t& start, GdkEvent const * event, int32
 void
 Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
 {
-       if (!session || snap_mode == SnapOff) {
+       if (!session || _snap_mode == SnapOff) {
                return;
        }
 
@@ -2569,7 +2581,7 @@ Editor::timecode_snap_to_internal (nframes64_t& start, int32_t direction, bool /
        const nframes64_t one_timecode_second = (nframes64_t)(rint(session->timecode_frames_per_second()) * session->frames_per_timecode_frame());
        nframes64_t one_timecode_minute = (nframes64_t)(rint(session->timecode_frames_per_second()) * session->frames_per_timecode_frame() * 60);
 
-       switch (snap_type) {
+       switch (_snap_type) {
        case SnapToTimecodeFrame:
                if (((direction == 0) && (fmod((double)start, (double)session->frames_per_timecode_frame()) > (session->frames_per_timecode_frame() / 2))) || (direction > 0)) {
                        start = (nframes64_t) (ceil ((double) start / session->frames_per_timecode_frame()) * session->frames_per_timecode_frame());
@@ -2633,7 +2645,7 @@ Editor::snap_to_internal (nframes64_t& start, int32_t direction, bool for_mark)
        nframes64_t before;
        nframes64_t after;
 
-       switch (snap_type) {
+       switch (_snap_type) {
        case SnapToTimecodeFrame:
        case SnapToTimecodeSeconds:
        case SnapToTimecodeMinutes:
@@ -2745,7 +2757,7 @@ Editor::snap_to_internal (nframes64_t& start, int32_t direction, bool for_mark)
                break;
        }
 
-       switch (snap_mode) {
+       switch (_snap_mode) {
        case SnapNormal:
                return;
 
@@ -3835,7 +3847,7 @@ Editor::get_grid_type_as_beats (bool& success, nframes64_t position)
 {
        success = true;
 
-       switch (snap_type) {
+       switch (_snap_type) {
        case SnapToBeat:
                return 1.0;
                break;
index e4cb5ec57d7ca39493d0d802ad6fcd66685bf26a..030be68ec12c3fd6a89b67374c8a6c7a68dc8987 100644 (file)
@@ -176,6 +176,9 @@ class Editor : public PublicEditor
        void set_snap_mode (Editing::SnapMode);
        void set_snap_threshold (double pixel_distance) {snap_threshold = pixel_distance;}
 
+       Editing::SnapMode  snap_mode () const;
+       Editing::SnapType  snap_type () const;
+
        void undo (uint32_t n = 1);
        void redo (uint32_t n = 1);
 
@@ -1285,8 +1288,8 @@ class Editor : public PublicEditor
        void extend_selection_to_end_of_region (bool next);
        void extend_selection_to_start_of_region (bool previous);
 
-       Editing::SnapType snap_type;
-       Editing::SnapMode snap_mode;
+       Editing::SnapType _snap_type;
+       Editing::SnapMode _snap_mode;
 
        /// Snap threshold in pixels
        double snap_threshold;
index f059c740fb59f2e5ce6d9de0c5fc3087f110a642..9d5fec0969558e14172e21c1c136f4b0e6fdb7ff 100644 (file)
@@ -1083,7 +1083,7 @@ Editor::snap_type_action (SnapType type)
 void
 Editor::cycle_snap_choice()
 {
-       switch (snap_type) {
+       switch (_snap_type) {
        case Editing::SnapToCDFrame:
                set_snap_to (Editing::SnapToTimecodeFrame);
                break;
@@ -1192,7 +1192,7 @@ Editor::snap_mode_action (SnapMode mode)
 void
 Editor::cycle_snap_mode ()
 {
-       switch (snap_mode) {
+       switch (_snap_mode) {
        case SnapOff:
                set_snap_mode (SnapNormal);
                break;
index 81f210a9019e3497910d9b85a043689e6a101fc5..1c5d98f1b2a21fea08f92584f4bf55d798a33ee2 100644 (file)
@@ -119,7 +119,7 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
                _was_rolling = false;
        }
 
-       switch (_editor->snap_type) {
+       switch (_editor->snap_type()) {
        case SnapToRegionStart:
        case SnapToRegionEnd:
        case SnapToRegionSync:
index f4e5a7d03c9d212937c8ec149b0eb2aef49df66c..60edec69c45661a9883dfbf5ae96a2bfab7d9ab5 100644 (file)
@@ -2390,14 +2390,14 @@ Editor::mouse_brush_insert_region (RegionView* rv, nframes64_t pos)
 {
        /* no brushing without a useful snap setting */
 
-       switch (snap_mode) {
+       switch (_snap_mode) {
        case SnapMagnetic:
                return; /* can't work because it allows region to be placed anywhere */
        default:
                break; /* OK */
        }
 
-       switch (snap_type) {
+       switch (_snap_type) {
        case SnapToMark:
                return;
 
index 7f5907dec62ed847828304d2bc43062729cb34d1..a128ed6cf23fa8333d4b6fa6926e438e64182aac 100644 (file)
@@ -125,7 +125,7 @@ Editor::split_regions_at (nframes64_t where, RegionSelection& regions)
        // region boundaries, don't pay attention to them
 
        if (regions.size() == 1) {
-               switch (snap_type) {
+               switch (_snap_type) {
                case SnapToRegionStart:
                case SnapToRegionSync:
                case SnapToRegionEnd:
@@ -579,7 +579,7 @@ Editor::build_region_boundary_cache ()
                return;
        }
 
-       switch (snap_type) {
+       switch (_snap_type) {
        case SnapToRegionStart:
                interesting_points.push_back (Start);
                break;
@@ -594,7 +594,7 @@ Editor::build_region_boundary_cache ()
                interesting_points.push_back (End);
                break;
        default:
-               fatal << string_compose (_("build_region_boundary_cache called with snap_type = %1"), snap_type) << endmsg;
+               fatal << string_compose (_("build_region_boundary_cache called with snap_type = %1"), _snap_type) << endmsg;
                /*NOTREACHED*/
                return;
        }
index e044487274dee669fd1202a305ccd30b892e0355..12b45477475c4ca0f5c4a2c6397f8c169f29322e 100644 (file)
@@ -1154,7 +1154,7 @@ Editor::compute_bbt_ruler_scale (nframes64_t lower, nframes64_t upper)
 
        bbt_ruler_scale =  bbt_over;
 
-       switch (snap_type) {
+       switch (_snap_type) {
        case SnapToAThirdBeat:
                 bbt_beat_subdivision = 3;
                break;
index 0642efc826d6b2d5b90cba559126cafa2bd975b1..77ba80b077425bacc645ba5aaa7917768b0b405a 100644 (file)
@@ -2203,9 +2203,15 @@ MidiRegionView::nudge_notes (bool forward)
        nframes64_t unused;
        nframes64_t distance;
 
-       if ((distance = trackview.editor().get_nudge_distance (ref_point, unused)) == 0) {
+       if (trackview.editor().snap_mode() == Editing::SnapOff) {
+               
+               /* grid is off - use nudge distance */
 
-               /* no nudge distance set - use grid */
+               distance = trackview.editor().get_nudge_distance (ref_point, unused);
+
+       } else {
+
+               /* use grid */
 
                nframes64_t next_pos = ref_point;
 
index d0d63e060b43ebb0ced61187c240d82b841f2495..035d05c1afec200a7c32184a10081b2e382265f8 100644 (file)
@@ -109,6 +109,9 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway
         */
        virtual void set_snap_to (Editing::SnapType t) = 0;
 
+       virtual Editing::SnapType snap_type () const = 0;
+       virtual Editing::SnapMode snap_mode () const = 0;
+
        /** Set the snap mode.
         * @param m Snap mode (defined in editing_syms.h)
         */