Fix visibility of automation tracks on reloading sessions.

git-svn-id: svn://localhost/ardour2/branches/3.0@4334 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2008-12-19 18:08:35 +00:00
parent f6469439f9
commit 331de3dc38
4 changed files with 55 additions and 46 deletions

View file

@ -85,8 +85,6 @@ AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
_view = new AudioStreamView (*this); _view = new AudioStreamView (*this);
create_automation_child (GainAutomation, false);
ignore_toggle = false; ignore_toggle = false;
mute_button->set_active (false); mute_button->set_active (false);
@ -102,13 +100,18 @@ AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
set_state (*xml_node); set_state (*xml_node);
_route->panner().Changed.connect (bind (mem_fun(*this, &AudioTimeAxisView::update_pans), false)); /* if set_state above didn't create a gain automation child, we need to make one */
if (automation_track (GainAutomation) == 0) {
create_automation_child (GainAutomation, false);
}
_route->panner().Changed.connect (bind (mem_fun(*this, &AudioTimeAxisView::ensure_pan_views), false));
/* map current state of the route */ /* map current state of the route */
processors_changed (); processors_changed ();
reset_processor_automation_curves (); reset_processor_automation_curves ();
update_pans (false); ensure_pan_views (false);
update_control_names (); update_control_names ();
if (is_audio_track()) { if (is_audio_track()) {
@ -342,20 +345,24 @@ AudioTimeAxisView::create_automation_child (const Evoral::Parameter& param, bool
} else if (param.type() == PanAutomation) { } else if (param.type() == PanAutomation) {
ensure_xml_node (); ensure_xml_node ();
update_pans (show); ensure_pan_views (show);
} else { } else {
error << "AudioTimeAxisView: unknown automation child " << EventTypeMap::instance().to_symbol(param) << endmsg; error << "AudioTimeAxisView: unknown automation child " << EventTypeMap::instance().to_symbol(param) << endmsg;
} }
} }
/** Ensure that we have the appropriate AutomationTimeAxisViews for the
* panners that we have.
*
* @param show true to show any new views that we create, otherwise false.
*/
void void
AudioTimeAxisView::update_pans (bool show) AudioTimeAxisView::ensure_pan_views (bool show)
{ {
const set<Evoral::Parameter>& params = _route->panner().what_can_be_automated(); const set<Evoral::Parameter>& params = _route->panner().what_can_be_automated();
set<Evoral::Parameter>::iterator p; set<Evoral::Parameter>::iterator p;
uint32_t i = 0;
for (p = params.begin(); p != params.end(); ++p) { for (p = params.begin(); p != params.end(); ++p) {
boost::shared_ptr<ARDOUR::AutomationControl> pan_control boost::shared_ptr<ARDOUR::AutomationControl> pan_control
= boost::dynamic_pointer_cast<ARDOUR::AutomationControl>( = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
@ -366,15 +373,25 @@ AudioTimeAxisView::update_pans (bool show)
continue; continue;
} }
boost::shared_ptr<AutomationTimeAxisView> pan_track(new AutomationTimeAxisView (_session, if (automation_child (pan_control->parameter ()).get () == 0) {
_route, _route, pan_control,
editor, /* we don't already have an AutomationTimeAxisView for this parameter */
*this,
false, std::string const name = _route->describe_parameter (pan_control->parameter ());
parent_canvas,
_route->describe_parameter(pan_control->parameter()))); boost::shared_ptr<AutomationTimeAxisView> pan_track (
add_automation_child(*p, pan_track, show); new AutomationTimeAxisView (_session,
++i; _route, _route, pan_control,
editor,
*this,
false,
parent_canvas,
name)
);
add_automation_child (*p, pan_track, show);
}
} }
} }
#if 0 #if 0

View file

