2 Copyright (C) 2016 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <boost/algorithm/string.hpp>
22 #include "pbd/compose.h"
23 #include "pbd/convert.h"
25 #include "ardour/debug.h"
26 #include "ardour/rc_configuration.h"
27 #include "ardour/stripable.h"
31 using namespace ARDOUR;
35 PBD::Signal0<void> Stripable::PresentationInfoChange;
37 Stripable::Stripable (Session& s, string const & name, PresentationInfo const & pi)
38 : SessionObject (s, name)
39 , _presentation_info (pi)
44 Stripable::set_presentation_group_order (PresentationInfo::order_t order, bool notify_class_listeners)
46 set_presentation_info_internal (PresentationInfo (order, _presentation_info.flags()), notify_class_listeners);
50 Stripable::set_presentation_group_order_explicit (PresentationInfo::order_t order)
52 set_presentation_group_order (order, false);
56 Stripable::set_presentation_info (PresentationInfo pi, bool notify_class_listeners)
58 if (Config->get_remote_model() != UserOrdered) {
62 set_presentation_info_internal (pi, notify_class_listeners);
66 Stripable::set_presentation_info_internal (PresentationInfo pi, bool notify_class_listeners)
68 if (pi != presentation_info()) {
70 DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("%1: set edit-based RID to %2\n", name(), pi));
73 _presentation_info = PresentationInfo (0, PresentationInfo::MasterOut);
74 } else if (is_monitor()) {
75 _presentation_info = PresentationInfo (0, PresentationInfo::MonitorOut);
77 _presentation_info = pi;
80 PresentationInfoChanged ();
82 if (notify_class_listeners) {
83 PresentationInfoChange ();
89 Stripable::set_presentation_info_explicit (PresentationInfo pi)
91 set_presentation_info_internal (pi, false);
95 Stripable::set_state (XMLNode const& node, int version)
97 const XMLProperty *prop;
98 XMLNodeList const & nlist (node.children());
99 XMLNodeConstIterator niter;
102 if (version > 3000) {
104 std::cerr << "Looking for PI\n";
106 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
109 if (child->name() == X_("PresentationInfo")) {
110 std::cerr << "Found it\n";
111 if ((prop = child->property (X_("value"))) != 0) {
112 _presentation_info = prop->value ();
113 std::cerr << "Set pinfo to " << _presentation_info << " from " << prop->value() << std::endl;
119 std::cerr << "Old\n";
121 /* Older versions of Ardour stored "_flags" as a property of the Route
122 * node, only for 3 special Routes (MasterOut, MonitorOut, Auditioner.
124 * Their presentation order was stored in a node called "RemoteControl"
126 * This information is now part of the PresentationInfo of every Stripable.
129 if ((prop = node.property (X_("flags"))) != 0) {
131 /* 4.x and earlier - didn't have Stripable but the
132 * relevant enums have the same names (MasterOut,
133 * MonitorOut, Auditioner), so we can use string_2_enum
136 PresentationInfo::Flag flags;
138 if (version < 3000) {
139 string f (prop->value());
140 boost::replace_all (f, "ControlOut", "MonitorOut");
141 flags = PresentationInfo::Flag (string_2_enum (f, flags));
143 flags = PresentationInfo::Flag (string_2_enum (prop->value(), flags));
146 _presentation_info.set_flags (flags);
155 Stripable::add_state (XMLNode& node) const
157 XMLNode* remote_control_node = new XMLNode (X_("PresentationInfo"));
158 remote_control_node->add_property (X_("value"), _presentation_info.to_string());
159 node.add_child_nocopy (*remote_control_node);