2 * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
3 * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
4 * Copyright (C) 2007 Doug McLain <doug@nostar.net>
5 * Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
6 * Copyright (C) 2012 Ben Loftis <ben@harrisonconsoles.com>
7 * Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
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.
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.
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.
24 #ifndef __gtk_ardour_audio_region_view_h__
25 #define __gtk_ardour_audio_region_view_h__
33 #include <sigc++/signal.h>
34 #include "ardour/audioregion.h"
36 #include "canvas/fwd.h"
37 #include "canvas/xfade_curve.h"
39 #include "waveview/wave_view.h"
41 #include "region_view.h"
42 #include "time_axis_view_item.h"
43 #include "automation_line.h"
51 class AudioTimeAxisView;
52 class AudioRegionGainLine;
54 class AutomationTimeAxisView;
55 class RouteTimeAxisView;
57 class AudioRegionView : public RegionView
60 AudioRegionView (ArdourCanvas::Container *,
62 boost::shared_ptr<ARDOUR::AudioRegion>,
63 double initial_samples_per_pixel,
66 AudioRegionView (ArdourCanvas::Container *,
68 boost::shared_ptr<ARDOUR::AudioRegion>,
69 double samples_per_pixel,
72 TimeAxisViewItem::Visibility);
74 AudioRegionView (const AudioRegionView& other, boost::shared_ptr<ARDOUR::AudioRegion>);
78 void init (bool wait_for_data);
80 boost::shared_ptr<ARDOUR::AudioRegion> audio_region() const;
85 void set_height (double);
86 void set_samples_per_pixel (double);
88 void set_amplitude_above_axis (gdouble spp);
90 void temporarily_hide_envelope (); ///< Dangerous!
91 void unhide_envelope (); ///< Dangerous!
93 void update_envelope_visibility ();
95 void add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *event, bool with_guard_points);
96 void remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent *event);
98 boost::shared_ptr<AudioRegionGainLine> get_gain_line() const { return gain_line; }
100 void region_changed (const PBD::PropertyChange&);
101 void envelope_active_changed ();
103 GhostRegion* add_ghost (TimeAxisView&);
105 void reset_fade_in_shape_width (boost::shared_ptr<ARDOUR::AudioRegion> ar, samplecnt_t, bool drag_active = false);
106 void reset_fade_out_shape_width (boost::shared_ptr<ARDOUR::AudioRegion> ar, samplecnt_t, bool drag_active = false);
108 samplepos_t get_fade_in_shape_width ();
109 samplepos_t get_fade_out_shape_width ();
111 void set_fade_visibility (bool);
112 void update_coverage_frame (LayerDisplay);
114 void update_transient(float old_pos, float new_pos);
115 void remove_transient(float pos);
117 void show_region_editor ();
119 virtual void entered ();
120 virtual void exited ();
122 void thaw_after_trim ();
127 void redraw_start_xfade_to (boost::shared_ptr<ARDOUR::AudioRegion>, samplecnt_t, ArdourCanvas::Points&, double, double);
128 void redraw_end_xfade_to (boost::shared_ptr<ARDOUR::AudioRegion>, samplecnt_t, ArdourCanvas::Points&, double, double, double);
129 void redraw_start_xfade ();
130 void redraw_end_xfade ();
133 void hide_start_xfade ();
134 void hide_end_xfade ();
136 void show_start_xfade ();
137 void show_end_xfade ();
139 bool start_xfade_visible () const {
140 return _start_xfade_visible;
143 bool end_xfade_visible () const {
144 return _end_xfade_visible;
149 /* this constructor allows derived types
150 * to specify their visibility requirements
151 * to the TimeAxisViewItem parent class
155 WaveformVisible = 0x4,
156 WaveformRectified = 0x8,
157 WaveformLogScaled = 0x10,
160 std::vector<ArdourWaveView::WaveView *> waves;
161 std::vector<ArdourWaveView::WaveView *> tmp_waves; ///< see \ref create_waves()
163 std::list<std::pair<samplepos_t, ArdourCanvas::Line*> > feature_lines;
165 ArdourCanvas::Polygon* sync_mark; ///< polgyon for sync position
166 ArdourCanvas::Rectangle* fade_in_handle; ///< fade in handle, or 0
167 ArdourCanvas::Rectangle* fade_out_handle; ///< fade out handle, or 0
168 ArdourCanvas::Rectangle* fade_in_trim_handle; ///< fade in trim handle, or 0
169 ArdourCanvas::Rectangle* fade_out_trim_handle; ///< fade out trim handle, or 0
170 ArdourCanvas::Rectangle* pending_peak_data;
172 static Cairo::RefPtr<Cairo::Pattern> pending_peak_pattern;
174 ArdourCanvas::XFadeCurve* start_xfade_curve;
175 ArdourCanvas::Rectangle* start_xfade_rect;
176 bool _start_xfade_visible;
178 ArdourCanvas::XFadeCurve* end_xfade_curve;
179 ArdourCanvas::Rectangle* end_xfade_rect;
180 bool _end_xfade_visible;
182 boost::shared_ptr<AudioRegionGainLine> gain_line;
184 double _amplitude_above_axis;
186 void reset_fade_shapes ();
187 void reset_fade_in_shape ();
188 void reset_fade_out_shape ();
189 void fade_in_changed ();
190 void fade_out_changed ();
191 void fade_in_active_changed ();
192 void fade_out_active_changed ();
194 void region_resized (const PBD::PropertyChange&);
195 void region_muted ();
196 void region_scale_amplitude_changed ();
197 void region_renamed ();
199 void create_one_wave (uint32_t, bool);
200 void peaks_ready_handler (uint32_t);
203 void set_waveform_colors ();
204 void reset_width_dependent_items (double pixel_width);
205 void set_frame_color ();
207 void color_handler ();
209 void transients_changed();
211 AutomationLine::VisibleAspects automation_line_visibility () const;
214 void setup_fade_handle_positions ();
216 void parameter_changed (std::string const &);
217 void setup_waveform_visibility ();
218 void set_some_waveform_colors (std::vector<ArdourWaveView::WaveView*>& waves_to_color);
220 /** A ScopedConnection for each PeaksReady callback (one per channel). Each member
221 * may be 0 if no connection exists.
223 std::vector<PBD::ScopedConnection*> _data_ready_connections;
225 /** RegionViews that we hid the xfades for at the start of the current drag;
226 * first list is for start xfades, second list is for end xfades.
228 std::pair<std::list<AudioRegionView*>, std::list<AudioRegionView*> > _hidden_xfades;
230 bool trim_fade_in_drag_active;
231 bool trim_fade_out_drag_active;
234 #endif /* __gtk_ardour_audio_region_view_h__ */