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