Ardour  9.0-pre0-582-g084a23a80d
region_view.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
3  * Copyright (C) 2007-2011 Carl Hetherington <carl@carlh.net>
4  * Copyright (C) 2007-2019 Paul Davis <paul@linuxaudiosystems.com>
5  * Copyright (C) 2007 Doug McLain <doug@nostar.net>
6  * Copyright (C) 2015-2017 Nick Mainsbridge <mainsbridge@gmail.com>
7  * Copyright (C) 2016-2019 Robin Gareus <robin@gareus.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 #pragma once
25 
26 #ifdef interface
27 #undef interface
28 #endif
29 
30 #include <vector>
31 
32 #include <sigc++/signal.h>
33 #include "ardour/region.h"
34 
35 #include "canvas/fwd.h"
36 
37 #include "time_axis_view_item.h"
38 #include "editor_automation_line.h"
39 #include "enums.h"
40 #include "marker.h"
41 
42 class TimeAxisView;
43 class ArdourWindow;
44 class GhostRegion;
47 
48 namespace ArdourCanvas {
49  class Polygon;
50  class Text;
51 }
52 
54 {
55 public:
57  TimeAxisView& time_view,
58  const std::shared_ptr<ARDOUR::Region>& region,
59  double samples_per_pixel,
60  uint32_t base_color,
61  bool automation = false);
62 
63  RegionView (const RegionView& other);
64  RegionView (const RegionView& other, const std::shared_ptr<ARDOUR::Region>& other_region);
65 
67 
68  virtual void set_selected (bool yn);
69 
70  virtual void init (bool what_changed);
71 
72  std::shared_ptr<ARDOUR::Region> region() const { return _region; }
73 
74  bool is_valid() const { return valid; }
75 
76  void set_valid (bool yn) { valid = yn; }
77 
78  virtual void set_height (double);
79  virtual void set_samples_per_pixel (double);
80  virtual bool set_duration (Temporal::timecnt_t const &, void*);
81 
82  void move (double xdelta, double ydelta);
83 
85  void raise_to_top ();
86  void lower_to_bottom ();
87 
88  bool set_position(Temporal::timepos_t const & pos, void* src, double* delta = 0);
89 
92 
93  virtual void region_changed (const PBD::PropertyChange&);
94 
98 
99  virtual void entered () {}
100  virtual void exited () {}
101 
102  bool display_enabled() const;
103  virtual void redisplay (bool) = 0;
104  void redisplay () {
105  redisplay (true);
106  }
107 
108  virtual void tempo_map_changed () {
109  redisplay (true);
110  }
111 
113  DisplaySuspender (RegionView& rv, bool just_view = false) : region_view (rv), view_only (just_view) {
115  }
116 
119  }
120 
123  }
125  bool view_only;
126  };
127 
129 
131 
133  virtual void trim_front_starting () {}
134 
135  bool trim_front (Temporal::timepos_t const &, bool);
136 
138  virtual void trim_front_ending () {}
139 
140  bool trim_end (Temporal::timepos_t const &, bool);
142  virtual void thaw_after_trim ();
143 
144  void set_silent_frames (const ARDOUR::AudioIntervalResult&, double threshold);
147 
148  struct PositionOrder {
149  bool operator()(const RegionView* a, const RegionView* b) {
150  return a->region()->position() < b->region()->position();
151  }
152  };
153 
155 
157 
160 
161  virtual void color_handler() { set_colors(); }
162 
163 protected:
164 
169  TimeAxisView&,
170  const std::shared_ptr<ARDOUR::Region>&,
171  double samples_per_pixel,
172  uint32_t basic_color,
173  bool recording,
175 
177 
178  virtual void region_resized (const PBD::PropertyChange&);
179  virtual void region_muted ();
180  void region_locked ();
181  void region_opacity ();
182  virtual void region_renamed ();
184 
185  std::string make_name () const;
186 
187  static gint _lock_toggle (ArdourCanvas::Item*, GdkEvent*, void*);
188  void lock_toggle ();
189 
190  virtual void set_colors ();
191  virtual void set_sync_mark_color ();
193 
194  virtual void parameter_changed (std::string const&);
195 
197 
199 
200  std::shared_ptr<ARDOUR::Region> _region;
201 
204 
206 
207  std::vector<ControlPoint *> control_points;
209 
210  bool valid;
211  uint32_t _disable_display;
212  double _pixel_width;
214 
216 
217  std::vector<GhostRegion*> ghosts;
218 
223  std::list<ArdourCanvas::Rectangle*> _coverage_frame;
224 
227  std::list<ArdourCanvas::Rectangle*> _silent_frames;
230  std::list<ArdourCanvas::Rectangle*> _silent_threshold_samples;
233 
234 private:
236  std::list<std::pair<samplepos_t, ArdourCanvas::Arrow*> > _xrun_markers;
238 
240 
242 
243  struct ViewCueMarker {
246 
249  };
250 
251  typedef std::list<ViewCueMarker*> ViewCueMarkers;
254 
255  private:
256  friend struct DisplaySuspender;
257  void enable_display (bool view_only);
259 
260 };
261 
bool display_enabled() const
std::list< ArdourCanvas::Rectangle * > _silent_frames
Definition: region_view.h:227
void drop_cue_marker(ArdourMarker *)
void update_cue_markers()
void region_opacity()
void set_silent_frames(const ARDOUR::AudioIntervalResult &, double threshold)
virtual void set_selected(bool yn)
virtual void color_handler()
Definition: region_view.h:161
void remove_ghost_in(TimeAxisView &)
std::vector< ControlPoint * > control_points
Definition: region_view.h:207
virtual void tempo_map_changed()
Definition: region_view.h:108
virtual void parameter_changed(std::string const &)
void region_sync_changed()
virtual void set_height(double)
double current_visible_sync_position
Definition: region_view.h:208
static PBD::Signal< void(RegionView *)> RegionViewGoingAway
Definition: region_view.h:130
std::list< ViewCueMarker * > ViewCueMarkers
Definition: region_view.h:251
RegionView(ArdourCanvas::Container *, TimeAxisView &, const std::shared_ptr< ARDOUR::Region > &, double samples_per_pixel, uint32_t basic_color, bool recording, TimeAxisViewItem::Visibility)
std::shared_ptr< ARDOUR::Region > _region
Definition: region_view.h:200
virtual void set_colors()
void maybe_raise_cue_markers()
bool canvas_group_event(GdkEvent *)
bool wait_for_data
Definition: region_view.h:215
std::list< ArdourCanvas::Rectangle * > _coverage_frame
Definition: region_view.h:223
bool set_position(Temporal::timepos_t const &pos, void *src, double *delta=0)
Temporal::timecnt_t snap_region_time_to_region_time(Temporal::timecnt_t const &, bool ensure_snap=false) const
void enable_display(bool view_only)
virtual void region_muted()
std::shared_ptr< ARDOUR::Region > region() const
Definition: region_view.h:72
void update_xrun_markers()
ViewCueMarkers _cue_markers
Definition: region_view.h:252
void lower_to_bottom()
void move_contents(Temporal::timecnt_t const &)
virtual void thaw_after_trim()
void show_region_editor()
virtual void set_sync_mark_color()
bool is_valid() const
Definition: region_view.h:74
bool trim_end(Temporal::timepos_t const &, bool)
RegionView(ArdourCanvas::Container *parent, TimeAxisView &time_view, const std::shared_ptr< ARDOUR::Region > &region, double samples_per_pixel, uint32_t base_color, bool automation=false)
void drop_silent_frames()
virtual void update_coverage_frame(LayerDisplay)
std::string make_name() const
void raise_to_top()
bool valid
see StreamView::redisplay_diskstream()
Definition: region_view.h:210
virtual void trim_front_ending()
Definition: region_view.h:138
void disable_display()
virtual void region_resized(const PBD::PropertyChange &)
virtual void region_renamed()
virtual void reset_width_dependent_items(double pixel_width)
virtual void trim_front_starting()
Definition: region_view.h:133
void move(double xdelta, double ydelta)
virtual bool set_duration(Temporal::timecnt_t const &, void *)
void lock_toggle()
ArdourCanvas::Polygon * sync_mark
polygon for sync position
Definition: region_view.h:202
void hide_silent_frames()
virtual GhostRegion * add_ghost(TimeAxisView &)=0
bool _xrun_markers_visible
Definition: region_view.h:237
ArdourCanvas::Line * sync_line
polygon for sync position
Definition: region_view.h:203
virtual void set_samples_per_pixel(double)
virtual void init(bool what_changed)
std::vector< GhostRegion * > ghosts
Definition: region_view.h:217
RegionView(const RegionView &other, const std::shared_ptr< ARDOUR::Region > &other_region)
std::list< ArdourCanvas::Rectangle * > _silent_threshold_samples
Definition: region_view.h:230
RegionView(const RegionView &other)
void region_locked()
void remove_ghost(GhostRegion *)
static gint _lock_toggle(ArdourCanvas::Item *, GdkEvent *, void *)
uint32_t _disable_display
see StreamView::redisplay_diskstream()
Definition: region_view.h:211
void set_valid(bool yn)
Definition: region_view.h:76
void hide_region_editor()
void visual_layer_on_top()
ArdourCanvas::Text * _silence_text
Definition: region_view.h:232
virtual void entered()
Definition: region_view.h:99
std::list< std::pair< samplepos_t, ArdourCanvas::Arrow * > > _xrun_markers
Definition: region_view.h:236
double _pixel_width
Definition: region_view.h:212
void clear_coverage_frame()
Temporal::timecnt_t region_relative_distance(Temporal::timecnt_t const &, Temporal::TimeDomain desired_time_domain)
void redisplay()
Definition: region_view.h:104
ARDOUR::CueMarker find_model_cue_marker(ArdourMarker *)
virtual void exited()
Definition: region_view.h:100
virtual void region_changed(const PBD::PropertyChange &)
virtual void redisplay(bool)=0
bool in_destructor
Definition: region_view.h:213
void update_visibility()
bool trim_front(Temporal::timepos_t const &, bool)
bool _cue_markers_visible
Definition: region_view.h:253
ArdourWindow * _editor
Definition: region_view.h:205
LayerDisplay
std::list< std::pair< sampleoffset_t, sampleoffset_t > > AudioIntervalResult
int pixel_width(const std::string &str, const Pango::FontDescription &font)
DisplaySuspender(DisplaySuspender const &other)
Definition: region_view.h:117
DisplaySuspender(RegionView &rv, bool just_view=false)
Definition: region_view.h:113
bool operator()(const RegionView *a, const RegionView *b)
Definition: region_view.h:149
ViewCueMarker(ArdourMarker *m, ARDOUR::CueMarker const &c)
Definition: region_view.h:247
ArdourMarker * view_marker
Definition: region_view.h:244
ARDOUR::CueMarker model_marker
Definition: region_view.h:245