No-op: rename a few variables and add/fix some comments.
[ardour.git] / libs / ardour / ardour / playlist.h
index 9cd02dec1e338808892ecf78480ed3bb9d5d32b5..d9a14c01fd750c9bbe4a1e523b51bf33030a4d4a 100644 (file)
@@ -35,7 +35,9 @@
 
 #include "pbd/undo.h"
 #include "pbd/stateful.h"
+#include "pbd/stateful_owner.h"
 #include "pbd/statefuldestructible.h"
+#include "pbd/sequence_property.h"
 
 #include "evoral/types.hpp"
 
@@ -49,11 +51,44 @@ namespace ARDOUR  {
 
 class Session;
 class Region;
+class Playlist;
+
+namespace Properties {
+        /* fake the type, since regions are handled by SequenceProperty which doesn't
+           care about such things.
+        */
+        extern PBD::PropertyDescriptor<bool> regions;
+}
+
+class RegionListProperty : public PBD::SequenceProperty<std::list<boost::shared_ptr<Region > > >
+{
+  public:
+        RegionListProperty (Playlist&);
+
+        boost::shared_ptr<Region> lookup_id (const PBD::ID& id);
+        void diff (PBD::PropertyList& undo, PBD::PropertyList& redo) const;
+
+  private:
+        friend class Playlist;
+        std::list<boost::shared_ptr<Region> > rlist() { return _val; }
+
+        /* we live and die with our playlist, no lifetime management needed */
+        Playlist& _playlist;
+
+        /* create a copy of this RegionListProperty that only
+           has what is needed for use in a history list command. This
+           means that it won't contain the actual region list but
+           will have the added/removed list.
+        */
+        RegionListProperty* copy_for_history () const;
+};
 
 class Playlist : public SessionObject
+               , public PBD::StatefulOwner
               , public boost::enable_shared_from_this<Playlist> {
   public:
        typedef std::list<boost::shared_ptr<Region> >    RegionList;
+        static void make_property_quarks ();
 
        Playlist (Session&, const XMLNode&, DataType type, bool hidden = false);
        Playlist (Session&, std::string name, DataType type, bool hidden = false);
@@ -62,6 +97,15 @@ class Playlist : public SessionObject
 
        virtual ~Playlist ();
 
+        bool set_property (const PBD::PropertyBase&);
+        void update (const RegionListProperty::ChangeRecord&);
+        void clear_owned_history ();
+        void rdiff (std::vector<PBD::StatefulDiffCommand*>&) const;
+
+        PBD::PropertyList* property_factory (const XMLNode&) const;
+
+       boost::shared_ptr<Region> region_by_id (const PBD::ID&);
+
        void set_region_ownership ();
 
        virtual void clear (bool with_signals=true);
@@ -72,6 +116,7 @@ class Playlist : public SessionObject
        bool used () const { return _refcnt != 0; }
 
        bool set_name (const std::string& str);
+        int sort_id() { return _sort_id; }
 
        const DataType& data_type() const { return _type; }
 
@@ -107,7 +152,7 @@ class Playlist : public SessionObject
        boost::shared_ptr<Playlist> copy (std::list<AudioRange>&, bool result_is_hidden = true);
        int                         paste (boost::shared_ptr<Playlist>, framepos_t position, float times);
 
-       const RegionList& region_list () const { return regions; }
+       const RegionListProperty& region_list () const { return regions; }
 
        RegionList*                regions_at (framepos_t frame);
        RegionList*                regions_touched (framepos_t start, framepos_t end);
@@ -192,10 +237,11 @@ class Playlist : public SessionObject
 
        friend class RegionLock;
 
-       RegionList       regions;  /* the current list of regions in the playlist */
+        RegionListProperty   regions;  /* the current list of regions in the playlist */
        std::set<boost::shared_ptr<Region> > all_regions; /* all regions ever added to this playlist */
        PBD::ScopedConnectionList region_state_changed_connections;
        DataType        _type;
+        int             _sort_id;
        mutable gint    block_notifications;
        mutable gint    ignore_state_changes;
        mutable Glib::RecMutex region_lock;
@@ -209,6 +255,7 @@ class Playlist : public SessionObject
        bool             save_on_thaw;
        std::string      last_save_reason;
        uint32_t         in_set_state;
+       bool             in_update;
        bool             first_set_state;
        bool            _hidden;
        bool            _splicing;
@@ -244,20 +291,22 @@ class Playlist : public SessionObject
        virtual void flush_notifications ();
        void clear_pending ();
 
+        void _set_sort_id ();
+
        void notify_region_removed (boost::shared_ptr<Region>);
        void notify_region_added (boost::shared_ptr<Region>);
        void notify_length_changed ();
        void notify_layering_changed ();
        void notify_contents_changed ();
-       void notify_state_changed (PBD::PropertyChange);
+       void notify_state_changed (const PBD::PropertyChange&);
        void notify_region_moved (boost::shared_ptr<Region>);
 
        void mark_session_dirty();
 
-       void region_changed_proxy (PBD::PropertyChange, boost::weak_ptr<Region>);
-       virtual bool region_changed (PBD::PropertyChange, boost::shared_ptr<Region>);
+       void region_changed_proxy (const PBD::PropertyChange&, boost::weak_ptr<Region>);
+       virtual bool region_changed (const PBD::PropertyChange&, boost::shared_ptr<Region>);
 
-       void region_bounds_changed (PBD::PropertyChange, boost::shared_ptr<Region>);
+       void region_bounds_changed (const PBD::PropertyChange&, boost::shared_ptr<Region>);
        void region_deleted (boost::shared_ptr<Region>);
 
        void sort_regions ();
@@ -277,8 +326,6 @@ class Playlist : public SessionObject
 
        virtual XMLNode& state (bool);
 
-       boost::shared_ptr<Region> region_by_id (PBD::ID);
-
        bool add_region_internal (boost::shared_ptr<Region>, framepos_t position);
 
        int remove_region_internal (boost::shared_ptr<Region>);
@@ -296,6 +343,8 @@ class Playlist : public SessionObject
        int move_region_to_layer (layer_t, boost::shared_ptr<Region> r, int dir);
        void relayer ();
 
+       void begin_undo ();
+       void end_undo ();
        void unset_freeze_parent (Playlist*);
        void unset_freeze_child (Playlist*);