Clean up some confusion with AutomationControls in AutomationTimeAxisViews that have...
authorCarl Hetherington <carl@carlh.net>
Thu, 17 Feb 2011 16:18:27 +0000 (16:18 +0000)
committerCarl Hetherington <carl@carlh.net>
Thu, 17 Feb 2011 16:18:27 +0000 (16:18 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@8883 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/audio_time_axis.cc
gtk2_ardour/automation_streamview.cc
gtk2_ardour/automation_streamview.h
gtk2_ardour/automation_time_axis.cc
gtk2_ardour/automation_time_axis.h
gtk2_ardour/midi_time_axis.cc
gtk2_ardour/route_time_axis.cc

index fcdc4bbdfa59e9f9146b71b88c6aecd8796cfabe..560c2dc15fd6c1eb7181198b70c52fe19b6fd254 100644 (file)
@@ -242,6 +242,7 @@ AudioTimeAxisView::ensure_pan_views (bool show)
                                                            _route, 
                                                             _route->pannable(), 
                                                             pan_control,
+                                                           pan_control->parameter (),
                                                            _editor,
                                                            *this,
                                                            false,
index a543c9d68cdba8d2d3faac3d31c808fbc99df492..86388f527f93e7008bad6579ec8c426716220489 100644 (file)
@@ -52,7 +52,6 @@ AutomationStreamView::AutomationStreamView (AutomationTimeAxisView& tv)
        : StreamView (*dynamic_cast<RouteTimeAxisView*>(tv.get_parent()),
                      new ArdourCanvas::Group(*tv.canvas_background()),
                      new ArdourCanvas::Group(*tv.canvas_display()))
-       , _controller(tv.controller())
        , _automation_view(tv)
        , _pending_automation_state (Off)
 {
@@ -78,7 +77,7 @@ AutomationStreamView::add_region_view_internal (boost::shared_ptr<Region> region
        }
 
        const boost::shared_ptr<AutomationControl> control = boost::dynamic_pointer_cast<AutomationControl> (
-               region->control (_controller->controllable()->parameter(), true)
+               region->control (_automation_view.parameter(), true)
                );
 
        boost::shared_ptr<AutomationList> list;
@@ -106,9 +105,11 @@ AutomationStreamView::add_region_view_internal (boost::shared_ptr<Region> region
                }
        }
 
-       region_view = new AutomationRegionView (_canvas_group, _automation_view, region,
-                       _controller->controllable()->parameter(), list,
-                       _samples_per_unit, region_color);
+       region_view = new AutomationRegionView (
+               _canvas_group, _automation_view, region,
+               _automation_view.parameter (), list,
+               _samples_per_unit, region_color
+               );
 
        region_view->init (region_color, false);
        region_views.push_front (region_view);
index 257908c9eaf5873813cdb864823b771223beab08..2b8013fefd659a80e530ce92c0710ea3c0e8c30c 100644 (file)
@@ -75,8 +75,6 @@ class AutomationStreamView : public StreamView
 
        void color_handler ();
 
-       boost::shared_ptr<AutomationController> _controller;
-
        AutomationTimeAxisView& _automation_view;
        /** automation state that should be applied when this view gets its first RegionView */
        ARDOUR::AutoState _pending_automation_state;
index 35138e889be461b325b433008181a1428abbf387..8f57fefe87037eceb1764aa2844d87193c82b389 100644 (file)
@@ -64,6 +64,7 @@ AutomationTimeAxisView::AutomationTimeAxisView (
        boost::shared_ptr<Route> r,
        boost::shared_ptr<Automatable> a,
        boost::shared_ptr<AutomationControl> c,
+       Evoral::Parameter p,
        PublicEditor& e,
        TimeAxisView& parent,
        bool show_regions,
@@ -76,7 +77,7 @@ AutomationTimeAxisView::AutomationTimeAxisView (
        , _route (r)
        , _control (c)
        , _automatable (a)
-       , _controller (AutomationController::create (a, c->parameter(), c))
+       , _parameter (p)
        , _base_rect (0)
        , _view (show_regions ? new AutomationStreamView (*this) : 0)
        , _name (nom)
@@ -87,6 +88,10 @@ AutomationTimeAxisView::AutomationTimeAxisView (
                have_name_font = true;
        }
 
+       if (_control) {
+               _controller = AutomationController::create (_automatable, _control->parameter(), _control);
+       }
+
        automation_menu = 0;
        auto_off_item = 0;
        auto_touch_item = 0;
@@ -193,8 +198,10 @@ AutomationTimeAxisView::AutomationTimeAxisView (
 
        controls_table.attach (auto_button, 5, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
 
-       /* add bar controller */
-       controls_table.attach (*_controller.get(), 0, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
+       if (_controller) {
+               /* add bar controller */
+               controls_table.attach (*_controller.get(), 0, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
+       }
 
        controls_table.show_all ();
 
@@ -205,7 +212,7 @@ AutomationTimeAxisView::AutomationTimeAxisView (
        controls_base_unselected_name = X_("AutomationTrackControlsBase");
        controls_ebox.set_name (controls_base_unselected_name);
 
-       XMLNode* xml_node = get_parent_with_state()->get_automation_child_xml_node (_control->parameter());
+       XMLNode* xml_node = get_parent_with_state()->get_automation_child_xml_node (_parameter);
 
        if (xml_node) {
                set_state (*xml_node, Stateful::loading_state_version);
@@ -222,7 +229,7 @@ AutomationTimeAxisView::AutomationTimeAxisView (
                
                boost::shared_ptr<AutomationLine> line (
                        new AutomationLine (
-                               ARDOUR::EventTypeMap::instance().to_symbol(_control->parameter()),
+                               ARDOUR::EventTypeMap::instance().to_symbol(_parameter),
                                *this,
                                *_canvas_display,
                                _control->alist()
@@ -275,11 +282,11 @@ AutomationTimeAxisView::set_automation_state (AutoState state)
        }
 
        if (_automatable) {
-               _automatable->set_parameter_automation_state (_control->parameter(), state);
+               _automatable->set_parameter_automation_state (_parameter, state);
        }
 #if 0
        if (_route == _automatable) { // This is a time axis for route (not region) automation
-               _route->set_parameter_automation_state (_control->parameter(), state);
+               _route->set_parameter_automation_state (_parameter, state);
        }
        
        if (_control->list()) {
@@ -418,7 +425,7 @@ AutomationTimeAxisView::set_height (uint32_t h)
 
        TimeAxisView* state_parent = get_parent_with_state ();
        assert(state_parent);
-       XMLNode* xml_node = state_parent->get_automation_child_xml_node (_control->parameter());
+       XMLNode* xml_node = state_parent->get_automation_child_xml_node (_parameter);
 
        TimeAxisView::set_height (h);
        _base_rect->property_y2() = h;
@@ -569,7 +576,7 @@ AutomationTimeAxisView::build_display_menu ()
        /* current interpolation state */
        AutomationList::InterpolationStyle const s = _view ? _view->interpolation() : _control->list()->interpolation ();
 
-       if (EventTypeMap::instance().is_midi_parameter(_control->parameter())) {
+       if (EventTypeMap::instance().is_midi_parameter(_parameter)) {
 
                Menu* auto_mode_menu = manage (new Menu);
                auto_mode_menu->set_name ("ArdourContextMenu");
@@ -973,7 +980,7 @@ AutomationTimeAxisView::set_state (const XMLNode& node, int version)
        }
        
        XMLProperty const * type = node.property ("automation-id");
-       if (type && type->value () == ARDOUR::EventTypeMap::instance().to_symbol (_control->parameter())) {
+       if (type && type->value () == ARDOUR::EventTypeMap::instance().to_symbol (_parameter)) {
                XMLProperty const * shown = node.property ("shown");
                if (shown && shown->value () == "yes") {
                        set_marked_for_display (true);
@@ -992,7 +999,7 @@ int
 
 AutomationTimeAxisView::set_state_2X (const XMLNode& node, int /*version*/)
 {
-       if (node.name() == X_("gain") && _control->parameter() == Evoral::Parameter (GainAutomation)) {
+       if (node.name() == X_("gain") && _parameter == Evoral::Parameter (GainAutomation)) {
                XMLProperty const * shown = node.property (X_("shown"));
                if (shown && string_is_affirmative (shown->value ())) {
                        set_marked_for_display (true);
@@ -1013,7 +1020,7 @@ AutomationTimeAxisView::get_state_node ()
        TimeAxisView* state_parent = get_parent_with_state ();
 
        if (state_parent) {
-               return state_parent->get_automation_child_xml_node (_control->parameter());
+               return state_parent->get_automation_child_xml_node (_parameter);
        } else {
                return 0;
        }
index 885e95a864e1a774b255cb1726abfccc0ccde633..7fc9c2575aaf2879adfa7f05e6a0e87c45148315 100644 (file)
@@ -106,6 +106,9 @@ class AutomationTimeAxisView : public TimeAxisView {
 
        boost::shared_ptr<ARDOUR::AutomationControl> control()    { return _control; }
        boost::shared_ptr<AutomationController>      controller() { return _controller; }
+       Evoral::Parameter parameter () const {
+               return _parameter;
+       }
 
        ArdourCanvas::Item* base_item () const {
                return _base_rect;
@@ -118,14 +121,15 @@ class AutomationTimeAxisView : public TimeAxisView {
        }
 
   protected:
-       /** parent route *
+       /** parent route */
        boost::shared_ptr<ARDOUR::Route> _route;
        /** control; 0 if we are editing region-based automation */
-       boost::shared_ptr<ARDOUR::AutomationControl> _control; ///< Control
+       boost::shared_ptr<ARDOUR::AutomationControl> _control;
        /** control owner; may be _route, or 0 if we are editing region-based automation */
        boost::shared_ptr<ARDOUR::Automatable> _automatable;
        /** controller owner; 0 if we are editing region-based automation */
        boost::shared_ptr<AutomationController> _controller;
+       Evoral::Parameter _parameter;
 
        ArdourCanvas::SimpleRect* _base_rect;
        boost::shared_ptr<AutomationLine> _line;
index 84288db326ab7bf48f548e9cfef8c3dbe6354842..77e862d8a90fb3f7663769a09c01b2195a39e6eb 100644 (file)
@@ -842,15 +842,13 @@ MidiTimeAxisView::create_automation_child (const Evoral::Parameter& param, bool
                /* These controllers are region "automation", so we do not create
                 * an AutomationList/Line for the track */
                
-               boost::shared_ptr<AutomationControl> c = _route->get_control (param);
-               assert (c);
-               
                boost::shared_ptr<AutomationTimeAxisView> track (
                        new AutomationTimeAxisView (
                                _session,
                                _route, 
                                _route,
-                               c,
+                               boost::shared_ptr<AutomationControl> (),
+                               param,
                                _editor,
                                *this,
                                true,
index 00007bab5870f99ce3c591bf3f959bad4cb68e24..3f9e40cf76ef5324ae3c120c4c9a42e4da0221f7 100644 (file)
@@ -1861,8 +1861,8 @@ RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor>
                        = boost::dynamic_pointer_cast<AutomationControl>(processor->control(what, true));
 
        pan->view = boost::shared_ptr<AutomationTimeAxisView>(
-                       new AutomationTimeAxisView (_session, _route, processor, control,
-                               _editor, *this, false, parent_canvas, name, state_name));
+               new AutomationTimeAxisView (_session, _route, processor, control, control->parameter (),
+                                           _editor, *this, false, parent_canvas, name, state_name));
 
        pan->view->Hiding.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
 
@@ -2407,7 +2407,7 @@ RouteTimeAxisView::create_gain_automation_child (const Evoral::Parameter& param,
        }
 
        gain_track.reset (new AutomationTimeAxisView (_session,
-                                                     _route, _route->amp(), c,
+                                                     _route, _route->amp(), c, param,
                                                      _editor,
                                                      *this,
                                                      false,