diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-05-16 07:30:28 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-05-31 15:30:42 -0400 |
commit | e0ff70cf86c01c42f98faf8b0eaf1a8ccf867946 (patch) | |
tree | dcb5ac7037e3b41d850930ea0a1759d79f8ca82a /libs/ardour/stripable.cc | |
parent | bae9474e9f04e324b1a2776b0fa9faefb5e6f0c2 (diff) |
first vaguely working version using PresentationInfo
remote control ID and "order keys" have been removed.
Diffstat (limited to 'libs/ardour/stripable.cc')
-rw-r--r-- | libs/ardour/stripable.cc | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/libs/ardour/stripable.cc b/libs/ardour/stripable.cc new file mode 100644 index 0000000000..d322fd75de --- /dev/null +++ b/libs/ardour/stripable.cc @@ -0,0 +1,160 @@ +/* + Copyright (C) 2016 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include <boost/algorithm/string.hpp> + +#include "pbd/compose.h" +#include "pbd/convert.h" + +#include "ardour/debug.h" +#include "ardour/rc_configuration.h" +#include "ardour/stripable.h" + +#include "i18n.h" + +using namespace ARDOUR; +using namespace PBD; +using std::string; + +PBD::Signal0<void> Stripable::PresentationInfoChange; + +Stripable::Stripable (Session& s, string const & name, PresentationInfo const & pi) + : SessionObject (s, name) + , _presentation_info (pi) +{ +} + +void +Stripable::set_presentation_group_order (PresentationInfo::order_t order, bool notify_class_listeners) +{ + set_presentation_info_internal (PresentationInfo (order, _presentation_info.flags()), notify_class_listeners); +} + +void +Stripable::set_presentation_group_order_explicit (PresentationInfo::order_t order) +{ + set_presentation_group_order (order, false); +} + +void +Stripable::set_presentation_info (PresentationInfo pi, bool notify_class_listeners) +{ + if (Config->get_remote_model() != UserOrdered) { + return; + } + + set_presentation_info_internal (pi, notify_class_listeners); +} + +void +Stripable::set_presentation_info_internal (PresentationInfo pi, bool notify_class_listeners) +{ + if (pi != presentation_info()) { + + DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("%1: set edit-based RID to %2\n", name(), pi)); + + if (is_master()) { + _presentation_info = PresentationInfo (0, PresentationInfo::MasterOut); + } else if (is_monitor()) { + _presentation_info = PresentationInfo (0, PresentationInfo::MonitorOut); + } else { + _presentation_info = pi; + } + + PresentationInfoChanged (); + + if (notify_class_listeners) { + PresentationInfoChange (); + } + } +} + +void +Stripable::set_presentation_info_explicit (PresentationInfo pi) +{ + set_presentation_info_internal (pi, false); +} + +int +Stripable::set_state (XMLNode const& node, int version) +{ + const XMLProperty *prop; + XMLNodeList const & nlist (node.children()); + XMLNodeConstIterator niter; + XMLNode *child; + + if (version > 3000) { + + std::cerr << "Looking for PI\n"; + + for (niter = nlist.begin(); niter != nlist.end(); ++niter){ + child = *niter; + + if (child->name() == X_("PresentationInfo")) { + std::cerr << "Found it\n"; + if ((prop = child->property (X_("value"))) != 0) { + _presentation_info = prop->value (); + std::cerr << "Set pinfo to " << _presentation_info << " from " << prop->value() << std::endl; + } + } + } + + } else { + std::cerr << "Old\n"; + + /* Older versions of Ardour stored "_flags" as a property of the Route + * node, only for 3 special Routes (MasterOut, MonitorOut, Auditioner. + * + * Their presentation order was stored in a node called "RemoteControl" + * + * This information is now part of the PresentationInfo of every Stripable. + */ + + if ((prop = node.property (X_("flags"))) != 0) { + + /* 4.x and earlier - didn't have Stripable but the + * relevant enums have the same names (MasterOut, + * MonitorOut, Auditioner), so we can use string_2_enum + */ + + PresentationInfo::Flag flags; + + if (version < 3000) { + string f (prop->value()); + boost::replace_all (f, "ControlOut", "MonitorOut"); + flags = PresentationInfo::Flag (string_2_enum (f, flags)); + } else { + flags = PresentationInfo::Flag (string_2_enum (prop->value(), flags)); + } + + _presentation_info.set_flags (flags); + + } + } + + return 0; +} + +void +Stripable::add_state (XMLNode& node) const +{ + XMLNode* remote_control_node = new XMLNode (X_("PresentationInfo")); + remote_control_node->add_property (X_("value"), _presentation_info.to_string()); + node.add_child_nocopy (*remote_control_node); +} |