ardour
selection.h
Go to the documentation of this file.
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 class AutomationLine;
47 class ControlPoint;
48 
49 
50 namespace ARDOUR {
51  class Region;
52  class AudioRegion;
53  class Playlist;
54  class Processor;
55  class AutomationList;
56 }
57 
58 namespace Evoral {
59  class ControlList;
60 }
61 
63 
66 class Selection : public sigc::trackable, public PBD::ScopedConnectionList
67 {
68  public:
70  Object = 0x1,
71  Range = 0x2
72  };
73 
74  enum Operation {
75  Set,
76  Add,
79  };
80 
89 
92 
93  Selection (PublicEditor const * e);
94 
95  // Selection& operator= (const Selection& other);
96 
97  sigc::signal<void> RegionsChanged;
98  sigc::signal<void> TracksChanged;
99  sigc::signal<void> TimeChanged;
100  sigc::signal<void> LinesChanged;
101  sigc::signal<void> PlaylistsChanged;
102  sigc::signal<void> PointsChanged;
103  sigc::signal<void> MarkersChanged;
104  sigc::signal<void> MidiNotesChanged;
105  sigc::signal<void> MidiRegionsChanged;
106 
107  void block_tracks_changed (bool);
108 
109  void clear ();
110  bool empty (bool internal_selection = false);
111 
112  void dump_region_layers();
113 
114  bool selected (TimeAxisView*);
115  bool selected (RegionView*);
116  bool selected (Marker*);
117  bool selected (ControlPoint*);
118 
119  void set (std::list<Selectable*> const &);
120  void add (std::list<Selectable*> const &);
121  void toggle (std::list<Selectable*> const &);
122 
123  void set (TimeAxisView*);
124  void set (const TrackViewList&);
125  void set (const MidiNoteSelection&);
126  void set (RegionView*, bool also_clear_tracks = true);
127  void set (MidiRegionView*);
128  void set (std::vector<RegionView*>&);
129  long set (framepos_t, framepos_t);
133  void set (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
134  void set (ControlPoint *);
135  void set (Marker*);
136  void set (const RegionSelection&);
137 
138  void toggle (TimeAxisView*);
139  void toggle (const TrackViewList&);
140  void toggle (const MidiNoteSelection&);
141  void toggle (RegionView*);
142  void toggle (MidiRegionView*);
143  void toggle (MidiCutBuffer*);
144  void toggle (std::vector<RegionView*>&);
145  long toggle (framepos_t, framepos_t);
148  void toggle (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
149  void toggle (ControlPoint *);
150  void toggle (std::vector<ControlPoint*> const &);
151  void toggle (Marker*);
152 
153  void add (TimeAxisView*);
154  void add (const TrackViewList&);
155  void add (const MidiNoteSelection&);
156  void add (RegionView*);
157  void add (MidiRegionView*);
158  void add (MidiCutBuffer*);
159  void add (std::vector<RegionView*>&);
160  long add (framepos_t, framepos_t);
163  void add (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
164  void add (ControlPoint *);
165  void add (std::vector<ControlPoint*> const &);
166  void add (Marker*);
167  void add (const std::list<Marker*>&);
168  void add (const RegionSelection&);
169  void add (const PointSelection&);
170  void remove (TimeAxisView*);
171  void remove (const TrackViewList&);
172  void remove (const MidiNoteSelection&);
173  void remove (RegionView*);
174  void remove (MidiRegionView*);
175  void remove (MidiCutBuffer*);
176  void remove (uint32_t selection_id);
177  void remove (framepos_t, framepos_t);
180  void remove (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
181  void remove (const std::list<Selectable*>&);
182  void remove (Marker*);
183  void remove (ControlPoint *);
184 
185  void remove_regions (TimeAxisView *);
186 
187  void move_time (framecnt_t);
188 
189  void replace (uint32_t time_index, framepos_t start, framepos_t end);
190 
191 /*
192  * A note about items in an editing Selection:
193  * At a high level, selections can include Tracks, Objects, or Time Ranges
194  * Range and Object selections are mutually exclusive.
195  * Selecting a Range will deselect all Objects, and vice versa.
196  * This is done to avoid confusion over what will happen in an operation such as Delete
197  * Tracks are somewhat orthogonal b/c editing operations don't apply to tracks.
198  * The Track selection isn't affected when ranges or objects are added.
199  */
200 
202 
203  void clear_time(); //clears any time selection ( i.e. Range )
204  void clear_tracks (); //clears the track header selections
205  void clear_objects(); //clears the items listed below
206 
207  // these items get cleared wholesale in clear_objects
208  void clear_regions();
209  void clear_lines ();
210  void clear_playlists ();
211  void clear_points ();
212  void clear_markers ();
213  void clear_midi_notes ();
214  void clear_midi_regions ();
215 
216  void foreach_region (void (ARDOUR::Region::*method)(void));
217  void foreach_regionview (void (RegionView::*method)(void));
218  void foreach_midi_regionview (void (MidiRegionView::*method)(void));
219  template<class A> void foreach_region (void (ARDOUR::Region::*method)(A), A arg);
220 
221  XMLNode& get_state () const;
222  int set_state (XMLNode const &, int);
223 
224  PBD::Signal0<void> ClearMidiNoteSelection;
225 
226  std::list<std::pair<PBD::ID const, std::list<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > > pending_midi_note_selection;
227 
228  private:
230  uint32_t next_time_id;
232 };
233 
234 bool operator==(const Selection& a, const Selection& b);
235 
236 #endif /* __ardour_gtk_selection_h__ */
PBD::Signal0< void > ClearMidiNoteSelection
Definition: selection.h:224
void move_time(framecnt_t)
Definition: selection.cc:548
void clear_regions()
Definition: selection.cc:159
void remove_regions(TimeAxisView *)
Definition: selection.cc:1502
AutomationSelection lines
Definition: selection.h:84
void clear()
Definition: selection.cc:101
Lists of selected things.
Definition: selection.h:66
sigc::signal< void > PlaylistsChanged
Definition: selection.h:101
Representation of the interface of the Editor class.
void foreach_regionview(void(RegionView::*method)(void))
Definition: marker.h:41
void foreach_midi_regionview(void(MidiRegionView::*method)(void))
MarkerSelection markers
Definition: selection.h:87
void set(std::list< Selectable * > const &)
Definition: selection.cc:1024
sigc::signal< void > MarkersChanged
Definition: selection.h:103
void block_tracks_changed(bool)
Definition: selection.cc:1518
std::list< std::pair< PBD::ID const, std::list< boost::shared_ptr< Evoral::Note< Evoral::Beats > > > > > pending_midi_note_selection
Definition: selection.h:226
sigc::signal< void > TimeChanged
Definition: selection.h:99
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > start
Definition: region.cc:63
void set_preserving_all_ranges(framepos_t, framepos_t)
Definition: selection.cc:882
sigc::signal< void > MidiRegionsChanged
Definition: selection.h:105
void clear_playlists()
Definition: selection.cc:193
bool empty(bool internal_selection=false)
Definition: selection.cc:938
Selection(PublicEditor const *e)
Definition: selection.cc:51
void clear_time()
Definition: selection.cc:141
void clear_all()
Definition: selection.h:201
void add(std::list< Selectable * > const &)
Definition: selection.cc:1045
void toggle(std::list< Selectable * > const &)
Definition: selection.cc:991
int64_t framecnt_t
Definition: types.h:76
void replace(uint32_t time_index, framepos_t start, framepos_t end)
Definition: selection.cc:563
Definition: amp.h:29
MidiNoteSelection midi_notes
Definition: selection.h:91
void clear_points()
Definition: selection.cc:1078
MidiRegionSelection midi_regions
Definition: selection.h:88
RegionSelection regions
Definition: selection.h:82
bool _no_tracks_changed
Definition: selection.h:231
PlaylistSelection playlists
Definition: selection.h:85
bool selected(TimeAxisView *)
Definition: selection.cc:920
void clear_objects()
Definition: selection.cc:116
PointSelection points
Definition: selection.h:86
LIBEVORAL_API uint64_t ControlList
Definition: debug.cpp:5
Definition: xml++.h:95
sigc::signal< void > PointsChanged
Definition: selection.h:102
void clear_tracks()
Definition: selection.cc:127
TimeSelection time
Definition: selection.h:83
TrackSelection tracks
Definition: selection.h:81
XMLNode & get_state() const
Definition: selection.cc:1208
sigc::signal< void > LinesChanged
Definition: selection.h:100
sigc::signal< void > MidiNotesChanged
Definition: selection.h:104
void clear_lines()
Definition: selection.cc:210
sigc::signal< void > TracksChanged
Definition: selection.h:98
void clear_midi_notes()
Definition: selection.cc:168
void foreach_region(void(ARDOUR::Region::*method)(void))
uint32_t next_time_id
Definition: selection.h:230
sigc::signal< void > RegionsChanged
Definition: selection.h:97
PublicEditor const * editor
Definition: selection.h:229
bool operator==(const Selection &a, const Selection &b)
Definition: selection.cc:88
void clear_midi_regions()
Definition: selection.cc:184
int64_t framepos_t
void dump_region_layers()
Definition: selection.cc:149
void clear_markers()
Definition: selection.cc:219
int set_state(XMLNode const &, int)
Definition: selection.cc:1307