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