Ardour  9.0-pre0-582-g084a23a80d
gtk2_ardour/selection.h
Go to the documentation of this file.
1 /*
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>
9  *
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.
14  *
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.
19  *
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.
23  */
24 
25 #pragma once
26 
27 #include <memory>
28 #include <vector>
29 
30 #include <sigc++/signal.h>
31 
32 #include "pbd/signals.h"
33 
34 #include "ardour/types.h"
35 
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"
45 #include "trigger_selection.h"
46 
47 class TimeAxisView;
48 class RegionView;
49 class Selectable;
50 class EditingContext;
51 class MidiRegionView;
53 class ControlPoint;
54 
55 
56 namespace ARDOUR {
57  class Region;
58  class AudioRegion;
59  class Playlist;
60  class Processor;
61  class AutomationList;
62 }
63 
64 namespace Evoral {
65  class ControlList;
66 }
67 
69 
72 class Selection : public sigc::trackable, public PBD::ScopedConnectionList
73 {
74 public:
76  Object = 0x1,
77  Range = 0x2
78  };
79 
88 
91 
96 
98 
99  // Selection& operator= (const Selection& other);
100 
101  sigc::signal<void> TracksChanged;
102  sigc::signal<void> RegionsChanged;
103  sigc::signal<void> TimeChanged;
104  sigc::signal<void> LinesChanged;
105  sigc::signal<void> PlaylistsChanged;
106  sigc::signal<void> PointsChanged;
107  sigc::signal<void> MarkersChanged;
108  sigc::signal<void> MidiNotesChanged;
109  sigc::signal<void> TriggersChanged;
110 
111  void clear ();
112 
117  bool empty (bool internal_selection = false);
118 
120 
121  bool selected (TimeAxisView*) const;
122  bool selected (RegionView*) const;
123  bool selected (ArdourMarker*) const;
124  bool selected (ControlPoint*) const;
125  bool selected (TriggerEntry*) const;
126 
127  /* ToDo: some region operations (midi quantize, audio reverse) expect
128  * a RegionSelection (a list of regionviews). We're likely going to
129  * need a region_view + time_axis_view proxy, and this will get it.
130  */
132 
133  void set (std::list<Selectable*> const &);
134  void add (std::list<Selectable*> const &);
135  void toggle (std::list<Selectable*> const &);
136 
137  void set (TimeAxisView*);
138  void set (const TrackViewList&);
139  void set (const MidiNoteSelection&);
140  void set (RegionView*, bool also_clear_tracks = true);
141  void set (std::vector<RegionView*>&);
142  long set (Temporal::timepos_t const &, Temporal::timepos_t const &);
144  void set (std::shared_ptr<Evoral::ControlList>);
145  void set (std::shared_ptr<ARDOUR::Playlist>);
146  void set (const std::list<std::shared_ptr<ARDOUR::Playlist> >&);
147  void set (ControlPoint *);
148  void set (ArdourMarker*);
149  void set (const RegionSelection&);
150  void set (TriggerEntry*);
151 
153  void toggle (const TrackViewList&);
154  void toggle (const MidiNoteSelection&);
157  void toggle (std::vector<RegionView*>&);
160  void toggle (std::shared_ptr<ARDOUR::Playlist>);
161  void toggle (const std::list<std::shared_ptr<ARDOUR::Playlist> >&);
163  void toggle (std::vector<ControlPoint*> const &);
166 
167  void add (TimeAxisView*);
168  void add (const TrackViewList&);
169  void add (const MidiNoteSelection&);
170  void add (RegionView*);
172  void add (std::vector<RegionView*>&);
173  long add (Temporal::timepos_t const &, Temporal::timepos_t const &);
174  void add (std::shared_ptr<Evoral::ControlList>);
175  void add (std::shared_ptr<ARDOUR::Playlist>);
176  void add (const std::list<std::shared_ptr<ARDOUR::Playlist> >&);
177  void add (ControlPoint *);
178  void add (std::vector<ControlPoint*> const &);
179  void add (ArdourMarker*);
180  void add (const std::list<ArdourMarker*>&);
181  void add (const RegionSelection&);
182  void add (const PointSelection&);
183  void add (TriggerEntry*);
184 
186  void remove (const TrackViewList&);
187  void remove (const MidiNoteSelection&);
189  void remove (std::vector<RegionView*>);
191  void remove (uint32_t selection_id);
193  void remove (std::shared_ptr<ARDOUR::AutomationList>);
194  void remove (std::shared_ptr<ARDOUR::Playlist>);
195  void remove (const std::list<std::shared_ptr<ARDOUR::Playlist> >&);
196  void remove (const std::list<Selectable*>&);
200 
202 
204 
205  void replace (uint32_t time_index, Temporal::timepos_t const & start, Temporal::timepos_t const & end);
206 
207  /*
208  * A note about items in an editing Selection:
209  * At a high level, selections can include Tracks, Objects, or Time Ranges
210  * Range and Object selections are mutually exclusive.
211  * Selecting a Range will deselect all Objects, and vice versa.
212  * This is done to avoid confusion over what will happen in an operation such as Delete
213  * Tracks are somewhat orthogonal b/c editing operations don't apply to tracks.
214  * The Track selection isn't affected when ranges or objects are added.
215  */
216 
218 
219  void clear_time(bool with_signal = true); //clears any time selection ( i.e. Range )
220  void clear_tracks (bool with_signal = true); //clears the track header selections
221  void clear_objects(bool with_signal = true); //clears the items listed below
222 
223  // these items get cleared wholesale in clear_objects
224  void clear_regions(bool with_signal = true);
225  void clear_lines (bool with_signal = true);
226  void clear_playlists (bool with_signal = true);
227  void clear_points (bool with_signal = true);
228  void clear_markers (bool with_signal = true);
229  void clear_midi_notes (bool with_signal = true);
230  void clear_triggers (bool with_signal = true);
231 
232  void foreach_region (void (ARDOUR::Region::*method)(void));
233  void foreach_regionview (void (RegionView::*method)(void));
234  void foreach_midi_regionview (void (MidiRegionView::*method)(void));
235  template<class A> void foreach_region (void (ARDOUR::Region::*method)(A), A arg);
236 
237  XMLNode& get_state () const;
238  int set_state (XMLNode const &, int);
239 
240  std::list<std::pair<PBD::ID const, std::list<Evoral::event_id_t> > > pending_midi_note_selection;
241 
243 
244 private:
246  uint32_t next_time_id;
248 };
249 
250 bool operator==(const Selection& a, const Selection& b);
251 
bool operator==(const Color &lhs, const Color &rhs)
Lists of selected things.
void set(std::list< Selectable * > const &)
void add(const MidiNoteSelection &)
void add(std::vector< RegionView * > &)
void toggle(RegionView *)
void toggle(std::shared_ptr< ARDOUR::Playlist >)
EditingContext const * editor
void set_preserving_all_ranges(Temporal::timepos_t const &, Temporal::timepos_t const &)
bool selected(RegionView *) const
void toggle(const TrackViewList &)
void remove(const MidiNoteSelection &)
void toggle(ARDOUR::AutomationList *)
void toggle(std::vector< RegionView * > &)
void remove_regions(TimeAxisView *)
AutomationSelection lines
void set(const std::list< std::shared_ptr< ARDOUR::Playlist > > &)
void clear_midi_notes(bool with_signal=true)
void add(const PointSelection &)
MarkerSelection markers
sigc::signal< void > MarkersChanged
std::list< std::pair< PBD::ID const, std::list< Evoral::event_id_t > > > pending_midi_note_selection
void clear_regions(bool with_signal=true)
void remove(ArdourMarker *)
sigc::signal< void > TimeChanged
void add(const RegionSelection &)
TriggerSelection triggers
void add(ControlPoint *)
sigc::signal< void > MidiNotesChanged
void remove(ControlPoint *)
void remove(samplepos_t, samplepos_t)
sigc::signal< void > TracksChanged
void clear()
void add(std::shared_ptr< Evoral::ControlList >)
bool manage_libardour_selection
void replace(uint32_t time_index, Temporal::timepos_t const &start, Temporal::timepos_t const &end)
void toggle(std::vector< ControlPoint * > const &)
void clear_time(bool with_signal=true)
PlaylistSelection playlists
long toggle(Temporal::timepos_t const &, Temporal::timepos_t const &)
void add(const TrackViewList &)
void foreach_midi_regionview(void(MidiRegionView::*method)(void))
void set(ControlPoint *)
void toggle(std::list< Selectable * > const &)
TrackSelection tracks
void remove(const std::list< std::shared_ptr< ARDOUR::Playlist > > &)
MidiNoteSelection midi_notes
void add(const std::list< ArdourMarker * > &)
void remove(std::shared_ptr< ARDOUR::AutomationList >)
sigc::signal< void > PointsChanged
void set(const RegionSelection &)
void toggle(ControlPoint *)
void foreach_regionview(void(RegionView::*method)(void))
TimeSelection time
sigc::signal< void > RegionsChanged
void add(std::vector< ControlPoint * > const &)
MidiRegionSelection midi_regions()
void clear_triggers(bool with_signal=true)
void remove(std::vector< RegionView * >)
void remove(uint32_t selection_id)
void set(TriggerEntry *)
sigc::signal< void > TriggersChanged
void remove(const std::list< Selectable * > &)
bool empty(bool internal_selection=false)
void set(const TrackViewList &)
void set(std::vector< RegionView * > &)
void add(RegionView *)
void clear_playlists(bool with_signal=true)
bool selected(TriggerEntry *) const
long set(Temporal::timepos_t const &, Temporal::timepos_t const &)
void add(MidiCutBuffer *)
void remove(const TrackViewList &)
void remove(TriggerEntry *)
void remove(RegionView *)
RegionSelection trigger_regionview_proxy() const
void set(TimeAxisView *)
void clear_markers(bool with_signal=true)
void set(std::shared_ptr< ARDOUR::Playlist >)
void remove(MidiCutBuffer *)
XMLNode & get_state() const
void core_selection_changed(PBD::PropertyChange const &pc)
long add(Temporal::timepos_t const &, Temporal::timepos_t const &)
void clear_lines(bool with_signal=true)
void clear_objects(bool with_signal=true)
void add(ArdourMarker *)
void add(std::shared_ptr< ARDOUR::Playlist >)
void remove(std::shared_ptr< ARDOUR::Playlist >)
void add(TimeAxisView *)
void toggle(const MidiNoteSelection &)
void toggle(MidiCutBuffer *)
void remove(TimeAxisView *)
sigc::signal< void > LinesChanged
void toggle(const std::list< std::shared_ptr< ARDOUR::Playlist > > &)
void toggle(TriggerEntry *)
bool selected(TimeAxisView *) const
void add(const std::list< std::shared_ptr< ARDOUR::Playlist > > &)
void set(ArdourMarker *)
int set_state(XMLNode const &, int)
PointSelection points
void toggle(ArdourMarker *)
Selection(EditingContext const *e, bool manage_libardour_selection)
sigc::signal< void > PlaylistsChanged
void dump_region_layers()
void toggle(TimeAxisView *)
bool selected(ArdourMarker *) const
void add(TriggerEntry *)
void add(std::list< Selectable * > const &)
void clear_tracks(bool with_signal=true)
bool selected(ControlPoint *) const
void set(std::shared_ptr< Evoral::ControlList >)
void clear_points(bool with_signal=true)
void set(RegionView *, bool also_clear_tracks=true)
void set(const MidiNoteSelection &)
void foreach_region(void(ARDOUR::Region::*method)(void))
void move_time(Temporal::timecnt_t const &)
RegionSelection regions
Definition: xml++.h:114
PBD::PropertyDescriptor< timepos_t > start
Temporal::samplepos_t samplepos_t
Definition: editor.h:86
DebugBits ControlList