diff options
author | Carl Hetherington <carl@carlh.net> | 2011-07-13 17:13:30 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-07-13 17:13:30 +0000 |
commit | 80972784e348aa51522e562b3d6b250745c489f0 (patch) | |
tree | 4d3fd6d92adea6a5e06e5ca9e2e516b960044d3e /gtk2_ardour | |
parent | f6a50adf42b40291d7b62d7e08348f5bfb8cc4ac (diff) |
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
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/automation_time_axis.cc | 51 | ||||
-rw-r--r-- | gtk2_ardour/automation_time_axis.h | 1 | ||||
-rw-r--r-- | gtk2_ardour/axis_view.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/gui_object.cc | 15 | ||||
-rw-r--r-- | gtk2_ardour/gui_object.h | 7 | ||||
-rw-r--r-- | gtk2_ardour/midi_time_axis.cc | 16 |
6 files changed, 89 insertions, 3 deletions
diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index def810f74e..7f70d3cd84 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -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; +} diff --git a/gtk2_ardour/automation_time_axis.h b/gtk2_ardour/automation_time_axis.h index 53e58153dd..0904357c27 100644 --- a/gtk2_ardour/automation_time_axis.h +++ b/gtk2_ardour/automation_time_axis.h @@ -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; } diff --git a/gtk2_ardour/axis_view.h b/gtk2_ardour/axis_view.h index ea502f8181..e4f4193852 100644 --- a/gtk2_ardour/axis_view.h +++ b/gtk2_ardour/axis_view.h @@ -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 */ diff --git a/gtk2_ardour/gui_object.cc b/gtk2_ardour/gui_object.cc index fda1e0b29e..fa708b25ad 100644 --- a/gtk2_ardour/gui_object.cc +++ b/gtk2_ardour/gui_object.cc @@ -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 (); +} + diff --git a/gtk2_ardour/gui_object.h b/gtk2_ardour/gui_object.h index 025be30fab..849665670f 100644 --- a/gtk2_ardour/gui_object.h +++ b/gtk2_ardour/gui_object.h @@ -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&); diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 8ebe40c864..0adb02725f 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -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 |