first part of MIDI cut/copy/paste ; fix for input/output_streams of an IOProcessor...
[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 "processor_selection.h"
34 #include "point_selection.h"
35 #include "marker_selection.h"
36 #include "midi_selection.h"
37
38 class TimeAxisView;
39 class RegionView;
40 class Selectable;
41 class PublicEditor;
42 class MidiRegionView;
43
44 namespace ARDOUR {
45         class Region;
46         class AudioRegion;
47         class Playlist;
48         class Processor;
49         class AutomationList;
50 }
51
52 namespace Evoral {
53         class ControlList;
54 }
55
56 /// Lists of selected things
57
58 /** The Selection class holds lists of selected items (tracks, regions, etc. etc.). */
59
60 class Selection : public sigc::trackable 
61 {
62   public:
63         enum SelectionType {
64                 Object = 0x1,
65                 Range = 0x2
66         };
67
68         enum Operation {
69                 Set,
70                 Add,
71                 Toggle,
72                 Extend
73         };
74
75         TrackSelection       tracks;
76         RegionSelection      regions;
77         TimeSelection        time;
78         AutomationSelection  lines;
79         PlaylistSelection    playlists;
80         PointSelection       points;
81         MarkerSelection      markers;
82         MidiSelection        midi;
83
84         Selection (PublicEditor const * e) : editor (e), next_time_id (0) {
85                 clear();
86         }
87
88         Selection& operator= (const Selection& other);
89
90         sigc::signal<void> RegionsChanged;
91         sigc::signal<void> TracksChanged;
92         sigc::signal<void> TimeChanged;
93         sigc::signal<void> LinesChanged;
94         sigc::signal<void> PlaylistsChanged;
95         sigc::signal<void> PointsChanged;
96         sigc::signal<void> MarkersChanged;
97         sigc::signal<void> MidiChanged;
98
99         void clear ();
100         bool empty();
101
102         void dump_region_layers();
103
104         bool selected (TimeAxisView*);
105         bool selected (RegionView*);
106         bool selected (Marker*);
107
108         void set (std::list<Selectable*>&);
109         void add (std::list<Selectable*>&);
110         void toggle (std::list<Selectable*>&);
111         
112         void set (TimeAxisView*);
113         void set (const std::list<TimeAxisView*>&);
114         void set (RegionView*, bool also_clear_tracks = true);
115         void set (MidiRegionView*);
116         void set (std::vector<RegionView*>&);
117         long set (TimeAxisView*, nframes_t, nframes_t);
118         void set (boost::shared_ptr<Evoral::ControlList>);
119         void set (boost::shared_ptr<ARDOUR::Playlist>);
120         void set (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
121         void set (AutomationSelectable*);
122         void set (Marker*);
123         void set (const RegionSelection&);
124
125         void toggle (TimeAxisView*);
126         void toggle (const std::list<TimeAxisView*>&);
127         void toggle (RegionView*);
128         void toggle (MidiRegionView*);
129         void toggle (std::vector<RegionView*>&);
130         long toggle (nframes_t, nframes_t);
131         void toggle (ARDOUR::AutomationList*);
132         void toggle (boost::shared_ptr<ARDOUR::Playlist>);
133         void toggle (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
134         void toggle (const std::vector<AutomationSelectable*>&);
135         void toggle (Marker*);
136
137         void add (TimeAxisView*);
138         void add (const std::list<TimeAxisView*>&);
139         void add (RegionView*);
140         void add (MidiRegionView*);
141         void add (std::vector<RegionView*>&);
142         long add (nframes_t, nframes_t);
143         void add (boost::shared_ptr<Evoral::ControlList>);
144         void add (boost::shared_ptr<ARDOUR::Playlist>);
145         void add (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
146         void add (Marker*);
147         void add (const std::list<Marker*>&);
148         void add (const RegionSelection&);
149         void remove (TimeAxisView*);
150         void remove (const std::list<TimeAxisView*>&);
151         void remove (RegionView*);
152         void remove (MidiRegionView*);
153         void remove (uint32_t selection_id);
154         void remove (nframes_t, nframes_t);
155         void remove (boost::shared_ptr<ARDOUR::AutomationList>);
156         void remove (boost::shared_ptr<ARDOUR::Playlist>);
157         void remove (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
158         void remove (const std::list<Selectable*>&);
159         void remove (Marker*);
160
161         void replace (uint32_t time_index, nframes_t start, nframes_t end);
162         
163         void clear_regions();
164         void clear_tracks ();
165         void clear_time();
166         void clear_lines ();
167         void clear_playlists ();
168         void clear_points ();
169         void clear_markers ();
170         void clear_midi ();
171
172         void foreach_region (void (ARDOUR::Region::*method)(void));
173         void foreach_regionview (void (RegionView::*method)(void));
174         template<class A> void foreach_region (void (ARDOUR::Region::*method)(A), A arg);
175
176   private:
177         PublicEditor const * editor;
178         uint32_t next_time_id;
179
180         void add (std::vector<AutomationSelectable*>&);
181 };
182
183 bool operator==(const Selection& a, const Selection& b);
184
185 #endif /* __ardour_gtk_selection_h__ */