Ardour  8.12
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 #ifndef __ardour_gtk_selection_h__
26 #define __ardour_gtk_selection_h__
27 
28 #include <memory>
29 #include <vector>
30 
31 #include <boost/noncopyable.hpp>
32 
33 #include <sigc++/signal.h>
34 
35 #include "pbd/signals.h"
36 
37 #include "ardour/types.h"
38 
39 #include "time_selection.h"
40 #include "region_selection.h"
41 #include "track_selection.h"
42 #include "automation_selection.h"
43 #include "playlist_selection.h"
44 #include "processor_selection.h"
45 #include "point_selection.h"
46 #include "marker_selection.h"
47 #include "midi_selection.h"
48 #include "trigger_selection.h"
49 
50 class TimeAxisView;
51 class RegionView;
52 class Selectable;
53 class PublicEditor;
54 class MidiRegionView;
55 class AutomationLine;
56 class ControlPoint;
57 
58 
59 namespace ARDOUR {
60  class Region;
61  class AudioRegion;
62  class Playlist;
63  class Processor;
64  class AutomationList;
65 }
66 
67 namespace Evoral {
68  class ControlList;
69 }
70 
72 
75 class Selection : public sigc::trackable, public PBD::ScopedConnectionList
76 {
77 public:
79  Object = 0x1,
80  Range = 0x2
81  };
82 
91 
94 
99 
101 
102  // Selection& operator= (const Selection& other);
103 
104  sigc::signal<void> TracksChanged;
105  sigc::signal<void> RegionsChanged;
106  sigc::signal<void> TimeChanged;
107  sigc::signal<void> LinesChanged;
108  sigc::signal<void> PlaylistsChanged;
109  sigc::signal<void> PointsChanged;
110  sigc::signal<void> MarkersChanged;
111  sigc::signal<void> MidiNotesChanged;
112  sigc::signal<void> TriggersChanged;
113 
114  void clear ();
115 
120  bool empty (bool internal_selection = false);
121 
123 
124  bool selected (TimeAxisView*) const;
125  bool selected (RegionView*) const;
126  bool selected (ArdourMarker*) const;
127  bool selected (ControlPoint*) const;
128  bool selected (TriggerEntry*) const;
129 
130  /* ToDo: some region operations (midi quantize, audio reverse) expect
131  * a RegionSelection (a list of regionviews). We're likely going to
132  * need a region_view + time_axis_view proxy, and this will get it.
133  */
135 
136  void set (std::list<Selectable*> const &);
137  void add (std::list<Selectable*> const &);
138  void toggle (std::list<Selectable*> const &);
139 
140  void set (TimeAxisView*);
141  void set (const TrackViewList&);
142  void set (const MidiNoteSelection&);
143  void set (RegionView*, bool also_clear_tracks = true);
144  void set (std::vector<RegionView*>&);
145  long set (Temporal::timepos_t const &, Temporal::timepos_t const &);
147  void set (std::shared_ptr<Evoral::ControlList>);
148  void set (std::shared_ptr<ARDOUR::Playlist>);
149  void set (const std::list<std::shared_ptr<ARDOUR::Playlist> >&);
150  void set (ControlPoint *);
151  void set (ArdourMarker*);
152  void set (const RegionSelection&);
153  void set (TriggerEntry*);
154 
156  void toggle (const TrackViewList&);
157  void toggle (const MidiNoteSelection&);
160  void toggle (std::vector<RegionView*>&);
163  void toggle (std::shared_ptr<ARDOUR::Playlist>);
164  void toggle (const std::list<std::shared_ptr<ARDOUR::Playlist> >&);
166  void toggle (std::vector<ControlPoint*> const &);
169 
170  void add (TimeAxisView*);
171  void add (const TrackViewList&);
172  void add (const MidiNoteSelection&);
173  void add (RegionView*);
175  void add (std::vector<RegionView*>&);
176  long add (Temporal::timepos_t const &, Temporal::timepos_t const &);
177  void add (std::shared_ptr<Evoral::ControlList>);
178  void add (std::shared_ptr<ARDOUR::Playlist>);
179  void add (const std::list<std::shared_ptr<ARDOUR::Playlist> >&);
180  void add (ControlPoint *);
181  void add (std::vector<ControlPoint*> const &);
182  void add (ArdourMarker*);
183  void add (const std::list<ArdourMarker*>&);
184  void add (const RegionSelection&);
185  void add (const PointSelection&);
186  void add (TriggerEntry*);
187 
189  void remove (const TrackViewList&);
190  void remove (const MidiNoteSelection&);
192  void remove (std::vector<RegionView*>);
194  void remove (uint32_t selection_id);
196  void remove (std::shared_ptr<ARDOUR::AutomationList>);
197  void remove (std::shared_ptr<ARDOUR::Playlist>);
198  void remove (const std::list<std::shared_ptr<ARDOUR::Playlist> >&);
199  void remove (const std::list<Selectable*>&);
203 
205 
207 
208  void replace (uint32_t time_index, Temporal::timepos_t const & start, Temporal::timepos_t const & end);
209 
210  /*
211  * A note about items in an editing Selection:
212  * At a high level, selections can include Tracks, Objects, or Time Ranges
213  * Range and Object selections are mutually exclusive.
214  * Selecting a Range will deselect all Objects, and vice versa.
215  * This is done to avoid confusion over what will happen in an operation such as Delete
216  * Tracks are somewhat orthogonal b/c editing operations don't apply to tracks.
217  * The Track selection isn't affected when ranges or objects are added.
218  */
219 
221 
222  void clear_time(bool with_signal = true); //clears any time selection ( i.e. Range )
223  void clear_tracks (bool with_signal = true); //clears the track header selections
224  void clear_objects(bool with_signal = true); //clears the items listed below
225 
226  // these items get cleared wholesale in clear_objects
227  void clear_regions(bool with_signal = true);
228  void clear_lines (bool with_signal = true);
229  void clear_playlists (bool with_signal = true);
230  void clear_points (bool with_signal = true);
231  void clear_markers (bool with_signal = true);
232  void clear_midi_notes (bool with_signal = true);
233  void clear_triggers (bool with_signal = true);
234 
235  void foreach_region (void (ARDOUR::Region::*method)(void));
236  void foreach_regionview (void (RegionView::*method)(void));
237  void foreach_midi_regionview (void (MidiRegionView::*method)(void));
238  template<class A> void foreach_region (void (ARDOUR::Region::*method)(A), A arg);
239 
240  XMLNode& get_state () const;
241  int set_state (XMLNode const &, int);
242 
243  std::list<std::pair<PBD::ID const, std::list<Evoral::event_id_t> > > pending_midi_note_selection;
244 
246 
247 private:
249  uint32_t next_time_id;
251 };
252 
253 bool operator==(const Selection& a, const Selection& b);
254 
255 #endif /* __ardour_gtk_selection_h__ */
bool operator==(const Color &lhs, const Color &rhs)
Representation of the interface of the Editor class.
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 >)
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
PublicEditor const * editor
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 * > &)
Selection(PublicEditor const *e, bool manage_libardour_selection)
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 *)
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:87
DebugBits ControlList