@ -110,7 +110,7 @@ class AudioTimeAxisView : public RouteTimeAxisView
void gain_hidden (); void gain_hidden ();
void pan_hidden (); void pan_hidden ();
void update_pans (bool show=true); void ensure_pan_views (bool show = true);
void update_control_names (); void update_control_names ();
Gtk::CheckMenuItem* waveform_item; Gtk::CheckMenuItem* waveform_item;

View file

@ -49,6 +49,7 @@ Pango::FontDescription* AutomationTimeAxisView::name_font = 0;
bool AutomationTimeAxisView::have_name_font = false; bool AutomationTimeAxisView::have_name_font = false;
const string AutomationTimeAxisView::state_node_name = "AutomationChild"; const string AutomationTimeAxisView::state_node_name = "AutomationChild";
/** \a a the automatable object this time axis is to display data for. /** \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/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 route child (e.g. plugin) automation, pass the child for \a.
@ -863,30 +864,18 @@ AutomationTimeAxisView::set_state (const XMLNode& node)
{ {
TimeAxisView::set_state (node); TimeAxisView::set_state (node);
XMLNodeList kids; XMLProperty const * type = node.property ("automation-id");
XMLNodeConstIterator iter; if (type && type->value () == ARDOUR::EventTypeMap::instance().to_symbol (_control->parameter())) {
XMLProperty const * shown = node.property ("shown");
kids = node.children (); if (shown && shown->value () == "yes") {
set_marked_for_display (true);
for (iter = kids.begin(); iter != kids.end(); ++iter) { canvas_display->show (); /* FIXME: necessary? show_at? */
if ((*iter)->name() == state_node_name) {
XMLProperty* type = (*iter)->property("automation-id");
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);
canvas_display->show(); /* FIXME: necessary? show_at? */
}
break;
}
} }
} }
if (!_marked_for_display) if (!_marked_for_display) {
hide(); hide();
}
return 0; return 0;
} }

View file

@ -426,6 +426,7 @@ RouteTimeAxisView::set_state (const XMLNode& node)
for (iter = kids.begin(); iter != kids.end(); ++iter) { for (iter = kids.begin(); iter != kids.end(); ++iter) {
if ((*iter)->name() == AutomationTimeAxisView::state_node_name) { if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
if ((prop = (*iter)->property ("automation-id")) != 0) { if ((prop = (*iter)->property ("automation-id")) != 0) {
Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value()); Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
bool show = ((prop = (*iter)->property ("shown")) != 0) && prop->value() == "yes"; bool show = ((prop = (*iter)->property ("shown")) != 0) && prop->value() == "yes";
create_automation_child(param, show); create_automation_child(param, show);
@ -434,6 +435,7 @@ RouteTimeAxisView::set_state (const XMLNode& node)
} }
} }
} }
return 0; return 0;
} }
@ -1249,25 +1251,26 @@ RouteTimeAxisView::show_automation(Evoral::Parameter param)
return (_show_automation.find(param) != _show_automation.end()); return (_show_automation.find(param) != _show_automation.end());
} }
/** Retuns NULL if track for \a param doesn't exist. /** Retuns 0 if track for \a param doesn't exist.
*/ */
RouteTimeAxisView::RouteAutomationNode* RouteTimeAxisView::RouteAutomationNode*
RouteTimeAxisView::automation_track(Evoral::Parameter param) RouteTimeAxisView::automation_track (Evoral::Parameter param)
{ {
map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find(param); map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
if (i != _automation_tracks.end()) if (i != _automation_tracks.end()) {
return i->second; return i->second;
else } else {
return NULL; return 0;
}
} }
/** Shorthand for GainAutomation, etc. /** Shorthand for GainAutomation, etc.
*/ */
RouteTimeAxisView::RouteAutomationNode* RouteTimeAxisView::RouteAutomationNode*
RouteTimeAxisView::automation_track(AutomationType type) RouteTimeAxisView::automation_track (AutomationType type)
{ {
return automation_track(Evoral::Parameter(type)); return automation_track (Evoral::Parameter(type));
} }
RouteGroup* RouteGroup*