Somewhat distasteful hack to fix #3469 (broken keyboard-entry of pan values)
authorCarl Hetherington <carl@carlh.net>
Fri, 26 Nov 2010 00:29:12 +0000 (00:29 +0000)
committerCarl Hetherington <carl@carlh.net>
Fri, 26 Nov 2010 00:29:12 +0000 (00:29 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@8090 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/mixer_strip.cc
gtk2_ardour/panner_ui.cc
gtk2_ardour/panner_ui.h
libs/gtkmm2ext/barcontroller.cc
libs/gtkmm2ext/gtkmm2ext/barcontroller.h

index f5ed9d86181f0174707ec9ef6d43620909fe6d9e..dc788dd35e50a1f9ca6265ff844d9187c0a3a82d 100644 (file)
@@ -1912,7 +1912,16 @@ bool
 MixerStrip::on_enter_notify_event (GdkEventCrossing*)
 {
        Keyboard::magic_widget_grab_focus ();
-       grab_focus ();
+
+       if (!panners._bar_spinner_active) {
+               /* This next grab_focus() causes a focus-out event to be sent to, amongst
+                * other things, panner BarControllers.  When they receive it, they abort
+                * the use of any SpinButton that might be in use to change pan settings.
+                * Hence we have this horrific hack which stops the grab_focus () call
+                * happening if a bar spinner is active.
+                */
+               grab_focus ();
+       }
        return false;
 }
 
index ea9b270bb5b8fba076124842b408d0b63db65a02..25580f0f511c032d81ff871d039dbd6a64cb334b 100644 (file)
@@ -58,6 +58,7 @@ PannerUI::PannerUI (Session* s)
        , panning_link_button (_("link"))
        , pan_automation_style_button ("")
        , pan_automation_state_button ("")
+       , _bar_spinner_active (false)
 {
        set_session (s);
 
@@ -453,6 +454,7 @@ PannerUI::setup_pan ()
                                (sigc::bind (sigc::mem_fun(*this, &PannerUI::pan_button_event), (uint32_t) asz));
 
                        bc->set_size_request (-1, pan_bar_height);
+                       bc->SpinnerActive.connect (sigc::mem_fun (*this, &PannerUI::bar_spinner_activate));
 
                        pan_bars.push_back (bc);
                        pan_bar_packer.pack_start (*bc, false, false);
@@ -921,3 +923,9 @@ PannerUI::connect_to_pan_control (uint32_t i)
                _pan_control_connections, invalidator (*this), boost::bind (&PannerUI::pan_value_changed, this, i), gui_context ()
                );
 }
+
+void
+PannerUI::bar_spinner_activate (bool a)
+{
+       _bar_spinner_active = a;
+}
index 0e16d01a64601a8c8157c10d6fafd618d6343908..4c0039a8d34c5ddc1409689b81154dff48ba7ded 100644 (file)
@@ -170,6 +170,10 @@ class PannerUI : public Gtk::HBox, public ARDOUR::SessionHandlePtr
 
         void start_touch (boost::weak_ptr<ARDOUR::AutomationControl>);
         void stop_touch (boost::weak_ptr<ARDOUR::AutomationControl>);
+
+       void bar_spinner_activate (bool);
+       /** true if any of our PannerBars are currently using a SpinButton to modify value */
+       bool _bar_spinner_active;
 };
 
 #endif /* __ardour_gtk_panner_ui_h__ */
index 75e5d4e7d679ff9c7b8ace9443b3b2bd613d1555..1b8c210fc97c5d9dda659f277d4ed18ad8ce6276 100644 (file)
@@ -398,6 +398,9 @@ BarController::switch_to_bar ()
        darea.show ();
 
        switching = false;
+
+       SpinnerActive (false); /* EMIT SIGNAL */
+       
        return FALSE;
 }
 
@@ -421,6 +424,9 @@ BarController::switch_to_spinner ()
        spinner.grab_focus ();
 
        switching = false;
+
+       SpinnerActive (true); /* EMIT SIGNAL */
+
        return FALSE;
 }
 
index f3eb2f41cd264aec3672f10f6b24a4620e768fe9..1a0b78dabe3aa94f031a7f38e57b54f09cb84f95 100644 (file)
@@ -61,6 +61,11 @@ class BarController : public Gtk::Frame
        boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
        void set_controllable(boost::shared_ptr<PBD::Controllable> c) { binding_proxy.set_controllable(c); }
 
+       /** Emitted when the adjustment spinner is activated or deactivated;
+        *  the parameter is true on activation, false on deactivation.
+        */
+       sigc::signal<void, bool> SpinnerActive;
+
   protected:
        Gtk::Adjustment&    adjustment;
        BindingProxy        binding_proxy;