simplify PresentationInfo concept of order so that it is always global
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 3 Jun 2016 19:14:23 +0000 (15:14 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 3 Jun 2016 19:15:39 +0000 (15:15 -0400)
Cases that need more complex sort orders (e.g. all routes, then all vcas then master) need
to take of this themselves

libs/ardour/ardour/presentation_info.h
libs/ardour/luabindings.cc
libs/ardour/route_graph.cc
libs/ardour/session.cc
libs/ardour/stripable.cc

index f12de944c764fba97173ebe89e4da1de4d02e048..2afaa345d1d3bae6fb5eeac779561fa626776e86 100644 (file)
@@ -58,27 +58,6 @@ class LIBARDOUR_API PresentationInfo
         * makes it show only busses, or only MIDI tracks. At that point, the
         * ordering on the surface differs from the ordering in the GUI.
         *
-        * The ordering is given via a combination of an object type and a
-        * simple numeric position within that type. The object types at this
-        * time are:
-        *
-        *     Route
-        *        - object has inputs and outputs; processes data
-        *     Output
-        *        - Route used to connect to outside the application (MasterOut, MonitorOut)
-        *     Special
-        *        - special type of Route (e.g. Auditioner)
-        *     VCA
-        *        - no data flows through; control only
-        *
-        * Objects with a numeric order of zero are considered unsorted. This
-        * applies (for now) to special objects such as the master out,
-        * auditioner and monitor out.  The rationale here is that the GUI
-        * presents these objects in special ways, rather than as part of some
-        * (potentially) re-orderable container. The same is true for hardware
-        * surfaces, where the master fader (for instance) is typically
-        * separate and distinct from anything else.
-        *
         * There are several pathways for the order being set:
         *
         *   - object created during session loading from XML
@@ -115,7 +94,6 @@ class LIBARDOUR_API PresentationInfo
         *
         */
 
-
        enum Flag {
                /* Type information */
                AudioTrack = 0x1,
@@ -123,26 +101,19 @@ class LIBARDOUR_API PresentationInfo
                AudioBus = 0x4,
                MidiBus = 0x8,
                VCA = 0x10,
-
-               /* These need to be at the high end */
-               MasterOut = 0x800,
-               MonitorOut = 0x1000,
-               Auditioner = 0x2000,
-
+               MasterOut = 0x20,
+               MonitorOut = 0x40,
+               Auditioner = 0x80,
                /* These are for sharing Stripable states between the GUI and other
                 * user interfaces/control surfaces
                 */
-               Selected = 0x4000,
-               Hidden = 0x8000,
-
+               Selected = 0x100,
+               Hidden = 0x200,
                /* single bit indicates that the group order is set */
-               GroupOrderSet = 0x10000000,
-
-               /* Masks */
+               GroupOrderSet = 0x400,
 
-               GroupMask = (AudioTrack|MidiTrack|AudioBus|MidiBus|VCA),
-               SpecialMask = (MasterOut|MonitorOut|Auditioner),
-               StatusMask = (Selected|Hidden),
+               /* special mask to delect out "state" bits */
+               StatusMask = (Selected|Hidden)
        };
 
        static const Flag Route;
@@ -157,58 +128,15 @@ class LIBARDOUR_API PresentationInfo
 
        static const order_t max_order;
 
-       order_t  group_order() const { return _order; }
-       global_order_t global_order () const {
-               if (_flags & Route) {
-
-                       /* set all bits related to Route so that all Routes
-                          sort together, with order() in the range of
-                          64424509440..68719476735
-
-                          Consider the following arrangement:
-
-                          Track   1
-                          Bus     1
-                          Track   2
-                          ---------
-                          VCA     1
-                          ---------
-                          Master
-                          ---------
-                          Monitor
-
-                          these translate into the following
-
-                          _order  |  _flags            | global_order()
-                          --------------------------------------
-                          1       |   0x1   AudioTrack | ((0x1|0x2|0x4|0x8)<<32)|1 = 64424509441
-                          2       |   0x2   AudioBus   | ((0x1|0x2|0x4|0x8)<<32)|2 = 64424509442
-                          3       |   0x1   AudioTrack | ((0x1|0x2|0x4|0x8)<<32)|3 = 64424509443
-
-                          1       |   0x10  VCA        | ((0x10)<<32)|1 = 68719476737
-
-                          0       |   0x800 Master     | (0x800<<32) = 8796093022208
-
-                          0       |   0x1000 Monitor   | (0x1000<<32) = 17592186044416
-
-                       */
-
-                       return (((global_order_t) (_flags | Route)) << (8*sizeof(order_t))) | _order;
-               } else {
-                       return (((global_order_t) _flags) << (8*sizeof(order_t))) | _order;
-               }
-       }
+       order_t  order() const { return _order; }
 
        PresentationInfo::Flag flags() const { return _flags; }
 
-       bool order_set() const { return _order != 0; }
-
-       /* these objects have no defined order */
-       bool special () const { return _flags & SpecialMask; }
+       bool order_set() const { return _flags & GroupOrderSet; }
 
-       /* detect group order set/not set */
-       bool unordered() const { return !(_flags & GroupOrderSet); }
-       bool ordered() const { return _flags & GroupOrderSet; }
+       bool hidden() const { return _flags & Hidden; }
+       bool selected() const { return _flags & Selected; }
+       bool special() const { return _flags & (MasterOut|MonitorOut|Auditioner); }
 
        void set_flag (PresentationInfo::Flag f) {
                _flags = PresentationInfo::Flag (_flags | f);
@@ -261,7 +189,7 @@ class LIBARDOUR_API PresentationInfo
        }
 
        bool operator< (PresentationInfo const& other) const {
-               return global_order() < other.global_order();
+               return order() < other.order();
        }
 
        PresentationInfo& operator= (std::string const& str) {
@@ -270,22 +198,22 @@ class LIBARDOUR_API PresentationInfo
        }
 
        bool match (PresentationInfo const& other) const {
-               return (_order == other.group_order()) && flag_match (other.flags());
+               return (_order == other.order()) && flag_match (other.flags());
        }
 
        bool operator==(PresentationInfo const& other) {
-               return (_order == other.group_order()) && (_flags == other.flags());
+               return (_order == other.order()) && (_flags == other.flags());
        }
 
        bool operator!=(PresentationInfo const& other) {
-               return (_order != other.group_order()) || (_flags != other.flags());
+               return (_order != other.order()) || (_flags != other.flags());
        }
 
        static Flag get_flags (XMLNode const& node);
 
   protected:
        friend class Stripable;
-       void set_group_order (order_t order) { _order = order; _flags = Flag (_flags|GroupOrderSet); }
+       void set_order (order_t order) { _order = order; _flags = Flag (_flags|GroupOrderSet); }
 
   private:
        order_t _order;
index 4f955930522aa022ef0b147e1fd90c0ce0ad9c94..ba0d28218780e1aa7b269d2126623db4f0f7415a 100644 (file)
@@ -955,8 +955,6 @@ LuaBindings::common (lua_State* L)
                .addConst ("Selected", ARDOUR::PresentationInfo::Flag(PresentationInfo::Selected))
                .addConst ("Hidden", ARDOUR::PresentationInfo::Flag(PresentationInfo::Hidden))
                .addConst ("GroupOrderSet", ARDOUR::PresentationInfo::Flag(PresentationInfo::GroupOrderSet))
-               .addConst ("GroupMask", ARDOUR::PresentationInfo::Flag(PresentationInfo::GroupMask))
-               .addConst ("SpecialMask", ARDOUR::PresentationInfo::Flag(PresentationInfo::SpecialMask))
                .addConst ("StatusMask", ARDOUR::PresentationInfo::Flag(PresentationInfo::StatusMask))
                .endNamespace ()
                .endNamespace ()
index 7939b29c7c37825ef84ace19de123e4a1dc34d4e..111033bf2319006eda0a3d40b0fd115ddde569e0 100644 (file)
@@ -198,8 +198,8 @@ struct RouteRecEnabledComparator
        {
                boost::shared_ptr<Track> t1 (boost::dynamic_pointer_cast<Track>(r1));
                boost::shared_ptr<Track> t2 (boost::dynamic_pointer_cast<Track>(r2));
-               PresentationInfo::global_order_t r1o = r1->presentation_info().global_order();
-               PresentationInfo::global_order_t r2o = r2->presentation_info().global_order();
+               PresentationInfo::order_t r1o = r1->presentation_info().order();
+               PresentationInfo::order_t r2o = r2->presentation_info().order();
 
                if (!t1) {
                        if (!t2) {
index 7833cad6496d7b7da7bc7e6cdd09ba79b2baed80..ed27def461ec9a89ae2b2604d94b243e441c7540 100644 (file)
@@ -2308,7 +2308,7 @@ Session::resort_routes_using (boost::shared_ptr<RouteList> r)
 #ifndef NDEBUG
                DEBUG_TRACE (DEBUG::Graph, "Routes resorted, order follows:\n");
                for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
-                       DEBUG_TRACE (DEBUG::Graph, string_compose ("\t%1 presentation order %2\n", (*i)->name(), (*i)->presentation_info().global_order()));
+                       DEBUG_TRACE (DEBUG::Graph, string_compose ("\t%1 presentation order %2\n", (*i)->name(), (*i)->presentation_info().order()));
                }
 #endif
 
@@ -2943,8 +2943,8 @@ Session::ensure_route_presentation_info_gap (PresentationInfo::order_t first_new
                        continue;
                }
 
-               if (rt->presentation_info().group_order () >= first_new_order) {
-                       rt->set_presentation_group_order (rt->presentation_info().group_order () + how_many);
+               if (rt->presentation_info().order () >= first_new_order) {
+                       rt->set_presentation_group_order (rt->presentation_info().order () + how_many);
                }
        }
 }
@@ -3440,7 +3440,7 @@ Session::add_routes_inner (RouteList& new_routes, bool input_auto_connect, bool
 
                        /* presentation info order may already have been set from XML */
 
-                       if (r->presentation_info().unordered()) {
+                       if (!r->presentation_info().order_set()) {
 
                                if (order == PresentationInfo::max_order) {
                                        /* just add to the end */
@@ -3451,14 +3451,13 @@ Session::add_routes_inner (RouteList& new_routes, bool input_auto_connect, bool
                                        DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("group order not set, set to %1 + %2 = %3\n", order, added, order + added));
                                }
                        } else {
-                               DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("group order already set to %1\n", r->presentation_info().group_order()));
+                               DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("group order already set to %1\n", r->presentation_info().order()));
                        }
                }
 
-               DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("added route %1, group order %2 global order %3 type %4 (summary: %5)\n",
+               DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("added route %1, group order %2 type %3 (summary: %4)\n",
                                                               r->name(),
-                                                              r->presentation_info().group_order(),
-                                                              r->presentation_info().global_order(),
+                                                              r->presentation_info().order(),
                                                               enum_2_string (r->presentation_info().flags()),
                                                               r->presentation_info().to_string()));
 
@@ -4272,11 +4271,11 @@ struct PresentationOrderSorter {
                if (a->presentation_info().special() && !b->presentation_info().special()) {
                        /* a is not ordered, b is; b comes before a */
                        return false;
-               } else if (b->presentation_info().unordered() && !a->presentation_info().unordered()) {
+               } else if (!b->presentation_info().order_set() && a->presentation_info().order_set()) {
                        /* b is not ordered, a is; a comes before b */
                        return true;
                } else {
-                       return a->presentation_info().global_order() < b->presentation_info().global_order();
+                       return a->presentation_info().order() < b->presentation_info().order();
                }
        }
 };
index c21d68c0a6cabbe61991bd869c11483d9676e399..4fe3fb4287b42fe7219a1a256d0b45b07220859a 100644 (file)
@@ -136,7 +136,7 @@ Stripable::set_state (XMLNode const& node, int version)
 
                if (!_presentation_info.special()) {
                        if ((prop = node.property (X_("order-key"))) != 0) {
-                               _presentation_info.set_group_order (atol (prop->value()));
+                               _presentation_info.set_order (atol (prop->value()));
                        }
                }
        }