clear_history -> clear_changes and some comments.
[ardour.git] / libs / ardour / ardour / playlist.h
index bc896f35a4cb4b39fd6787fb59b07dee060d57a1..43cb80418a50bfd2201777602b2bd140a285f76f 100644 (file)
@@ -35,7 +35,6 @@
 
 #include "pbd/undo.h"
 #include "pbd/stateful.h"
-#include "pbd/stateful_owner.h"
 #include "pbd/statefuldestructible.h"
 #include "pbd/sequence_property.h"
 
@@ -44,7 +43,6 @@
 #include "ardour/ardour.h"
 #include "ardour/session_object.h"
 #include "ardour/crossfade_compare.h"
-#include "ardour/location.h"
 #include "ardour/data_type.h"
 
 namespace ARDOUR  {
@@ -60,34 +58,27 @@ namespace Properties {
         extern PBD::PropertyDescriptor<bool> regions;
 }
 
-class RegionListProperty : public PBD::SequenceProperty<std::list<boost::shared_ptr<Region > > >
+class RegionListProperty : public PBD::SequenceProperty<std::list<boost::shared_ptr<Region> > >
 {
   public:
         RegionListProperty (Playlist&);
 
+       RegionListProperty* clone () const;
+
         boost::shared_ptr<Region> lookup_id (const PBD::ID& id);
-        void diff (PBD::PropertyList& before, PBD::PropertyList& after) const;
 
   private:
-        friend class Playlist;
-        std::list<boost::shared_ptr<Region> > rlist() { return _val; }
+       RegionListProperty* create () const;
 
+        friend class Playlist;
         /* 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;
+class Playlist : public SessionObject , 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);
@@ -97,13 +88,10 @@ class Playlist : public SessionObject
 
        virtual ~Playlist ();
 
-        bool set_property (const PBD::PropertyBase&);
         void update (const RegionListProperty::ChangeRecord&);
-        void clear_owned_history ();
+        void clear_owned_changes ();
         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 ();
@@ -116,6 +104,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; }
 
@@ -125,7 +114,7 @@ class Playlist : public SessionObject
        bool hidden() const { return _hidden; }
        bool empty() const;
        uint32_t n_regions() const;
-       framecnt_t get_maximum_extent () const;
+       std::pair<framecnt_t, framecnt_t> get_extent () const;
        layer_t top_layer() const;
 
        EditMode get_edit_mode() const { return _edit_mode; }
@@ -135,6 +124,7 @@ class Playlist : public SessionObject
 
        void add_region (boost::shared_ptr<Region>, framepos_t position, float times = 1, bool auto_partition = false);
        void remove_region (boost::shared_ptr<Region>);
+       void remove_region_by_source (boost::shared_ptr<Source>);
        void get_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&);
        void get_region_list_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&);
        void replace_region (boost::shared_ptr<Region> old, boost::shared_ptr<Region> newr, framepos_t pos);
@@ -180,12 +170,14 @@ class Playlist : public SessionObject
        PBD::Signal0<void>      NameChanged;
        PBD::Signal0<void>      LengthChanged;
        PBD::Signal0<void>      LayeringChanged;
-       PBD::Signal1<void,std::list< Evoral::RangeMove<framepos_t> > const &> RangesMoved;
+
+       /** Emitted when regions have moved (not when regions have only been trimmed) */
+       PBD::Signal2<void,std::list< Evoral::RangeMove<framepos_t> > const &, bool> RangesMoved;
 
        static std::string bump_name (std::string old_name, Session&);
 
        void freeze ();
-       void thaw ();
+       void thaw (bool from_undo = false);
 
        void raise_region (boost::shared_ptr<Region>);
        void lower_region (boost::shared_ptr<Region>);
@@ -194,6 +186,7 @@ class Playlist : public SessionObject
 
        uint32_t read_data_count() const { return _read_data_count; }
 
+       /* XXX: use of diskstream here is a little unfortunate */
        const PBD::ID& get_orig_diskstream_id () const { return _orig_diskstream_id; }
        void set_orig_diskstream_id (const PBD::ID& did) { _orig_diskstream_id = did; }
 
@@ -240,6 +233,7 @@ class Playlist : public SessionObject
        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;
@@ -249,10 +243,16 @@ class Playlist : public SessionObject
        bool             pending_contents_change;
        bool             pending_layering;
        bool             pending_length;
+
+       /** Movements of time ranges caused by region moves; note that
+        *  region trims are not included in this list; it is used to
+        *  do automation-follows-regions.
+        */
        std::list< Evoral::RangeMove<framepos_t> > pending_range_moves;
        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;
@@ -284,10 +284,12 @@ class Playlist : public SessionObject
        }
 
        void delay_notifications ();
-       void release_notifications ();
-       virtual void flush_notifications ();
+       void release_notifications (bool from_undo = false);
+       virtual void flush_notifications (bool from_undo = false);
        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 ();
@@ -328,7 +330,7 @@ class Playlist : public SessionObject
        void copy_regions (RegionList&) const;
        void partition_internal (framepos_t start, framepos_t end, bool cutting, RegionList& thawlist);
 
-       framecnt_t _get_maximum_extent() const;
+       std::pair<framecnt_t, framecnt_t> _get_extent() const;
 
        boost::shared_ptr<Playlist> cut_copy (boost::shared_ptr<Playlist> (Playlist::*pmf)(framepos_t, framecnt_t, bool),
                                              std::list<AudioRange>& ranges, bool result_is_hidden);