Small comment.
[ardour.git] / gtk2_ardour / selection.h
1 /*
2     Copyright (C) 2000-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_gtk_selection_h__
21 #define __ardour_gtk_selection_h__
22
23 #include <vector>
24 #include <boost/shared_ptr.hpp>
25 #include <boost/noncopyable.hpp>
26
27 #include <sigc++/signal.h>
28
29 #include "pbd/signals.h"
30
31 #include "time_selection.h"
32 #include "region_selection.h"
33 #include "track_selection.h"
34 #include "automation_selection.h"
35 #include "playlist_selection.h"
36 #include "processor_selection.h"
37 #include "point_selection.h"
38 #include "marker_selection.h"
39 #include "midi_selection.h"
40
41 class TimeAxisView;
42 class RegionView;
43 class Selectable;
44 class PublicEditor;
45 class MidiRegionView;
46 class AutomationLine;
47 class ControlPoint;
48
49
50 namespace ARDOUR {
51         class Region;
52         class AudioRegion;
53         class Playlist;
54         class Processor;
55         class AutomationList;
56 }
57
58 namespace Evoral {
59         class ControlList;
60 }
61
62 /// Lists of selected things
63
64 /** The Selection class holds lists of selected items (tracks, regions, etc. etc.). */
65
66 class Selection : public sigc::trackable, public PBD::ScopedConnectionList
67 {
68   public:
69         enum SelectionType {
70                 Object = 0x1,
71                 Range = 0x2
72         };
73
74         enum Operation {
75                 Set,
76                 Add,
77                 Toggle,
78                 Extend
79         };
80
81         TrackSelection       tracks;
82         RegionSelection      regions;
83         TimeSelection        time;
84         AutomationSelection  lines;
85         PlaylistSelection    playlists;
86         PointSelection       points;
87         MarkerSelection      markers;
88         MidiRegionSelection  midi_regions;
89
90         /** only used when this class is used as a cut buffer */
91         MidiNoteSelection    midi_notes;
92
93         Selection (PublicEditor const * e);
94
95         // Selection& operator= (const Selection& other);
96
97         sigc::signal<void> RegionsChanged;
98         sigc::signal<void> TracksChanged;
99         sigc::signal<void> TimeChanged;
100         sigc::signal<void> LinesChanged;
101         sigc::signal<void> PlaylistsChanged;
102         sigc::signal<void> PointsChanged;
103         sigc::signal<void> MarkersChanged;
104         sigc::signal<void> MidiNotesChanged;
105         sigc::signal<void> MidiRegionsChanged;
106
107         void clear ();
108         bool empty (bool internal_selection = false);
109
110         void dump_region_layers();
111
112         bool selected (TimeAxisView*);
113         bool selected (RegionView*);
114         bool selected (Marker*);
115
116         void set (std::list<Selectable*> const &);
117         void add (std::list<Selectable*> const &);
118         void toggle (std::list<Selectable*> const &);
119
120         void set (TimeAxisView*);
121         void set (const TrackViewList&);
122         void set (const MidiNoteSelection&);
123         void set (RegionView*, bool also_clear_tracks = true);
124         void set (MidiRegionView*);
125         void set (std::vector<RegionView*>&);
126         long set (framepos_t, framepos_t);
127         void set_preserving_all_ranges (framepos_t, framepos_t);
128         void set (boost::shared_ptr<Evoral::ControlList>);
129         void set (boost::shared_ptr<ARDOUR::Playlist>);
130         void set (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
131         void set (ControlPoint *);
132         void set (Marker*);
133         void set (const RegionSelection&);
134
135         void toggle (TimeAxisView*);
136         void toggle (const TrackViewList&);
137         void toggle (const MidiNoteSelection&);
138         void toggle (RegionView*);
139         void toggle (MidiRegionView*);
140         void toggle (MidiCutBuffer*);
141         void toggle (std::vector<RegionView*>&);
142         long toggle (framepos_t, framepos_t);
143         void toggle (ARDOUR::AutomationList*);
144         void toggle (boost::shared_ptr<ARDOUR::Playlist>);
145         void toggle (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
146         void toggle (ControlPoint *);
147         void toggle (std::vector<ControlPoint*> const &);
148         void toggle (Marker*);
149
150         void add (TimeAxisView*);
151         void add (const TrackViewList&);
152         void add (const MidiNoteSelection&);
153         void add (RegionView*);
154         void add (MidiRegionView*);
155         void add (MidiCutBuffer*);
156         void add (std::vector<RegionView*>&);
157         long add (framepos_t, framepos_t);
158         void add (boost::shared_ptr<Evoral::ControlList>);
159         void add (boost::shared_ptr<ARDOUR::Playlist>);
160         void add (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
161         void add (ControlPoint *);
162         void add (std::vector<ControlPoint*> const &);
163         void add (Marker*);
164         void add (const std::list<Marker*>&);
165         void add (const RegionSelection&);
166         void remove (TimeAxisView*);
167         void remove (const TrackViewList&);
168         void remove (const MidiNoteSelection&);
169         void remove (RegionView*);
170         void remove (MidiRegionView*);
171         void remove (MidiCutBuffer*);
172         void remove (uint32_t selection_id);
173         void remove (framepos_t, framepos_t);
174         void remove (boost::shared_ptr<ARDOUR::AutomationList>);
175         void remove (boost::shared_ptr<ARDOUR::Playlist>);
176         void remove (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
177         void remove (const std::list<Selectable*>&);
178         void remove (Marker*);
179
180         void remove_regions (TimeAxisView *);
181
182         void replace (uint32_t time_index, framepos_t start, framepos_t end);
183
184         void clear_regions();
185         void clear_tracks ();
186         void clear_time();
187         void clear_lines ();
188         void clear_playlists ();
189         void clear_points ();
190         void clear_markers ();
191         void clear_midi_notes ();
192         void clear_midi_regions ();
193
194         void foreach_region (void (ARDOUR::Region::*method)(void));
195         void foreach_regionview (void (RegionView::*method)(void));
196         void foreach_midi_regionview (void (MidiRegionView::*method)(void));
197         template<class A> void foreach_region (void (ARDOUR::Region::*method)(A), A arg);
198
199         XMLNode& get_state () const;
200         int set_state (XMLNode const &, int);
201
202   private:
203         void set_point_selection_from_line (AutomationLine const &);
204
205         PublicEditor const * editor;
206         uint32_t next_time_id;
207 };
208
209 bool operator==(const Selection& a, const Selection& b);
210
211 #endif /* __ardour_gtk_selection_h__ */