Initial import of gtk2_ardour.
[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 <sigc++/signal_system.h>
25
26 #include "time_selection.h"
27 #include "region_selection.h"
28 #include "track_selection.h"
29 #include "automation_selection.h"
30 #include "playlist_selection.h"
31 #include "redirect_selection.h"
32 #include "point_selection.h"
33
34 class TimeAxisView;
35 class AudioRegionView;
36 class Selectable;
37
38 class Selection : public SigC::Object 
39 {
40   public:
41         enum SelectionType {
42                 Object = 0x1,
43                 Range = 0x2
44         };
45
46         TrackSelection       tracks;
47         AudioRegionSelection audio_regions;
48         TimeSelection        time;
49         AutomationSelection  lines;
50         PlaylistSelection    playlists;
51         RedirectSelection    redirects;
52         PointSelection       points;
53
54         Selection() {
55                 next_time_id = 0;
56                 clear();
57         }
58
59         Selection& operator= (const Selection& other);
60
61         SigC::Signal0<void> RegionsChanged;
62         SigC::Signal0<void> TracksChanged;
63         SigC::Signal0<void> TimeChanged;
64         SigC::Signal0<void> LinesChanged;
65         SigC::Signal0<void> PlaylistsChanged;
66         SigC::Signal0<void> RedirectsChanged;
67         SigC::Signal0<void> PointsChanged;
68
69         void clear ();
70         bool empty();
71
72         void dump_region_layers();
73
74         bool selected (TimeAxisView*);
75         bool selected (AudioRegionView*);
76
77         void set (list<Selectable*>&);
78         void add (list<Selectable*>&);
79         
80         void set (TimeAxisView*);
81         void set (const list<TimeAxisView*>&);
82         void set (AudioRegionView*);
83         void set (std::vector<AudioRegionView*>&);
84         long set (TimeAxisView*, jack_nframes_t, jack_nframes_t);
85         void set (ARDOUR::AutomationList*);
86         void set (ARDOUR::Playlist*);
87         void set (const list<ARDOUR::Playlist*>&);
88         void set (ARDOUR::Redirect*);
89         void set (AutomationSelectable*);
90
91         void add (TimeAxisView*);
92         void add (const list<TimeAxisView*>&);
93         void add (AudioRegionView*);
94         void add (std::vector<AudioRegionView*>&);
95         long add (jack_nframes_t, jack_nframes_t);
96         void add (ARDOUR::AutomationList*);
97         void add (ARDOUR::Playlist*);
98         void add (const list<ARDOUR::Playlist*>&);
99         void add (ARDOUR::Redirect*);
100
101         void remove (TimeAxisView*);
102         void remove (const list<TimeAxisView*>&);
103         void remove (AudioRegionView*);
104         void remove (uint32_t selection_id);
105         void remove (jack_nframes_t, jack_nframes_t);
106         void remove (ARDOUR::AutomationList*);
107         void remove (ARDOUR::Playlist*);
108         void remove (const list<ARDOUR::Playlist*>&);
109         void remove (ARDOUR::Redirect*);
110
111         void replace (uint32_t time_index, jack_nframes_t start, jack_nframes_t end);
112         
113         void clear_audio_regions();
114         void clear_tracks ();
115         void clear_time();
116         void clear_lines ();
117         void clear_playlists ();
118         void clear_redirects ();
119         void clear_points ();
120
121         void foreach_audio_region (void (ARDOUR::AudioRegion::*method)(void));
122         void foreach_audio_region (void (ARDOUR::Region::*method)(void));
123         template<class A> void foreach_audio_region (void (ARDOUR::AudioRegion::*method)(A), A arg);
124         template<class A> void foreach_audio_region (void (ARDOUR::Region::*method)(A), A arg);
125
126   private:
127         uint32_t next_time_id;
128
129         void add (vector<AutomationSelectable*>&);
130 };
131
132 bool operator==(const Selection& a, const Selection& b);
133
134 #endif /* __ardour_gtk_selection_h__ */