2 Copyright (C) 2000-2003 Paul Davis
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.
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.
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.
20 #ifndef __ardour_gtk_selection_h__
21 #define __ardour_gtk_selection_h__
24 #include <boost/shared_ptr.hpp>
25 #include <boost/noncopyable.hpp>
27 #include <sigc++/signal.h>
29 #include "pbd/signals.h"
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"
62 /// Lists of selected things
64 /** The Selection class holds lists of selected items (tracks, regions, etc. etc.). */
66 class Selection : public sigc::trackable, public PBD::ScopedConnectionList
81 TrackSelection tracks;
82 RegionSelection regions;
84 AutomationSelection lines;
85 PlaylistSelection playlists;
86 PointSelection points;
87 MarkerSelection markers;
88 MidiRegionSelection midi_regions;
90 /** only used when this class is used as a cut buffer */
91 MidiNoteSelection midi_notes;
93 Selection (PublicEditor const * e, bool manage_libardour_selection);
95 // Selection& operator= (const Selection& other);
97 sigc::signal<void> RegionsChanged;
98 sigc::signal<void> TimeChanged;
99 sigc::signal<void> LinesChanged;
100 sigc::signal<void> PlaylistsChanged;
101 sigc::signal<void> PointsChanged;
102 sigc::signal<void> MarkersChanged;
103 sigc::signal<void> MidiNotesChanged;
104 sigc::signal<void> MidiRegionsChanged;
108 /** check if all selections are empty
109 * @param internal_selection also check object internals (e.g midi notes, automation points), when false only check objects.
110 * @return true if nothing is selected.
112 bool empty (bool internal_selection = false);
114 void dump_region_layers();
116 bool selected (TimeAxisView*) const;
117 bool selected (RegionView*) const;
118 bool selected (ArdourMarker*) const;
119 bool selected (ControlPoint*) const;
121 void set (std::list<Selectable*> const &);
122 void add (std::list<Selectable*> const &);
123 void toggle (std::list<Selectable*> const &);
125 void set (TimeAxisView*);
126 void set (const TrackViewList&);
127 void set (const MidiNoteSelection&);
128 void set (RegionView*, bool also_clear_tracks = true);
129 void set (MidiRegionView*);
130 void set (std::vector<RegionView*>&);
131 long set (samplepos_t, samplepos_t);
132 void set_preserving_all_ranges (samplepos_t, samplepos_t);
133 void set (boost::shared_ptr<Evoral::ControlList>);
134 void set (boost::shared_ptr<ARDOUR::Playlist>);
135 void set (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
136 void set (ControlPoint *);
137 void set (ArdourMarker*);
138 void set (const RegionSelection&);
140 void toggle (TimeAxisView*);
141 void toggle (const TrackViewList&);
142 void toggle (const MidiNoteSelection&);
143 void toggle (RegionView*);
144 void toggle (MidiRegionView*);
145 void toggle (MidiCutBuffer*);
146 void toggle (std::vector<RegionView*>&);
147 long toggle (samplepos_t, samplepos_t);
148 void toggle (ARDOUR::AutomationList*);
149 void toggle (boost::shared_ptr<ARDOUR::Playlist>);
150 void toggle (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
151 void toggle (ControlPoint *);
152 void toggle (std::vector<ControlPoint*> const &);
153 void toggle (ArdourMarker*);
155 void add (TimeAxisView*);
156 void add (const TrackViewList&);
157 void add (const MidiNoteSelection&);
158 void add (RegionView*);
159 void add (MidiRegionView*);
160 void add (MidiCutBuffer*);
161 void add (std::vector<RegionView*>&);
162 long add (samplepos_t, samplepos_t);
163 void add (boost::shared_ptr<Evoral::ControlList>);
164 void add (boost::shared_ptr<ARDOUR::Playlist>);
165 void add (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
166 void add (ControlPoint *);
167 void add (std::vector<ControlPoint*> const &);
168 void add (ArdourMarker*);
169 void add (const std::list<ArdourMarker*>&);
170 void add (const RegionSelection&);
171 void add (const PointSelection&);
172 void remove (TimeAxisView*);
173 void remove (const TrackViewList&);
174 void remove (const MidiNoteSelection&);
175 void remove (RegionView*);
176 void remove (MidiRegionView*);
177 void remove (MidiCutBuffer*);
178 void remove (uint32_t selection_id);
179 void remove (samplepos_t, samplepos_t);
180 void remove (boost::shared_ptr<ARDOUR::AutomationList>);
181 void remove (boost::shared_ptr<ARDOUR::Playlist>);
182 void remove (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
183 void remove (const std::list<Selectable*>&);
184 void remove (ArdourMarker*);
185 void remove (ControlPoint *);
187 void remove_regions (TimeAxisView *);
189 void move_time (samplecnt_t);
191 void replace (uint32_t time_index, samplepos_t start, samplepos_t end);
194 * A note about items in an editing Selection:
195 * At a high level, selections can include Tracks, Objects, or Time Ranges
196 * Range and Object selections are mutually exclusive.
197 * Selecting a Range will deselect all Objects, and vice versa.
198 * This is done to avoid confusion over what will happen in an operation such as Delete
199 * Tracks are somewhat orthogonal b/c editing operations don't apply to tracks.
200 * The Track selection isn't affected when ranges or objects are added.
203 void clear_all() { clear_time(); clear_tracks(); clear_objects(); }
205 void clear_time(bool with_signal = true); //clears any time selection ( i.e. Range )
206 void clear_tracks (bool with_signal = true); //clears the track header selections
207 void clear_objects(bool with_signal = true); //clears the items listed below
209 // these items get cleared wholesale in clear_objects
210 void clear_regions(bool with_signal = true);
211 void clear_lines (bool with_signal = true);
212 void clear_playlists (bool with_signal = true);
213 void clear_points (bool with_signal = true);
214 void clear_markers (bool with_signal = true);
215 void clear_midi_notes (bool with_signal = true);
216 void clear_midi_regions (bool with_signal = true);
218 void foreach_region (void (ARDOUR::Region::*method)(void));
219 void foreach_regionview (void (RegionView::*method)(void));
220 void foreach_midi_regionview (void (MidiRegionView::*method)(void));
221 template<class A> void foreach_region (void (ARDOUR::Region::*method)(A), A arg);
223 XMLNode& get_state () const;
224 int set_state (XMLNode const &, int);
226 std::list<std::pair<PBD::ID const, std::list<Evoral::event_id_t> > > pending_midi_note_selection;
228 void core_selection_changed (PBD::PropertyChange const & pc);
231 PublicEditor const * editor;
232 uint32_t next_time_id;
233 bool manage_libardour_selection;
235 TrackViewList add_grouped_tracks (TrackViewList const & t);
238 bool operator==(const Selection& a, const Selection& b);
240 #endif /* __ardour_gtk_selection_h__ */