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