Prefer const references: Beat-Converter does not modify the TempoMap
[ardour.git] / libs / ardour / ardour / presentation_info.h
index 0de0a3d8bc91e5bf63bd7f44a99b3bc5c598f0d6..7c847e9fce8e9b7c263c739670d5909e0072b9d3 100644 (file)
@@ -125,12 +125,16 @@ class LIBARDOUR_API PresentationInfo : public PBD::Stateful
                OrderSet = 0x400,
 
                /* special mask to delect out "state" bits */
-               StatusMask = (Selected|Hidden)
+               StatusMask = (Selected|Hidden),
+               /* special mask to delect select type bits */
+               TypeMask = (AudioBus|AudioTrack|MidiTrack|MidiBus|VCA|MasterOut|MonitorOut|Auditioner)
        };
 
-       static const Flag Route;
-       static const Flag Track;
-       static const Flag Bus;
+       static const Flag AllStripables; /* mask to use for any route or VCA (but not auditioner) */
+       static const Flag AllRoutes; /* mask to use for any route include master+monitor, but not auditioner */
+       static const Flag Route;     /* mask for any route (bus or track */
+       static const Flag Track;     /* mask to use for any track */
+       static const Flag Bus;       /* mask to use for any bus */
 
        typedef uint32_t order_t;
        typedef uint32_t color_t;
@@ -141,33 +145,25 @@ class LIBARDOUR_API PresentationInfo : public PBD::Stateful
 
        static const order_t max_order;
 
+       PresentationInfo::Flag flags() const { return _flags; }
        order_t  order() const { return _order; }
        color_t  color() const { return _color; }
 
+       bool color_set() const;
+
        void set_color (color_t);
        void set_selected (bool yn);
        void set_hidden (bool yn);
-
-       PresentationInfo::Flag flags() const { return _flags; }
+       void set_flags (Flag f) { _flags = f; }
 
        bool order_set() const { return _flags & OrderSet; }
 
+       int selection_cnt() const { return _selection_cnt; }
+
        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);
-       }
-
-       void unset_flag (PresentationInfo::Flag f) {
-               _flags = PresentationInfo::Flag (_flags & ~f);
-       }
-
-       void set_flags (Flag f) {
-               _flags = f;
-       }
-
        bool flag_match (Flag f) const {
                /* no flags, match all */
 
@@ -193,24 +189,38 @@ class LIBARDOUR_API PresentationInfo : public PBD::Stateful
                        return true;
                }
                if (f == Route && (_flags & Route)) {
-                       /* any kind of route */
+                       /* any kind of route, but not master, monitor in
+                          or auditioner.
+                        */
                        return true;
                }
 
-               return f == _flags;
-       }
+               if (f == AllRoutes && (_flags & AllRoutes)) {
+                       /* any kind of route, but not auditioner. Ask for that
+                          specifically.
+                       */
+                       return true;
+               }
 
-       int set_state (XMLNode const&, int);
-       XMLNode& get_state ();
+               if (f == AllStripables && (_flags & AllStripables)) {
+                       /* any kind of stripable, but not auditioner. Ask for that
+                          specifically.
+                       */
+                       return true;
+               }
 
-       bool operator< (PresentationInfo const& other) const {
-               return order() < other.order();
-       }
+               /* check for any matching type bits.
+                *
+                * Do comparisoon without status mask or order set bits - we
+                * already checked that above.
+                */
 
-       bool match (PresentationInfo const& other) const {
-               return (_order == other.order()) && flag_match (other.flags());
+               return ((f & TypeMask) & _flags);
        }
 
+       int set_state (XMLNode const&, int);
+       XMLNode& get_state ();
+
        bool operator==(PresentationInfo const& other) {
                return (_order == other.order()) && (_flags == other.flags());
        }
@@ -224,15 +234,29 @@ class LIBARDOUR_API PresentationInfo : public PBD::Stateful
        static Flag get_flags (XMLNode const& node);
        static std::string state_node_name;
 
-       /* for things concerned about *any* PresentationInfo. This is emitted
-        * only at the request of another object that has finished making some
-        * changes (e.g. reordering things)
+       /* for things concerned about *any* PresentationInfo.
         */
 
-       static PBD::Signal0<void> Change;
+       static PBD::Signal1<void,PBD::PropertyChange const &> Change;
 
        static void make_property_quarks ();
 
+  protected:
+       friend class ChangeSuspender;
+       static void suspend_change_signal ();
+       static void unsuspend_change_signal ();
+
+  public:
+       class ChangeSuspender {
+          public:
+               ChangeSuspender() {
+                       PresentationInfo::suspend_change_signal ();
+               }
+               ~ChangeSuspender() {
+                       PresentationInfo::unsuspend_change_signal ();
+               }
+       };
+
   protected:
        friend class Stripable;
        void set_order (order_t order);
@@ -241,6 +265,14 @@ class LIBARDOUR_API PresentationInfo : public PBD::Stateful
        order_t _order;
        Flag    _flags;
        color_t _color;
+       int     _selection_cnt;
+
+       static PBD::PropertyChange _pending_static_changes;
+       static Glib::Threads::Mutex static_signal_lock;
+       static int _change_signal_suspended;
+       static void send_static_change (const PBD::PropertyChange&);
+
+       static int selection_counter;
 };
 
 }