Merged with trunk R1141
[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     $Id$
19 */
20
21 #ifndef __ardour_gtk_selection_h__
22 #define __ardour_gtk_selection_h__
23
24 #include <vector>
25 #include <boost/shared_ptr.hpp>
26
27 #include <sigc++/signal.h>
28
29 #include "time_selection.h"
30 #include "region_selection.h"
31 #include "track_selection.h"
32 #include "automation_selection.h"
33 #include "playlist_selection.h"
34 #include "redirect_selection.h"
35 #include "point_selection.h"
36
37 class TimeAxisView;
38 class RegionView;
39 class Selectable;
40
41 namespace ARDOUR {
42         class Region;
43         class AudioRegion;
44         class Playlist;
45         class Redirect;
46         class AutomationList;
47 }
48
49 class Selection : public sigc::trackable 
50 {
51   public:
52         enum SelectionType {
53                 Object = 0x1,
54                 Range = 0x2
55         };
56
57         enum Operation {
58                 Set,
59                 Add,
60                 Toggle,
61                 Extend
62         };
63
64         TrackSelection       tracks;
65         RegionSelection      regions;
66         TimeSelection        time;
67         AutomationSelection  lines;
68         PlaylistSelection    playlists;
69         RedirectSelection    redirects;
70         PointSelection       points;
71
72         Selection() {
73                 next_time_id = 0;
74                 clear();
75         }
76
77         Selection& operator= (const Selection& other);
78
79         sigc::signal<void> RegionsChanged;
80         sigc::signal<void> TracksChanged;
81         sigc::signal<void> TimeChanged;
82         sigc::signal<void> LinesChanged;
83         sigc::signal<void> PlaylistsChanged;
84         sigc::signal<void> RedirectsChanged;
85         sigc::signal<void> PointsChanged;
86
87         void clear ();
88         bool empty();
89
90         void dump_region_layers();
91
92         bool selected (TimeAxisView*);
93         bool selected (RegionView*);
94
95         void set (list<Selectable*>&);
96         void add (list<Selectable*>&);
97         
98         void set (TimeAxisView*);
99         void set (const 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 (ARDOUR::Playlist*);
105         void set (const list<ARDOUR::Playlist*>&);
106         void set (boost::shared_ptr<ARDOUR::Redirect>);
107         void set (AutomationSelectable*);
108
109         void toggle (TimeAxisView*);
110         void toggle (const 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 (ARDOUR::Playlist*);
116         void toggle (const list<ARDOUR::Playlist*>&);
117         void toggle (boost::shared_ptr<ARDOUR::Redirect>);
118
119         void add (TimeAxisView*);
120         void add (const list<TimeAxisView*>&);
121         void add (RegionView*);
122         void add (std::vector<RegionView*>&);
123         long add (nframes_t, nframes_t);
124         void add (ARDOUR::AutomationList*);
125         void add (ARDOUR::Playlist*);
126         void add (const list<ARDOUR::Playlist*>&);
127         void add (boost::shared_ptr<ARDOUR::Redirect>);
128         
129         void remove (TimeAxisView*);
130         void remove (const list<TimeAxisView*>&);
131         void remove (RegionView*);
132         void remove (uint32_t selection_id);
133         void remove (nframes_t, nframes_t);
134         void remove (ARDOUR::AutomationList*);
135         void remove (ARDOUR::Playlist*);
136         void remove (const list<ARDOUR::Playlist*>&);
137         void remove (boost::shared_ptr<ARDOUR::Redirect>);
138
139         void replace (uint32_t time_index, nframes_t start, nframes_t end);
140         
141         void clear_regions();
142         void clear_tracks ();
143         void clear_time();
144         void clear_lines ();
145         void clear_playlists ();
146         void clear_redirects ();
147         void clear_points ();
148
149         void foreach_region (void (ARDOUR::Region::*method)(void));
150         template<class A> void foreach_region (void (ARDOUR::Region::*method)(A), A arg);
151
152   private:
153         uint32_t next_time_id;
154
155         void add (std::vector<AutomationSelectable*>&);
156 };
157
158 bool operator==(const Selection& a, const Selection& b);
159
160 #endif /* __ardour_gtk_selection_h__ */