From 5576faf943f875cc13b807bdd0d3d99eb2714ff2 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 17 Feb 2011 16:18:27 +0000 Subject: [PATCH] Clean up some confusion with AutomationControls in AutomationTimeAxisViews that have regions. git-svn-id: svn://localhost/ardour2/branches/3.0@8883 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/audio_time_axis.cc | 1 + gtk2_ardour/automation_streamview.cc | 11 +++++----- gtk2_ardour/automation_streamview.h | 2 -- gtk2_ardour/automation_time_axis.cc | 31 +++++++++++++++++----------- gtk2_ardour/automation_time_axis.h | 8 +++++-- gtk2_ardour/midi_time_axis.cc | 6 ++---- gtk2_ardour/route_time_axis.cc | 6 +++--- 7 files changed, 37 insertions(+), 28 deletions(-) diff --git a/gtk2_ardour/audio_time_axis.cc b/gtk2_ardour/audio_time_axis.cc index fcdc4bbdfa..560c2dc15f 100644 --- a/gtk2_ardour/audio_time_axis.cc +++ b/gtk2_ardour/audio_time_axis.cc @@ -242,6 +242,7 @@ AudioTimeAxisView::ensure_pan_views (bool show) _route, _route->pannable(), pan_control, + pan_control->parameter (), _editor, *this, false, diff --git a/gtk2_ardour/automation_streamview.cc b/gtk2_ardour/automation_streamview.cc index a543c9d68c..86388f527f 100644 --- a/gtk2_ardour/automation_streamview.cc +++ b/gtk2_ardour/automation_streamview.cc @@ -52,7 +52,6 @@ AutomationStreamView::AutomationStreamView (AutomationTimeAxisView& tv) : StreamView (*dynamic_cast(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 } const boost::shared_ptr control = boost::dynamic_pointer_cast ( - region->control (_controller->controllable()->parameter(), true) + region->control (_automation_view.parameter(), true) ); boost::shared_ptr list; @@ -106,9 +105,11 @@ AutomationStreamView::add_region_view_internal (boost::shared_ptr 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); diff --git a/gtk2_ardour/automation_streamview.h b/gtk2_ardour/automation_streamview.h index 257908c9ea..2b8013fefd 100644 --- a/gtk2_ardour/automation_streamview.h +++ b/gtk2_ardour/automation_streamview.h @@ -75,8 +75,6 @@ class AutomationStreamView : public StreamView void color_handler (); - boost::shared_ptr _controller; - AutomationTimeAxisView& _automation_view; /** automation state that should be applied when this view gets its first RegionView */ ARDOUR::AutoState _pending_automation_state; diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index 35138e889b..8f57fefe87 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -64,6 +64,7 @@ AutomationTimeAxisView::AutomationTimeAxisView ( boost::shared_ptr r, boost::shared_ptr a, boost::shared_ptr 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 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; } diff --git a/gtk2_ardour/automation_time_axis.h b/gtk2_ardour/automation_time_axis.h index 885e95a864..7fc9c2575a 100644 --- a/gtk2_ardour/automation_time_axis.h +++ b/gtk2_ardour/automation_time_axis.h @@ -106,6 +106,9 @@ class AutomationTimeAxisView : public TimeAxisView { boost::shared_ptr control() { return _control; } boost::shared_ptr 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 _route; /** control; 0 if we are editing region-based automation */ - boost::shared_ptr _control; ///< Control + boost::shared_ptr _control; /** control owner; may be _route, or 0 if we are editing region-based automation */ boost::shared_ptr _automatable; /** controller owner; 0 if we are editing region-based automation */ boost::shared_ptr _controller; + Evoral::Parameter _parameter; ArdourCanvas::SimpleRect* _base_rect; boost::shared_ptr _line; diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 84288db326..77e862d8a9 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -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 c = _route->get_control (param); - assert (c); - boost::shared_ptr track ( new AutomationTimeAxisView ( _session, _route, _route, - c, + boost::shared_ptr (), + param, _editor, *this, true, diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 00007bab58..3f9e40cf76 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -1861,8 +1861,8 @@ RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr = boost::dynamic_pointer_cast(processor->control(what, true)); pan->view = boost::shared_ptr( - 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, -- 2.30.2