Fix non visibility of previously-visible MIDI automation

tracks on session reload.


git-svn-id: svn://localhost/ardour2/branches/3.0@9863 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2011-07-13 17:13:30 +00:00
parent f6a50adf42
commit 80972784e3
6 changed files with 89 additions and 3 deletions

View File

@ -20,6 +20,8 @@
#include <utility>
#include <gtkmm2ext/barcontroller.h>
#include <gtkmm2ext/utils.h>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include "pbd/memento_command.h"
#include "pbd/stacktrace.h"
@ -1024,3 +1026,52 @@ AutomationTimeAxisView::state_id() const
(int) _parameter.channel());
}
}
/** Given a state id string, see if it is one generated by
* this class. If so, parse it into its components.
* @param state_id State ID string to parse.
* @param route_id Filled in with the route's ID if the state ID string is parsed.
* @param has_parameter Filled in with true if the state ID has a parameter, otherwise false.
* @param parameter Filled in with the state ID's parameter, if it has one.
* @return true if this is a state ID generated by this class, otherwise false.
*/
bool
AutomationTimeAxisView::parse_state_id (
string const & state_id,
PBD::ID & route_id,
bool & has_parameter,
Evoral::Parameter & parameter)
{
stringstream s;
s << state_id;
string a, b, c;
s >> a >> b >> c;
if (a != X_("automation")) {
return false;
}
route_id = PBD::ID (b);
if (c.empty ()) {
has_parameter = false;
return true;
}
has_parameter = true;
vector<string> p;
boost::split (p, c, boost::is_any_of ("/"));
assert (p.size() == 3);
parameter = Evoral::Parameter (
boost::lexical_cast<int> (p[0]),
boost::lexical_cast<int> (p[2]),
boost::lexical_cast<int> (p[1])
);
return true;
}

View File

@ -99,6 +99,7 @@ class AutomationTimeAxisView : public TimeAxisView {
int set_state (const XMLNode&, int version);
std::string state_id() const;
static bool parse_state_id (std::string const &, PBD::ID &, bool &, Evoral::Parameter &);
boost::shared_ptr<ARDOUR::AutomationControl> control() { return _control; }
boost::shared_ptr<AutomationController> controller() { return _controller; }

View File

@ -95,7 +95,7 @@ class AxisView : public virtual Selectable, public PBD::ScopedConnectionList, pu
bool _marked_for_display;
uint32_t _old_order_key;
private:
protected:
static GUIObjectState& gui_object_state();
}; /* class AxisView */

View File

@ -169,3 +169,18 @@ GUIObjectState::operator= (const GUIObjectState& other)
return *this;
}
/** @return begin iterator into our StringPropertyMap */
GUIObjectState::StringPropertyMap::const_iterator
GUIObjectState::begin () const
{
return _property_maps.begin ();
}
/** @return end iterator into our StringPropertyMap */
GUIObjectState::StringPropertyMap::const_iterator
GUIObjectState::end () const
{
return _property_maps.end ();
}

View File

@ -32,12 +32,15 @@ class GUIObjectState {
private:
typedef boost::variant<int64_t,std::string> Variant;
typedef std::map<std::string,Variant> PropertyMap;
typedef std::map<std::string,PropertyMap> StringPropertyMap;
public:
GUIObjectState() {}
typedef std::map<std::string,PropertyMap> StringPropertyMap;
~GUIObjectState();
StringPropertyMap::const_iterator begin () const;
StringPropertyMap::const_iterator end () const;
XMLNode& get_state () const;
int set_state (const XMLNode&);

View File

@ -230,6 +230,22 @@ MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt)
_percussion_mode_item->set_active (_note_mode == Percussive);
}
}
/* Look for any GUI object state nodes that represent automation children that should exist, and create
* the children.
*/
GUIObjectState& gui_state = gui_object_state ();
for (GUIObjectState::StringPropertyMap::const_iterator i = gui_state.begin(); i != gui_state.end(); ++i) {
PBD::ID route_id;
bool has_parameter;
Evoral::Parameter parameter (0, 0, 0);
bool const p = AutomationTimeAxisView::parse_state_id (i->first, route_id, has_parameter, parameter);
if (p && route_id == _route->id () && has_parameter) {
create_automation_child (parameter, string_is_affirmative (gui_object_state().get_string (i->first, X_("visible"))));
}
}
}
void