added RCU handling of Session route list, and major use of shared_ptr<T> everywhere...
[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 AudioRegionView;
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                 Toggle,
60                 Extend
61         };
62
63         TrackSelection       tracks;
64         AudioRegionSelection audio_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 (AudioRegionView*);
93
94         void set (list<Selectable*>&);
95         void add (list<Selectable*>&);
96         
97         void set (TimeAxisView*);
98         void set (const list<TimeAxisView*>&);
99         void set (AudioRegionView*);
100         void set (std::vector<AudioRegionView*>&);
101         long set (TimeAxisView*, jack_nframes_t, jack_nframes_t);
102         void set (ARDOUR::AutomationList*);
103         void set (ARDOUR::Playlist*);
104         void set (const list<ARDOUR::Playlist*>&);
105         void set (boost::shared_ptr<ARDOUR::Redirect>);
106         void set (AutomationSelectable*);
107
108         void toggle (TimeAxisView*);
109         void toggle (const list<TimeAxisView*>&);
110         void toggle (AudioRegionView*);
111         void toggle (std::vector<AudioRegionView*>&);
112         long toggle (jack_nframes_t, jack_nframes_t);
113         void toggle (ARDOUR::AutomationList*);
114         void toggle (ARDOUR::Playlist*);
115         void toggle (const list<ARDOUR::Playlist*>&);
116         void toggle (boost::shared_ptr<ARDOUR::Redirect>);
117
118         void add (TimeAxisView*);
119         void add (const list<TimeAxisView*>&);
120         void add (AudioRegionView*);
121         void add (std::vector<AudioRegionView*>&);
122         long add (jack_nframes_t, jack_nframes_t);
123         void add (ARDOUR::AutomationList*);
124         void add (ARDOUR::Playlist*);
125         void add (const list<ARDOUR::Playlist*>&);
126         void add (boost::shared_ptr<ARDOUR::Redirect>);
127         
128         void remove (TimeAxisView*);
129         void remove (const list<TimeAxisView*>&);
130         void remove (AudioRegionView*);
131         void remove (uint32_t selection_id);
132         void remove (jack_nframes_t, jack_nframes_t);
133         void remove (ARDOUR::AutomationList*);
134         void remove (ARDOUR::Playlist*);
135         void remove (const list<ARDOUR::Playlist*>&);
136         void remove (boost::shared_ptr<ARDOUR::Redirect>);
137
138         void replace (uint32_t time_index, jack_nframes_t start, jack_nframes_t end);
139         
140         void clear_audio_regions();
141         void clear_tracks ();
142         void clear_time();
143         void clear_lines ();
144         void clear_playlists ();
145         void clear_redirects ();
146         void clear_points ();
147
148         void foreach_audio_region (void (ARDOUR::AudioRegion::*method)(void));
149         void foreach_audio_region (void (ARDOUR::Region::*method)(void));
150         template<class A> void foreach_audio_region (void (ARDOUR::AudioRegion::*method)(A), A arg);
151         template<class A> void foreach_audio_region (void (ARDOUR::Region::*method)(A), A arg);
152
153   private:
154         uint32_t next_time_id;
155
156         void add (std::vector<AutomationSelectable*>&);
157 };
158
159 bool operator==(const Selection& a, const Selection& b);
160
161 #endif /* __ardour_gtk_selection_h__ */