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