When a region movement is undone, prevent the resulting movement from triggering...
[ardour.git] / libs / ardour / ardour / audioplaylist.h
1 /*
2     Copyright (C) 2003 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 #ifndef __ardour_audio_playlist_h__
21 #define __ardour_audio_playlist_h__
22
23 #include <vector>
24 #include <list>
25
26 #include "ardour/ardour.h"
27 #include "ardour/playlist.h"
28
29 namespace ARDOUR  {
30
31 class Session;
32 class Region;
33 class AudioRegion;
34 class Source;
35
36 class AudioPlaylist : public ARDOUR::Playlist
37 {
38   public:
39         typedef std::list<boost::shared_ptr<Crossfade> > Crossfades;
40
41    public:
42         AudioPlaylist (Session&, const XMLNode&, bool hidden = false);
43         AudioPlaylist (Session&, std::string name, bool hidden = false);
44         AudioPlaylist (boost::shared_ptr<const AudioPlaylist>, std::string name, bool hidden = false);
45         AudioPlaylist (boost::shared_ptr<const AudioPlaylist>, nframes_t start, nframes_t cnt, std::string name, bool hidden = false);
46
47         ~AudioPlaylist ();
48
49         void clear (bool with_signals=true);
50
51         nframes_t read (Sample *dst, Sample *mixdown, float *gain_buffer, nframes_t start, nframes_t cnt, uint32_t chan_n=0);
52
53         int set_state (const XMLNode&, int version);
54
55         PBD::Signal1<void,boost::shared_ptr<Crossfade> >  NewCrossfade;
56         
57         void foreach_crossfade (boost::function<void (boost::shared_ptr<Crossfade>)>);
58         void crossfades_at (nframes_t frame, Crossfades&);
59
60         bool destroy_region (boost::shared_ptr<Region>);
61
62     protected:
63
64         /* playlist "callbacks" */
65         void notify_crossfade_added (boost::shared_ptr<Crossfade>);
66         void flush_notifications (bool);
67
68         void finalize_split_region (boost::shared_ptr<Region> orig, boost::shared_ptr<Region> left, boost::shared_ptr<Region> right);
69
70         void refresh_dependents (boost::shared_ptr<Region> region);
71         void check_dependents (boost::shared_ptr<Region> region, bool norefresh);
72         void remove_dependents (boost::shared_ptr<Region> region);
73
74     private:
75        Crossfades      _crossfades;
76        Crossfades      _pending_xfade_adds;
77
78        void crossfade_invalidated (boost::shared_ptr<Region>);
79        XMLNode& state (bool full_state);
80        void dump () const;
81
82        bool region_changed (const PBD::PropertyChange&, boost::shared_ptr<Region>);
83        void crossfade_changed (const PBD::PropertyChange&);
84        void add_crossfade (boost::shared_ptr<Crossfade>);
85
86        void source_offset_changed (boost::shared_ptr<AudioRegion> region);
87 };
88
89 } /* namespace ARDOUR */
90
91 #endif  /* __ardour_audio_playlist_h__ */
92
93