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