"Lock" mode is now "Constrained", make snap absolute modifier configurable.
authornick_m <mainsbridge@gmail.com>
Sun, 17 May 2015 20:25:36 +0000 (06:25 +1000)
committernick_m <mainsbridge@gmail.com>
Sun, 17 May 2015 20:25:36 +0000 (06:25 +1000)
- user can abs/rel modifier key in prefs->user interaction
  suggested for linux - absolute->alt ignore snap->alt-shift
- Constrained mode works the same as button 2 drag (initial move
  sets constraint axis).

gtk2_ardour/editor.cc
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_ops.cc
gtk2_ardour/rc_option_editor.cc
libs/ardour/ardour/types.h
libs/ardour/enums.cc
libs/ardour/utils.cc
libs/gtkmm2ext/gtkmm2ext/keyboard.h
libs/gtkmm2ext/keyboard.cc

index ff9d480a3549f947d321992c3239867f6b70cb35..e785db3de76afa9377ce422d3163e2cb45135960 100644 (file)
@@ -195,7 +195,7 @@ static const gchar *_edit_mode_strings[] = {
        N_("Slide"),
        N_("Splice"),
        N_("Ripple"),
-       N_("Lock"),
+       N_("Constrained"),
        0
 };
 
@@ -3171,7 +3171,7 @@ Editor::build_edit_mode_menu ()
        edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Slide], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Slide)));
 //     edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Splice], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Splice)));
        edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Ripple], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Ripple)));
-       edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Lock], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode)  Lock)));
+       edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Constrained], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode)  Constrained)));
 
        set_size_request_to_display_given_text (edit_mode_selector, edit_mode_strings, COMBO_TRIANGLE_WIDTH, 2);
 }
@@ -3617,16 +3617,16 @@ Editor::cycle_edit_mode ()
        switch (Config->get_edit_mode()) {
        case Slide:
                if (Profile->get_sae()) {
-                       Config->set_edit_mode (Lock);
+                       Config->set_edit_mode (Constrained);
                } else {
                        Config->set_edit_mode (Ripple);
                }
                break;
        case Splice:
        case Ripple:
-               Config->set_edit_mode (Lock);
+               Config->set_edit_mode (Constrained);
                break;
-       case Lock:
+       case Constrained:
                Config->set_edit_mode (Slide);
                break;
        }
index baebda73af3fa707cda4b63646d7700a0c51026c..f1cf70fd89f83c74ea5e463ad37ccbbb5fe5d47e 100644 (file)
@@ -509,7 +509,7 @@ Editor::register_actions ()
 //     ActionManager::register_action (editor_actions, "set-edit-splice", _("Splice"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Splice));
        ActionManager::register_action (editor_actions, "set-edit-ripple", _("Ripple"), bind (mem_fun (*this, &Editor::set_edit_mode), Ripple));
        ActionManager::register_action (editor_actions, "set-edit-slide", _("Slide"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Slide));
-       ActionManager::register_action (editor_actions, "set-edit-lock", S_("EditMode|Lock"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Lock));
+       ActionManager::register_action (editor_actions, "set-edit-constrained", S_("EditMode|Constrained"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Constrained));
        ActionManager::register_action (editor_actions, "cycle-edit-mode", _("Cycle Edit Mode"), sigc::mem_fun (*this, &Editor::cycle_edit_mode));
 
        ActionManager::register_action (editor_actions, X_("SnapTo"), _("Snap to"));
