fix for bad sync with other JACK transport-aware clients (thanks to torben for discov...
[ardour.git] / gtk2_ardour / automation_time_axis.cc
index daf0a01b95483180a260b9f49998e5d81e7c6eff..f2144131ad86a548bd65d78256d16f0a0e60d24e 100644 (file)
@@ -49,17 +49,21 @@ Pango::FontDescription* AutomationTimeAxisView::name_font = 0;
 bool AutomationTimeAxisView::have_name_font = false;
 const string AutomationTimeAxisView::state_node_name = "AutomationChild";
 
+/** \a a the automatable object this time axis is to display data for.
+ * For route/track automation (e.g. gain) pass the route for both \r and \a.
+ * For route child (e.g. plugin) automation, pass the child for \a.
+ * For region automation (e.g. MIDI CC), pass null for \a.
+ */
 AutomationTimeAxisView::AutomationTimeAxisView (Session& s, boost::shared_ptr<Route> r,
                boost::shared_ptr<Automatable> a, boost::shared_ptr<AutomationControl> c,
                PublicEditor& e, TimeAxisView& parent, bool show_regions,
                ArdourCanvas::Canvas& canvas, const string & nom, const string & nomparent)
-
        : AxisView (s), 
          TimeAxisView (s, e, &parent, canvas),
          _route (r),
          _control (c),
          _automatable (a),
-         _controller(AutomationController::create(a, c->list(), c)),
+         _controller(AutomationController::create(a, c->parameter(), c)),
          _base_rect (0),
          _view (show_regions ? new AutomationStreamView(*this) : NULL),
          _name (nom),
@@ -208,7 +212,7 @@ AutomationTimeAxisView::AutomationTimeAxisView (Session& s, boost::shared_ptr<Ro
        } else {
        
                boost::shared_ptr<AutomationLine> line(new AutomationLine (
-                                       _control->parameter().symbol(),
+                                       ARDOUR::EventTypeMap::instance().to_symbol(_control->parameter()),
                                        *this,
                                        *canvas_display,
                                        _control->alist()));
@@ -238,14 +242,14 @@ AutomationTimeAxisView::auto_clicked ()
                automation_menu->set_name ("ArdourContextMenu");
                MenuList& items (automation_menu->items());
 
-               items.push_back (MenuElem (_("Manual"), 
-                                          bind (mem_fun(*this, &AutomationTimeAxisView::set_automation_state), (AutoState) Off)));
-               items.push_back (MenuElem (_("Play"),
-                                          bind (mem_fun(*this, &AutomationTimeAxisView::set_automation_state), (AutoState) Play)));
-               items.push_back (MenuElem (_("Write"),
-                                          bind (mem_fun(*this, &AutomationTimeAxisView::set_automation_state), (AutoState) Write)));
-               items.push_back (MenuElem (_("Touch"),
-                                          bind (mem_fun(*this, &AutomationTimeAxisView::set_automation_state), (AutoState) Touch)));
+               items.push_back (MenuElem (_("Manual"), bind (mem_fun(*this,
+                               &AutomationTimeAxisView::set_automation_state), (AutoState) Off)));
+               items.push_back (MenuElem (_("Play"), bind (mem_fun(*this,
+                               &AutomationTimeAxisView::set_automation_state), (AutoState) Play)));
+               items.push_back (MenuElem (_("Write"), bind (mem_fun(*this,
+                               &AutomationTimeAxisView::set_automation_state), (AutoState) Write)));
+               items.push_back (MenuElem (_("Touch"), bind (mem_fun(*this,
+                               &AutomationTimeAxisView::set_automation_state), (AutoState) Touch)));
        }
 
        automation_menu->popup (1, gtk_get_current_event_time());
@@ -255,15 +259,15 @@ void
 AutomationTimeAxisView::set_automation_state (AutoState state)
 {
        if (!ignore_state_request) {
-               if (_route == _automatable) { // FIXME: ew
-                       _route->set_parameter_automation_state (
-                                       _control->parameter(),
-                                       state);
+               if (_route == _automatable) { // This is a time axis for route (not region) automation
+                       _route->set_parameter_automation_state (_control->parameter(), state);
                }
 
-               _control->alist()->set_automation_state(state);
-
+               if (_control->list())
+                       _control->alist()->set_automation_state(state);
        }
+       if (_view)
+               _view->set_automation_state (state);
 }
 
 void
@@ -278,7 +282,7 @@ AutomationTimeAxisView::automation_state_changed ()
        } else {
                state = _control->alist()->automation_state ();
        }
-
+       
        switch (state & (Off|Play|Touch|Write)) {
        case Off:
                auto_button.set_label (_("Manual"));
@@ -353,8 +357,8 @@ void
 AutomationTimeAxisView::set_interpolation (AutomationList::InterpolationStyle style)
 {
        _control->list()->set_interpolation(style);
-               if (_line)
-       _line->set_interpolation(style);
+       if (_line)
+               _line->set_interpolation(style);
 }
 
 void
@@ -880,8 +884,8 @@ AutomationTimeAxisView::set_state (const XMLNode& node)
                if ((*iter)->name() == state_node_name) {
                        XMLProperty* type = (*iter)->property("automation-id");
 
-                       if (type && type->value() == _control->parameter().symbol()) {
-                               XMLProperty *shown = (*iter)->property("shown_editor");
+                       if (type && type->value() == ARDOUR::EventTypeMap::instance().to_symbol(_control->parameter())) {
+                               XMLProperty *shown = (*iter)->property("shown-editor");
 
                                if (shown && shown->value() == "yes") {
                                        set_marked_for_display(true);