Hacky fix for track height step losing 'grip' on the
authorCarl Hetherington <carl@carlh.net>
Sun, 17 Jun 2012 16:57:21 +0000 (16:57 +0000)
committerCarl Hetherington <carl@carlh.net>
Sun, 17 Jun 2012 16:57:21 +0000 (16:57 +0000)
track being resized (#4503).

git-svn-id: svn://localhost/ardour2/branches/3.0@12747 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/time_axis_view.cc
libs/gtkmm2ext/gtkmm2ext/keyboard.h
libs/gtkmm2ext/keyboard.cc

index 939c05b1e89e4a42ed4f58cecae80ce5e821a338..e3e00cf340cf63ee00ebebef835a187ceb913a8f 100644 (file)
@@ -282,6 +282,7 @@ Editor::Editor ()
        , _region_selection_change_updates_region_list (true)
        , _following_mixer_selection (false)
        , _control_point_toggled_on_press (false)
+       , _stepping_axis_view (0)
 {
        constructed = false;
 
@@ -696,6 +697,8 @@ Editor::Editor ()
        signal_configure_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
        signal_delete_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
 
+       Gtkmm2ext::Keyboard::the_keyboard().ShiftReleased.connect (sigc::mem_fun (*this, &Editor::shift_key_released));
+       
        /* allow external control surfaces/protocols to do various things */
 
        ControlProtocol::ZoomToSession.connect (*this, invalidator (*this), boost::bind (&Editor::temporal_zoom_session, this), gui_context());
@@ -5473,3 +5476,8 @@ Editor::popup_control_point_context_menu (ArdourCanvas::Item* item, GdkEvent* ev
        _control_point_context_menu.popup (event->button.button, event->button.time);
 }
 
+void
+Editor::shift_key_released ()
+{
+       _stepping_axis_view = 0;
+}
index 5134b6a7a1ab5013f45fce8a88dc6165523219a9..a2d7c93fd37d8ab10de200463b4d7425614183f8 100644 (file)
@@ -470,6 +470,14 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void get_pointer_position (double &, double &) const;
 
+       TimeAxisView* stepping_axis_view () {
+               return _stepping_axis_view;
+       }
+       
+       void set_stepping_axis_view (TimeAxisView* v) {
+               _stepping_axis_view = v;
+       }
+
   protected:
        void map_transport_state ();
        void map_position_change (framepos_t);
@@ -2102,6 +2110,17 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        /** Flag for a bit of a hack wrt control point selection; see set_selected_control_point_from_click */
        bool _control_point_toggled_on_press;
 
+       /** This is used by TimeAxisView to keep a track of the TimeAxisView that is currently being
+           stepped in height using Shift-Scrollwheel.  When a scroll event occurs, we do the step on
+           this _stepping_axis_view if it is non-0 (and we set up this _stepping_axis_view with the
+           TimeAxisView underneath the mouse if it is 0).  Then Editor resets _stepping_axis_view when
+           the shift key is released.  In this (hacky) way, pushing shift and moving the scroll wheel
+           will operate on the same track until shift is released (rather than skipping about to whatever
+           happens to be underneath the mouse at the time).
+       */
+       TimeAxisView* _stepping_axis_view;
+       void shift_key_released ();
+
        friend class Drag;
        friend class RegionDrag;
        friend class RegionMoveDrag;
index ddf03e968e3c3717c97d1efc59841bb296313468..ee5c7c1c2a4c68e4702b5456e1f3a0260b3984a4 100644 (file)
@@ -48,6 +48,7 @@
 #include "utils.h"
 #include "streamview.h"
 #include "editor_drag.h"
+#include "editor.h"
 
 #include "i18n.h"
 
@@ -317,7 +318,12 @@ TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev)
        switch (ev->direction) {
        case GDK_SCROLL_UP:
                if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
-                       step_height (false);
+                       /* See Editor::_stepping_axis_view for notes on this hack */
+                       Editor& e = dynamic_cast<Editor&> (_editor);
+                       if (!e.stepping_axis_view ()) {
+                               e.set_stepping_axis_view (this);
+                       }
+                       e.stepping_axis_view()->step_height (false);
                        return true;
                } else if (Keyboard::no_modifiers_active (ev->state)) {
                        _editor.scroll_tracks_up_line();
@@ -327,7 +333,12 @@ TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev)
 
        case GDK_SCROLL_DOWN:
                if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
-                       step_height (true);
+                       /* See Editor::_stepping_axis_view for notes on this hack */
+                       Editor& e = dynamic_cast<Editor&> (_editor);
+                       if (!e.stepping_axis_view ()) {
+                               e.set_stepping_axis_view (this);
+                       }
+                       e.stepping_axis_view()->step_height (true);
                        return true;
                } else if (Keyboard::no_modifiers_active (ev->state)) {
                        _editor.scroll_tracks_down_line();
index 3287cdb37ef3c51a35c645e9707d6b1c1fad0f90..909f791403e2228538c222c93c420731fd92aa43 100644 (file)
@@ -159,6 +159,8 @@ class Keyboard : public sigc::trackable, PBD::Stateful
            }
        };
 
+       sigc::signal0<void> ShiftReleased;
+
   protected:
        static Keyboard* _the_keyboard;
 
index 6328eb977c39492327ed7a55db6eff7cbcc5e57b..81b9ae642afc49d013e480874c50b2c1706d380a 100644 (file)
@@ -243,6 +243,14 @@ Keyboard::snooper (GtkWidget *widget, GdkEventKey *event)
                keyval = event->keyval;
        }
 
+       if (keyval == GDK_Shift_L) {
+               /* There is a special and rather hacky situation in Editor which makes
+                  it useful to know when a shift key has been released, so emit a signal
+                  here (see Editor::_stepping_axis_view)
+               */
+               ShiftReleased (); /* EMIT SIGNAL */
+       }
+
        if (event->type == GDK_KEY_PRESS) {
 
                if (find (state.begin(), state.end(), keyval) == state.end()) {