index c21622dd4a5177b3851265c7ec0d70354784d142..cf1f8007b9ea5e4f12fd9abfb043b2aa7823052c 100644 (file)
@@ -339,7 +339,7 @@ Drag::adjusted_current_frame (GdkEvent const * event, bool snap) const
 frameoffset_t
 Drag::snap_delta (GdkEvent const * event) const
 {
-       if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) {
+       if (Keyboard::modifier_state_equals (event->button.state, Keyboard::snap_delta_modifier())) {
                return 0;
        } else {
                return _snap_delta;
@@ -401,18 +401,23 @@ Drag::motion_handler (GdkEvent* event, bool from_autoscroll)
                                /* just changed */
 
                                if (fabs (current_pointer_y() - _grab_y) > fabs (current_pointer_x() - _grab_x)) {
-                                       if (event->motion.state & Gdk::BUTTON2_MASK) {
+                                       if ((event->motion.state & Gdk::BUTTON2_MASK) || Config->get_edit_mode() == Constrained) {
                                                _x_constrained = true;
                                                _y_constrained = false;
                                        }
                                        _initially_vertical = true;
                                } else {
-                                       if (event->motion.state & Gdk::BUTTON2_MASK) {
+                                       if ((event->motion.state & Gdk::BUTTON2_MASK) || Config->get_edit_mode() == Constrained) {
                                                _x_constrained = false;
                                                _y_constrained = true;
                                        }
                                        _initially_vertical = false;
                                }
+
+                               if ((event->motion.state & Gdk::BUTTON2_MASK) && Config->get_edit_mode() == Constrained) {
+                                       _x_constrained = false;
+                                       _y_constrained = false;
+                               }
                        }
 
                        if (!from_autoscroll) {
@@ -630,9 +635,7 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, framepos_t* pending_r
        }
 
        double dx = 0;
-
-       /* in locked edit mode, reverse the usual meaning of _x_constrained */
-       bool const x_move_allowed = Config->get_edit_mode() == Lock ? _x_constrained : !_x_constrained;
+       bool x_move_allowed = !_x_constrained;
 
        if ((*pending_region_position != _last_frame_position) && x_move_allowed) {
 
@@ -1307,14 +1310,6 @@ RegionMoveDrag::finished (GdkEvent* ev, bool movement_occurred)
                return;
        }
 
-       /* reverse this here so that we have the correct logic to finalize
-          the drag.
-       */
-
-       if (Config->get_edit_mode() == Lock) {
-               _x_constrained = !_x_constrained;
-       }
-
        assert (!_views.empty ());
 
        /* We might have hidden region views so that they weren't visible during the drag
index 5c45951e04802cb036331b74d5b02a5e2509d796..0ff9cbb732c4de0827a8bac99ba8e95447282967 100644 (file)
@@ -6960,7 +6960,7 @@ Editor::insert_time (
 {
        bool commit = false;
 
-       if (Config->get_edit_mode() == Lock) {
+       if (Config->get_edit_mode() == Constrained) {
                return;
        }
 
@@ -7133,8 +7133,8 @@ Editor::cut_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt,
 {
        bool commit = false;
        
-       if (Config->get_edit_mode() == Lock) {
-               error << (_("Cannot insert or delete time when in Lock edit.")) << endmsg;
+       if (Config->get_edit_mode() == Constrained) {
+               error << (_("Cannot insert or delete time when in Constrained edit.")) << endmsg;
                return;
        }
 
index bcefc1260bca9eda7279e97cdd2bc9b48e590a10..9c5a603fd75c676d30ac1ce627401f0b5647d331 100644 (file)
@@ -319,7 +319,7 @@ public:
                        }
                }
 
-               Table* t = manage (new Table (4, 4));
+               Table* t = manage (new Table (4, 5));
                t->set_spacings (4);
 
                Label* l = manage (left_aligned_label (_("Edit using:")));
@@ -391,7 +391,7 @@ public:
                _insert_note_button_adjustment.set_value (Keyboard::insert_note_button());
                _insert_note_button_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::insert_note_button_changed));
 
-
+               /* ignore snap */
                set_popdown_strings (_snap_modifier_combo, dumb);
                _snap_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::snap_modifier_chosen));
 
@@ -408,6 +408,23 @@ public:
                t->attach (*l, 0, 1, 3, 4, FILL | EXPAND, FILL);
                t->attach (_snap_modifier_combo, 1, 2, 3, 4, FILL | EXPAND, FILL);
 
+               /* snap delta */
+               set_popdown_strings (_snap_delta_combo, dumb);
+               _snap_delta_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::snap_delta_modifier_chosen));
+
+               for (int x = 0; modifiers[x].name; ++x) {
+                       if (modifiers[x].modifier == (guint) Keyboard::snap_delta_modifier ()) {
+                               _snap_delta_combo.set_active_text (S_(modifiers[x].name));
+                               break;
+                       }
+               }
+
+               l = manage (left_aligned_label (_("Snap to absolute using:")));
+               l->set_name ("OptionsLabel");
+
+               t->attach (*l, 0, 1, 4, 5, FILL | EXPAND, FILL);
+               t->attach (_snap_delta_combo, 1, 2, 4, 5, FILL | EXPAND, FILL);
+
                vector<string> strs;
 
                for (map<string,string>::iterator bf = Keyboard::binding_files.begin(); bf != Keyboard::binding_files.end(); ++bf) {
@@ -421,8 +438,8 @@ public:
                l = manage (left_aligned_label (_("Keyboard layout:")));
                l->set_name ("OptionsLabel");
 
-               t->attach (*l, 0, 1, 4, 5, FILL | EXPAND, FILL);
-               t->attach (_keyboard_layout_selector, 1, 2, 4, 5, FILL | EXPAND, FILL);
+               t->attach (*l, 0, 1, 5, 6, FILL | EXPAND, FILL);
+               t->attach (_keyboard_layout_selector, 1, 2, 5, 6, FILL | EXPAND, FILL);
 
                _box->pack_start (*t, false, false);
        }
@@ -502,6 +519,18 @@ private:
                }
        }
 
