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