virtualize the way that AutomationController gets strings to display values, so that...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 27 Jan 2011 18:48:33 +0000 (18:48 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 27 Jan 2011 18:48:33 +0000 (18:48 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@8590 d708f5d6-7413-0410-9779-e7cbd77b26cf

16 files changed:
gtk2_ardour/automation_controller.cc
gtk2_ardour/automation_controller.h
gtk2_ardour/automation_time_axis.cc
libs/ardour/ardour/automatable.h
libs/ardour/ardour/pannable.h
libs/ardour/ardour/panner.h
libs/ardour/automatable.cc
libs/ardour/pannable.cc
libs/ardour/panner.cc
libs/gtkmm2ext/gtkmm2ext/barcontroller.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 f09fae905bb24dc986011818889e53be602a6efa..540612c8d456d49d2f3385c18a83fbe87fb624e4 100644 (file)
@@ -19,6 +19,7 @@
 */
 
 #include <iomanip>
+#include <cmath>
 
 #include "pbd/error.h"
 
 using namespace ARDOUR;
 using namespace Gtk;
 
-
-AutomationController::AutomationController(boost::shared_ptr<AutomationControl> ac, Adjustment* adj)
+AutomationController::AutomationController(boost::shared_ptr<Automatable> owner, boost::shared_ptr<AutomationControl> ac, Adjustment* adj)
        : BarController (*adj, ac)
        , _ignore_change(false)
+        , _owner (owner)
        , _controllable(ac)
        , _adjustment(adj)
 {
@@ -80,30 +81,18 @@ AutomationController::create(
        } else {
                assert(ac->parameter() == param);
        }
-       return boost::shared_ptr<AutomationController>(new AutomationController(ac, adjustment));
+       return boost::shared_ptr<AutomationController>(new AutomationController(parent, ac, adjustment));
 }
 
 std::string
 AutomationController::get_label (int&)
 {
-       std::stringstream s;
-
-       // Hack to display CC rounded to int
-       if (_controllable->parameter().type() == MidiCCAutomation) {
-               s << (int)_controllable->get_value();
-       } else {
-               s << std::fixed << std::setprecision(3) << _controllable->get_value();
-       }
-
-       return s.str ();
+        return _owner->value_as_string (_controllable);
 }
 
 void
 AutomationController::display_effective_value()
 {
-       //if ( ! _controllable->list()->automation_playback())
-       //      return;
-
        float value = _controllable->get_value();
 
        if (_adjustment->get_value() != value) {
index a2168700e27edbc26ad46f9947150f4cc527d9da..814f716f13c351a88dc05ff3963ed9c8dcbac699 100644 (file)
@@ -54,7 +54,7 @@ public:
        void stop_updating ();
 
 private:
-       AutomationController (boost::shared_ptr<ARDOUR::AutomationControl> ac, Gtk::Adjustment* adj);
+       AutomationController (boost::shared_ptr<ARDOUR::Automatable> parent, boost::shared_ptr<ARDOUR::AutomationControl> ac, Gtk::Adjustment* adj);
        std::string get_label (int&);
 
        void start_touch();
@@ -64,6 +64,7 @@ private:
        void automation_state_changed();
 
        bool                                         _ignore_change;
+        boost::shared_ptr<ARDOUR::Automatable>       _owner;
        boost::shared_ptr<ARDOUR::AutomationControl> _controllable;
        Gtk::Adjustment*                             _adjustment;
        sigc::connection                             _screen_update_connection;
index e0a2cd0970e1f0063ac17f5d11635ebadfc6a71b..2cdb6f7de924c421163d64da5447146a406ae820 100644 (file)
@@ -148,6 +148,7 @@ AutomationTimeAxisView::AutomationTimeAxisView (Session* s, boost::shared_ptr<Ro
 
        name_label.set_text (shortpname);
        name_label.set_alignment (Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER);
+        name_label.set_name (X_("TrackParameterName"));
 
        if (nomparent.length()) {
 
@@ -161,7 +162,6 @@ AutomationTimeAxisView::AutomationTimeAxisView (Session* s, boost::shared_ptr<Ro
                plugname = new Label (pname);
                plugname->set_name (X_("TrackPlugName"));
                plugname->show();
-               name_label.set_name (X_("TrackParameterName"));
                controls_table.remove (name_hbox);
                controls_table.attach (*plugname, 1, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
                plugname_packed = true;
index c9e900e6a9d908f07a1a81c6381fe87d22e88c37..1abfb4faf164acbb55da6921e9c0236d17c8ea1f 100644 (file)
@@ -63,6 +63,7 @@ public:
        virtual void transport_stopped (framepos_t now);
 
        virtual std::string describe_parameter(Evoral::Parameter param);
+        virtual std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
 
        AutoState get_parameter_automation_state (Evoral::Parameter param);
        virtual void set_parameter_automation_state (Evoral::Parameter param, AutoState);
index dff64cec4bc875ff77f58bf23479dce97602be70..3dc4ccb8fd42dbfd6ebbf0bc5dad1ec693f0b9b5 100644 (file)
@@ -65,6 +65,8 @@ struct Pannable : public PBD::Stateful, public Automatable, public SessionHandle
                 return ((_auto_state & Write) || ((_auto_state & Touch) && touching()));
         }
 
+        std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
+
        void start_touch (double when);
        void stop_touch (bool mark, double when);
        bool touching() const { return g_atomic_int_get (&_touching); }
index f43be2dbbc4722e93021adba64eb9138137e524e..c26d1a6a2c7696c76623b1e9a91d6d79500f9db5 100644 (file)
@@ -93,6 +93,7 @@ class Panner : public PBD::Stateful, public PBD::ScopedConnectionList
 
        virtual std::set<Evoral::Parameter> what_can_be_automated() const;
         virtual std::string describe_parameter (Evoral::Parameter);
+        virtual std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
 
        bool touching() const;
 
index 0d2413571057d82e8c1e51f39c1645e01b2e545c..20dc910f61d2af439e6bc8c2e693e8b6117d4dae 100644 (file)
@@ -492,3 +492,23 @@ Automatable::clear_controls ()
        _control_connections.drop_connections ();
        ControlSet::clear_controls ();
 }
+
+string
+Automatable::value_as_string (boost::shared_ptr<AutomationControl> ac) const
+{
+       std::stringstream s;
+
+        /* this is a the default fallback for this virtual method. Derived Automatables
+           are free to override this to display the values of their parameters/controls
+           in different ways.
+        */
+
+       // Hack to display CC as integer value, rather than double
+       if (ac->parameter().type() == MidiCCAutomation) {
+               s << lrint (ac->get_value());
+       } else {
+               s << std::fixed << std::setprecision(3) << ac->get_value();
+       }
+
+       return s.str ();
+}
index 4243ab45dfe07e2856a42c43d127810729c7dd91..1e2d5f559493f8900812d7a160c72c4a22aca232 100644 (file)
 #include "ardour/automation_control.h"
 #include "ardour/automation_list.h"
 #include "ardour/pannable.h"
+#include "ardour/panner.h"
 #include "ardour/pan_controllable.h"
 #include "ardour/session.h"
 
+using namespace std;
 using namespace PBD;
 using namespace ARDOUR;
 
@@ -245,6 +247,12 @@ Pannable::set_state (const XMLNode& root, int /*version - not used*/)
         return 0;
 }
 
+string 
+Pannable::value_as_string (boost::shared_ptr<AutomationControl> ac) const
+{
+        if (_panner) {
+                return _panner->value_as_string (ac);
+        } 
 
-
-        
+        return Automatable::value_as_string (ac);
+}
index bfee68a34261d1d09580df3a91ba044b05449a8c..1cb5e310aa36fc5a62106389c29eb45dcd7b0a10 100644 (file)
@@ -161,3 +161,9 @@ Panner::describe_parameter (Evoral::Parameter p)
 {
         return _pannable->describe_parameter (p);
 }
+
+string 
+Panner::value_as_string (boost::shared_ptr<AutomationControl> ac) const
+{
+        return _pannable->value_as_string (ac);
+}
index e0e14f1c26d1625873a9711a9aa64d087b9f62a7..c65d8abe81872b8fff15d3b28f06129918789757 100644 (file)
@@ -82,6 +82,8 @@ class BarController : public Gtk::Frame
        Gtk::SpinButton     spinner;
        bool                use_parent;
        bool                logarithmic;
+        sigc::slot<std::string> _label_slot;
+        bool                    _use_slot;
 
        virtual std::string get_label (int& /*x*/) {
                return "";
index 7a59aa04cc276bd23bdda87c1c6399ea4bc1ad64..cce2ec9b715237ca53741cb66c547004384f5076 100644 (file)
@@ -362,3 +362,27 @@ Panner1in2out::describe_parameter (Evoral::Parameter p)
                 return _pannable->describe_parameter (p);
         }
 }
+
+string 
+Panner1in2out::value_as_string (boost::shared_ptr<AutomationControl> ac) const
+{
+        /* DO NOT USE LocaleGuard HERE */
+        double val = ac->get_value();
+
+        switch (ac->parameter().type()) {
+        case PanAzimuthAutomation:
+                /* We show the position of the center of the image relative to the left & right.
+                   This is expressed as a pair of percentage values that ranges from (100,0) 
+                   (hard left) through (50,50) (hard center) to (0,100) (hard right).
+                   
+                   This is pretty wierd, but its the way audio engineers expect it. Just remember that
+                   the center of the USA isn't Kansas, its (50LA, 50NY) and it will all make sense.
+                */
+                
+                return string_compose (_("L:%1 R:%2"), (int) rint (100.0 * (1.0 - val)),
+                                       (int) rint (100.0 * val));
+                
+        default:
+                return _pannable->value_as_string (ac);
+        }
+}
index ced467c11bb5fe21429cedc5a2854f9e642ffe1e..ffc67ac54dfeecc8e11a1154370cfa73b2e81b37 100644 (file)
@@ -60,6 +60,7 @@ class Panner1in2out : public Panner
         static Panner* factory (boost::shared_ptr<Pannable>, Speakers&);
 
         std::string describe_parameter (Evoral::Parameter);
+        std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
 
        XMLNode& state (bool full_state); 
        XMLNode& get_state (void); 
index 2c2856361c8014708609144880ac416ff45fd820..30d971d118d0126902daf98a2013c6ec1f39c14f 100644 (file)
@@ -473,3 +473,30 @@ Panner2in2out::describe_parameter (Evoral::Parameter p)
                 return _pannable->describe_parameter (p);
         }
 }
+
+string 
+Panner2in2out::value_as_string (boost::shared_ptr<AutomationControl> ac) const
+{
+        /* DO NOT USE LocaleGuard HERE */
+        double val = ac->get_value();
+
+        switch (ac->parameter().type()) {
+        case PanAzimuthAutomation:
+                /* We show the position of the center of the image relative to the left & right.
+                   This is expressed as a pair of percentage values that ranges from (100,0) 
+                   (hard left) through (50,50) (hard center) to (0,100) (hard right).
+                   
+                   This is pretty wierd, but its the way audio engineers expect it. Just remember that
+                   the center of the USA isn't Kansas, its (50LA, 50NY) and it will all make sense.
+                */
+                
+                return string_compose (_("L:%1 R:%2"), (int) rint (100.0 * (1.0 - val)),
+                                       (int) rint (100.0 * val));
+                
+        case PanWidthAutomation:
+                return string_compose (_("Width: %1%%"), (int) floor (100.0 * val));
+                
+        default:
+                return _pannable->value_as_string (ac);
+        }
+}
index 0bb38fa27f79190ebc9152533fb5444eb5621d3f..2014bb032e4e3c429bd9ad3e00353127bc658c22 100644 (file)
@@ -60,6 +60,7 @@ class Panner2in2out : public Panner
        static Panner* factory (boost::shared_ptr<Pannable>, Speakers&);
 
         std::string describe_parameter (Evoral::Parameter);
+        std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
 
        XMLNode& state (bool full_state); 
        XMLNode& get_state (void); 
index 6088a2d0d6dda3c39033ff60cd136b28a974d7e1..239a253f19f560468bcdc1e2890aaacdbdb75b09 100644 (file)
@@ -313,3 +313,21 @@ VBAPanner::describe_parameter (Evoral::Parameter p)
                 return _pannable->describe_parameter (p);
         }
 }
+
+string 
+VBAPanner::value_as_string (boost::shared_ptr<AutomationControl> ac) const
+{
+        /* DO NOT USE LocaleGuard HERE */
+        double val = ac->get_value();
+
+        switch (ac->parameter().type()) {
+        case PanAzimuthAutomation: /* direction */
+                return string_compose (_("%1"), val * 360.0);
+                
+        case PanWidthAutomation: /* diffusion */
+                return string_compose (_("%1%%"), (int) floor (100.0 * fabs(val)));
+                
+        default:
+                return _pannable->value_as_string (ac);
+        }
+}
index 2b80b032cb7a54b082ae6a06f4cebaf2a824c2ad..cf010cc33190a486771429848f3f5c462cd8bf14 100644 (file)
@@ -53,6 +53,7 @@ public:
        void set_azimuth_elevation (double azimuth, double elevation);
 
         std::string describe_parameter (Evoral::Parameter);
+        std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
 
        XMLNode& state (bool full_state);
        XMLNode& get_state ();