Implement reset() in panners, and use it from the GUI (fixes #4196).
authorCarl Hetherington <carl@carlh.net>
Sat, 22 Oct 2011 16:19:27 +0000 (16:19 +0000)
committerCarl Hetherington <carl@carlh.net>
Sat, 22 Oct 2011 16:19:27 +0000 (16:19 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10282 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/mono_panner.cc
gtk2_ardour/mono_panner.h
gtk2_ardour/panner_ui.cc
gtk2_ardour/stereo_panner.cc
libs/ardour/ardour/panner.h
libs/panners/1in2out/panner_1in2out.cc
libs/panners/1in2out/panner_1in2out.h
libs/panners/2in2out/panner_2in2out.cc
libs/panners/2in2out/panner_2in2out.h
libs/panners/vbap/vbap.cc
libs/panners/vbap/vbap.h

index 43afcd5c840c3cb639f559f40935317dd40cc41b..791c3e8d0b52b733c9f4b210479d80ac94f2c554 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "ardour/panner.h"
 #include "ardour/panner.h"
+#include "ardour/pannable.h"
 
 #include "ardour_ui.h"
 #include "global_signals.h"
@@ -55,8 +56,9 @@ static const int top_step = 2;
 MonoPanner::ColorScheme MonoPanner::colors;
 bool MonoPanner::have_colors = false;
 
-MonoPanner::MonoPanner (boost::shared_ptr<PBD::Controllable> position)
-        : position_control (position)
+MonoPanner::MonoPanner (boost::shared_ptr<ARDOUR::Panner> panner)
+       : _panner (panner)
+       , position_control (_panner->pannable()->pan_azimuth_control)
         , dragging (false)
         , drag_start_x (0)
         , last_drag_x (0)
@@ -64,7 +66,7 @@ MonoPanner::MonoPanner (boost::shared_ptr<PBD::Controllable> position)
         , detented (false)
         , drag_data_window (0)
         , drag_data_label (0)
-        , position_binder (position)
+        , position_binder (position_control)
 {
         if (!have_colors) {
                 set_colors ();
@@ -333,8 +335,7 @@ MonoPanner::on_button_release_event (GdkEventButton* ev)
         }
 
         if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
-                /* reset to default */
-                position_control->set_value (0.5);
+               _panner->reset ();
         } else {
                 StopGesture ();
         }
index f583140af92727abec2d5b8e7fe4d52b6029c69d..37a0932b99727f6aa21649497594cc9ebc2ff6f2 100644 (file)
@@ -34,7 +34,7 @@ namespace PBD {
 class MonoPanner : public Gtk::DrawingArea
 {
   public:
-       MonoPanner (boost::shared_ptr<PBD::Controllable> pos);
+       MonoPanner (boost::shared_ptr<ARDOUR::Panner>);
        ~MonoPanner ();
 
         boost::shared_ptr<PBD::Controllable> get_controllable() const { return position_control; }
@@ -54,6 +54,7 @@ class MonoPanner : public Gtk::DrawingArea
         bool on_leave_notify_event (GdkEventCrossing* ev);
 
   private:
+       boost::shared_ptr<ARDOUR::Panner> _panner;
         boost::shared_ptr<PBD::Controllable> position_control;
         PBD::ScopedConnectionList connections;
         bool dragging;
index 71a982124226ffc778a63605dd7b8ddc5e3fc124..05c2843630270676f2ca8a7f9dd556bf152b3af7 100644 (file)
@@ -283,7 +283,7 @@ PannerUI::setup_pan ()
                         boost::shared_ptr<Pannable> pannable = _panner->pannable();
                         boost::shared_ptr<AutomationControl> ac = pannable->pan_azimuth_control;
 
-                        mp = new MonoPanner (ac);
+                        mp = new MonoPanner (_panner);
 
                         mp->StartGesture.connect (sigc::bind (sigc::mem_fun (*this, &PannerUI::start_touch),
                                                                       boost::weak_ptr<AutomationControl> (ac)));
index 690acbfddaf626b632a0e57a5c213b3aee8b408d..e55d2c1b2061fe24a29a09a001a8dbaf359e1196 100644 (file)
@@ -418,7 +418,7 @@ StereoPanner::on_button_release_event (GdkEventButton* ev)
                return false;
        }
 
-       bool dp = dragging_position;
+       bool const dp = dragging_position;
 
        dragging = false;
        dragging_position = false;
@@ -432,9 +432,7 @@ StereoPanner::on_button_release_event (GdkEventButton* ev)
        }
 
        if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
-               /* reset to default */
-               position_control->set_value (0.5);
-               width_control->set_value (1.0);
+               _panner->reset ();
        } else {
                if (dp) {
                        StopPositionGesture ();
index f770a181c13e0eff32f191d462f909d6f3a43008..6f54ea7d792334bc4d444532f388dd0d2878d787 100644 (file)
@@ -81,7 +81,7 @@ public:
 
        virtual PBD::AngularVector signal_position (uint32_t) const { return PBD::AngularVector(); }
 
-       virtual void reset() {}
+       virtual void reset () = 0;
 
        void      set_automation_state (AutoState);
        AutoState automation_state() const;
index 19b8dadd6de75ecfd264dbf1c22ae75c0211e4d5..2fb2df7e9ab40bbdbfa7cdf65c6239f227603f6a 100644 (file)
@@ -373,3 +373,10 @@ Panner1in2out::value_as_string (boost::shared_ptr<AutomationControl> ac) const
                 return _pannable->value_as_string (ac);
         }
 }
+
+void
+Panner1in2out::reset ()
+{
+       set_position (0.5);
+       update ();
+}
index bd1b1a9c12125a2e2714a7efc4bd0255b89d8379..13b48fa839520a6333695e25210ec6a7be6d62fa 100644 (file)
@@ -58,6 +58,8 @@ class Panner1in2out : public Panner
 
        XMLNode& get_state ();
 
+       void reset ();
+
   protected:
        float left;
        float right;
index 1ac3974c49ebd0e4b0e34fc553dd9e148f207060..c9dac08cf12d2f3c0758ce6035e35fa914626332 100644 (file)
@@ -490,3 +490,11 @@ Panner2in2out::value_as_string (boost::shared_ptr<AutomationControl> ac) const
                 return _pannable->value_as_string (ac);
         }
 }
+
+void
+Panner2in2out::reset ()
+{
+       set_position (0.5);
+       set_width (1);
+       update ();
+}
index 48f441fbd031ba1b80723f181de5be777434198a..232d63ec62257ba988a81f11ee316efc77239563 100644 (file)
@@ -66,6 +66,8 @@ class Panner2in2out : public Panner
 
         void update ();
 
+       void reset ();
+
   protected:
        float left[2];
        float right[2];
index 59f8cddb62353c3395450bea4172b6e2c9c83541..f9ad5efed70a17690056194863008e20d61ccf81 100644 (file)
@@ -473,3 +473,12 @@ VBAPanner::set_width (double w)
 {
         _pannable->pan_width_control->set_value (min (1.0, max (-1.0, w)));
 }
+
+void
+VBAPanner::reset ()
+{
+       set_position (0);
+       set_width (1);
+
+       update ();
+}
index 752a0c9be664d3fd1733a21aef67e98980d77414..e90bbc6fb13ad5971b57e8275a7fc012f4fb13b7 100644 (file)
@@ -63,6 +63,8 @@ public:
         PBD::AngularVector signal_position (uint32_t n) const;
         boost::shared_ptr<Speakers> get_speakers() const;
 
+       void reset ();
+
 private:
         struct Signal {
             PBD::AngularVector direction;