fix behaviour of select_(next|prev)_route() in editor, when VCAs are present.
[ardour.git] / libs / ardour / stripable.cc
1 /*
2     Copyright (C) 2016 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #include <boost/algorithm/string.hpp>
21
22 #include "pbd/compose.h"
23 #include "pbd/convert.h"
24
25 #include "ardour/debug.h"
26 #include "ardour/rc_configuration.h"
27 #include "ardour/stripable.h"
28
29 #include "i18n.h"
30
31 using namespace ARDOUR;
32 using namespace PBD;
33 using std::string;
34
35 Stripable::Stripable (Session& s, string const & name, PresentationInfo const & pi)
36         : SessionObject (s, name)
37         , _presentation_info (pi)
38 {
39 }
40
41 void
42 Stripable::set_presentation_order (PresentationInfo::order_t order, bool notify_class_listeners)
43 {
44         _presentation_info.set_order (order);
45
46         if (notify_class_listeners) {
47                 PresentationInfo::Change ();
48         }
49 }
50
51 void
52 Stripable::set_presentation_order_explicit (PresentationInfo::order_t order)
53 {
54         _presentation_info.set_order (order);
55 }
56
57 int
58 Stripable::set_state (XMLNode const& node, int version)
59 {
60         const XMLProperty *prop;
61         XMLNodeList const & nlist (node.children());
62         XMLNodeConstIterator niter;
63         XMLNode *child;
64
65         if (version > 3001) {
66
67                 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
68                         child = *niter;
69
70                         if (child->name() == PresentationInfo::state_node_name) {
71                                 _presentation_info.set_state (*child, version);
72                         }
73                 }
74
75         } else {
76
77                 /* Older versions of Ardour stored "_flags" as a property of the Route
78                  * node, only for 3 special Routes (MasterOut, MonitorOut, Auditioner.
79                  *
80                  * Their presentation order was stored in a node called "RemoteControl"
81                  *
82                  * This information is now part of the PresentationInfo of every Stripable.
83                  */
84
85                 if ((prop = node.property (X_("flags"))) != 0) {
86
87                         /* 4.x and earlier - didn't have Stripable but the
88                          * relevant enums have the same names (MasterOut,
89                          * MonitorOut, Auditioner), so we can use string_2_enum
90                          */
91
92                         PresentationInfo::Flag flags;
93
94                         if (version < 3000) {
95                                 string f (prop->value());
96                                 boost::replace_all (f, "ControlOut", "MonitorOut");
97                                 flags = PresentationInfo::Flag (string_2_enum (f, flags));
98                         } else {
99                                 flags = PresentationInfo::Flag (string_2_enum (prop->value(), flags));
100                         }
101
102                         _presentation_info.set_flags (flags);
103
104                 }
105
106                 if (!_presentation_info.special()) {
107                         if ((prop = node.property (X_("order-key"))) != 0) {
108                                 _presentation_info.set_order (atol (prop->value()));
109                         }
110                 }
111         }
112
113         return 0;
114 }