+       void snap_delta_modifier_chosen ()
+       {
+               string const txt = _snap_delta_combo.get_active_text();
+
+               for (int i = 0; modifiers[i].name; ++i) {
+                       if (txt == _(modifiers[i].name)) {
+                               Keyboard::set_snap_delta_modifier (modifiers[i].modifier);
+                               break;
+                       }
+               }
+       }
+
        void delete_button_changed ()
        {
                Keyboard::set_delete_button (_delete_button_spin.get_value_as_int());
@@ -522,6 +551,7 @@ private:
        ComboBoxText _delete_modifier_combo;
        ComboBoxText _insert_note_modifier_combo;
        ComboBoxText _snap_modifier_combo;
+       ComboBoxText _snap_delta_combo;
        Adjustment _delete_button_adjustment;
        SpinButton _delete_button_spin;
        Adjustment _edit_button_adjustment;
index b1b4388a747115d3b090decd6471264f07a60f17..33cd94f10163dc8e42dd49f7905dcb060e860c66 100644 (file)
@@ -352,7 +352,7 @@ namespace ARDOUR {
                Slide,
                Splice,
                Ripple,
-               Lock
+               Constrained
        };
 
        enum RegionSelectionAfterSplit {
index a1cf8d090cf972c5f4b147071b01026bc24fd240..6e53660cfbdfbb7b611bacf9e75bc5c473f9e43c 100644 (file)
@@ -242,7 +242,7 @@ setup_enum_writer ()
        REGISTER_ENUM (Slide);
        REGISTER_ENUM (Splice);
        REGISTER_ENUM (Ripple); // XXX do the old enum values have to stay in order?
-       REGISTER_ENUM (Lock);
+       REGISTER_ENUM (Constrained);
        REGISTER (_EditMode);
        /*
         * Splice mode is undefined, undocumented, and basically fubar'ed
index 6d6511bb9f5f377c29d7cd4eb014fcdefe54e45f..82ad8c38d5c732a0971cbd27db8fab4f6f1b2ac8 100644 (file)
@@ -425,8 +425,8 @@ ARDOUR::string_to_edit_mode (string str)
                return Slide;
        } else if (str == _("Ripple")) {
                return Ripple;
-       } else if (str == _("Lock")) {
-               return Lock;
+       } else if (str == _("Constrained")) {
+               return Constrained;
        }
        fatal << string_compose (_("programming error: unknown edit mode string \"%1\""), str) << endmsg;
        abort(); /*NOTREACHED*/
@@ -440,8 +440,8 @@ ARDOUR::edit_mode_to_string (EditMode mode)
        case Slide:
                return _("Slide");
 
-       case Lock:
-               return _("Lock");
+       case Constrained:
+               return _("Constrained");
 
        case Ripple:
                return _("Ripple");
index 328638373fc3f6ab12bc7d9db0deafa11bfcbc9b..6cccca762bd61532a2c3f1d406140b8904b5a19e 100644 (file)
@@ -122,6 +122,12 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful
         */
        static ModifierMask snap_modifier () { return ModifierMask (snap_mod); }
 
+       static void set_snap_delta_modifier (guint);
+
+       /** @return Modifier mask to temporarily toggle between relative and absolute grid setting;
+        */
+       static ModifierMask snap_delta_modifier () { return ModifierMask (snap_delta_mod); }
+
        static guint edit_button() { return edit_but; }
        static void set_edit_button (guint);
        static guint edit_modifier() { return edit_mod; }
@@ -186,6 +192,7 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful
        static guint     insert_note_but;
        static guint     insert_note_mod;
        static guint     snap_mod;
+       static guint     snap_delta_mod;
        static guint     button2_modifiers;
        static Gtk::Window* current_window;
        static std::string user_keybindings_path;
index 420d42209b3311bffeff5d4aea6790d2d6b38e61..06f158662be7eb584dcd21d521660c8e51075e92 100644 (file)
@@ -59,6 +59,7 @@ guint Keyboard::delete_mod = GDK_SHIFT_MASK;
 guint Keyboard::insert_note_but = 1;
 guint Keyboard::insert_note_mod = GDK_CONTROL_MASK;
 guint Keyboard::snap_mod = GDK_MOD3_MASK;
+guint Keyboard::snap_delta_mod = 0;
 
 #ifdef GTKOSX
 
@@ -179,6 +180,8 @@ Keyboard::get_state (void)
        node->add_property ("delete-modifier", buf);
        snprintf (buf, sizeof (buf), "%d", snap_mod);
        node->add_property ("snap-modifier", buf);
+       snprintf (buf, sizeof (buf), "%d", snap_delta_mod);
+       node->add_property ("snap-delta-modifier", buf);
        snprintf (buf, sizeof (buf), "%d", insert_note_but);
        node->add_property ("insert-note-button", buf);
        snprintf (buf, sizeof (buf), "%d", insert_note_mod);
@@ -212,6 +215,10 @@ Keyboard::set_state (const XMLNode& node, int /*version*/)
                sscanf (prop->value().c_str(), "%d", &snap_mod);
        }
 
+       if ((prop = node.property ("snap-delta-modifier")) != 0) {
+               sscanf (prop->value().c_str(), "%d", &snap_delta_mod);
+       }
+
        if ((prop = node.property ("insert-note-button")) != 0) {
                sscanf (prop->value().c_str(), "%d", &insert_note_but);
        }
@@ -466,6 +473,14 @@ Keyboard::set_snap_modifier (guint mod)
        RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | snap_mod);
 }
 
+void
+Keyboard::set_snap_delta_modifier (guint mod)
+{cerr << "setting snap delta mod" << endl;
+       RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~snap_delta_mod);
+       snap_delta_mod = mod;
+       RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | snap_delta_mod);
+}
+
 bool
 Keyboard::is_edit_event (GdkEventButton *ev)
 {