2 * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
3 * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
4 * Copyright (C) 2006-2017 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
6 * Copyright (C) 2014-2018 Ben Loftis <ben@harrisonconsoles.com>
7 * Copyright (C) 2015-2016 Nick Mainsbridge <mainsbridge@gmail.com>
8 * Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #ifndef __ardour_gtk_selection_h__
26 #define __ardour_gtk_selection_h__
29 #include <boost/shared_ptr.hpp>
30 #include <boost/noncopyable.hpp>
32 #include <sigc++/signal.h>
34 #include "pbd/signals.h"
36 #include "time_selection.h"
37 #include "region_selection.h"
38 #include "track_selection.h"
39 #include "automation_selection.h"
40 #include "playlist_selection.h"
41 #include "processor_selection.h"
42 #include "point_selection.h"
43 #include "marker_selection.h"
44 #include "midi_selection.h"
67 /// Lists of selected things
69 /** The Selection class holds lists of selected items (tracks, regions, etc. etc.). */
71 class Selection : public sigc::trackable, public PBD::ScopedConnectionList
86 TrackSelection tracks;
87 RegionSelection regions;
89 AutomationSelection lines;
90 PlaylistSelection playlists;
91 PointSelection points;
92 MarkerSelection markers;
93 MidiRegionSelection midi_regions;
95 /** only used when this class is used as a cut buffer */
96 MidiNoteSelection midi_notes;
98 Selection (PublicEditor const * e, bool manage_libardour_selection);
100 // Selection& operator= (const Selection& other);
102 sigc::signal<void> TracksChanged;
103 sigc::signal<void> RegionsChanged;
104 sigc::signal<void> TimeChanged;
105 sigc::signal<void> LinesChanged;
106 sigc::signal<void> PlaylistsChanged;
107 sigc::signal<void> PointsChanged;
108 sigc::signal<void> MarkersChanged;
109 sigc::signal<void> MidiNotesChanged;
110 sigc::signal<void> MidiRegionsChanged;
114 /** check if all selections are empty
115 * @param internal_selection also check object internals (e.g midi notes, automation points), when false only check objects.
116 * @return true if nothing is selected.
118 bool empty (bool internal_selection = false);
120 void dump_region_layers();
122 bool selected (TimeAxisView*) const;
123 bool selected (RegionView*) const;
124 bool selected (ArdourMarker*) const;
125 bool selected (ControlPoint*) const;
127 void set (std::list<Selectable*> const &);
128 void add (std::list<Selectable*> const &);
129 void toggle (std::list<Selectable*> const &);
131 void set (TimeAxisView*);
132 void set (const TrackViewList&);
133 void set (const MidiNoteSelection&);
134 void set (RegionView*, bool also_clear_tracks = true);
135 void set (MidiRegionView*);
136 void set (std::vector<RegionView*>&);
137 long set (samplepos_t, samplepos_t);
138 void set_preserving_all_ranges (samplepos_t, samplepos_t);
139 void set (boost::shared_ptr<Evoral::ControlList>);
140 void set (boost::shared_ptr<ARDOUR::Playlist>);
141 void set (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
142 void set (ControlPoint *);
143 void set (ArdourMarker*);
144 void set (const RegionSelection&);
146 void toggle (TimeAxisView*);
147 void toggle (const TrackViewList&);
148 void toggle (const MidiNoteSelection&);
149 void toggle (RegionView*);
150 void toggle (MidiRegionView*);
151 void toggle (MidiCutBuffer*);
152 void toggle (std::vector<RegionView*>&);
153 long toggle (samplepos_t, samplepos_t);
154 void toggle (ARDOUR::AutomationList*);
155 void toggle (boost::shared_ptr<ARDOUR::Playlist>);
156 void toggle (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
157 void toggle (ControlPoint *);
158 void toggle (std::vector<ControlPoint*> const &);
159 void toggle (ArdourMarker*);
161 void add (TimeAxisView*);
162 void add (const TrackViewList&);
163 void add (const MidiNoteSelection&);
164 void add (RegionView*);
165 void add (MidiRegionView*);
166 void add (MidiCutBuffer*);
167 void add (std::vector<RegionView*>&);
168 long add (samplepos_t, samplepos_t);
169 void add (boost::shared_ptr<Evoral::ControlList>);
170 void add (boost::shared_ptr<ARDOUR::Playlist>);
171 void add (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
172 void add (ControlPoint *);
173 void add (std::vector<ControlPoint*> const &);
174 void add (ArdourMarker*);
175 void add (const std::list<ArdourMarker*>&);
176 void add (const RegionSelection&);
177 void add (const PointSelection&);
178 void remove (TimeAxisView*);
179 void remove (const TrackViewList&);
180 void remove (const MidiNoteSelection&);
181 void remove (RegionView*);
182 void remove (MidiRegionView*);
183 void remove (MidiCutBuffer*);
184 void remove (uint32_t selection_id);
185 void remove (samplepos_t, samplepos_t);
186 void remove (boost::shared_ptr<ARDOUR::AutomationList>);
187 void remove (boost::shared_ptr<ARDOUR::Playlist>);
188 void remove (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
189 void remove (const std::list<Selectable*>&);
190 void remove (ArdourMarker*);
191 void remove (ControlPoint *);
193 void remove_regions (TimeAxisView *);
195 void move_time (samplecnt_t);
197 void replace (uint32_t time_index, samplepos_t start, samplepos_t end);
200 * A note about items in an editing Selection:
201 * At a high level, selections can include Tracks, Objects, or Time Ranges
202 * Range and Object selections are mutually exclusive.
203 * Selecting a Range will deselect all Objects, and vice versa.
204 * This is done to avoid confusion over what will happen in an operation such as Delete
205 * Tracks are somewhat orthogonal b/c editing operations don't apply to tracks.
206 * The Track selection isn't affected when ranges or objects are added.
209 void clear_all() { clear_time(); clear_tracks(); clear_objects(); }
211 void clear_time(bool with_signal = true); //clears any time selection ( i.e. Range )
212 void clear_tracks (bool with_signal = true); //clears the track header selections
213 void clear_objects(bool with_signal = true); //clears the items listed below
215 // these items get cleared wholesale in clear_objects
216 void clear_regions(bool with_signal = true);
217 void clear_lines (bool with_signal = true);
218 void clear_playlists (bool with_signal = true);
219 void clear_points (bool with_signal = true);
220 void clear_markers (bool with_signal = true);
221 void clear_midi_notes (bool with_signal = true);
222 void clear_midi_regions (bool with_signal = true);
224 void foreach_region (void (ARDOUR::Region::*method)(void));
225 void foreach_regionview (void (RegionView::*method)(void));
226 void foreach_midi_regionview (void (MidiRegionView::*method)(void));
227 template<class A> void foreach_region (void (ARDOUR::Region::*method)(A), A arg);
229 XMLNode& get_state () const;
230 int set_state (XMLNode const &, int);
232 std::list<std::pair<PBD::ID const, std::list<Evoral::event_id_t> > > pending_midi_note_selection;
234 void core_selection_changed (PBD::PropertyChange const & pc);
237 PublicEditor const * editor;
238 uint32_t next_time_id;
239 bool manage_libardour_selection;
241 TrackViewList add_grouped_tracks (TrackViewList const & t);
244 bool operator==(const Selection& a, const Selection& b);
246 #endif /* __ardour_gtk_selection_h__ */