NO-OP whitespace (updated GH PR #357)
[ardour.git] / gtk2_ardour / audio_region_view.h
1 /*
2     Copyright (C) 2001-2006 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 #ifndef __gtk_ardour_audio_region_view_h__
20 #define __gtk_ardour_audio_region_view_h__
21
22 #ifdef interface
23 #undef interface
24 #endif
25
26 #include <vector>
27
28 #include <sigc++/signal.h>
29 #include "ardour/audioregion.h"
30
31 #include "canvas/fwd.h"
32 #include "canvas/wave_view.h"
33 #include "canvas/xfade_curve.h"
34
35 #include "region_view.h"
36 #include "time_axis_view_item.h"
37 #include "automation_line.h"
38 #include "enums.h"
39
40 namespace ARDOUR {
41         class AudioRegion;
42         struct PeakData;
43 };
44
45 class AudioTimeAxisView;
46 class AudioRegionGainLine;
47 class GhostRegion;
48 class AutomationTimeAxisView;
49 class RouteTimeAxisView;
50
51 class AudioRegionView : public RegionView
52 {
53   public:
54         AudioRegionView (ArdourCanvas::Container *,
55                          RouteTimeAxisView&,
56                          boost::shared_ptr<ARDOUR::AudioRegion>,
57                          double initial_samples_per_pixel,
58                          uint32_t base_color);
59
60         AudioRegionView (ArdourCanvas::Container *,
61                          RouteTimeAxisView&,
62                          boost::shared_ptr<ARDOUR::AudioRegion>,
63                          double samples_per_pixel,
64                          uint32_t base_color,
65                          bool recording,
66                          TimeAxisViewItem::Visibility);
67
68         AudioRegionView (const AudioRegionView& other, boost::shared_ptr<ARDOUR::AudioRegion>);
69
70         ~AudioRegionView ();
71
72         void init (bool wait_for_data);
73
74         boost::shared_ptr<ARDOUR::AudioRegion> audio_region() const;
75
76         void create_waves ();
77         void delete_waves ();
78
79         void set_height (double);
80         void set_samples_per_pixel (double);
81
82         void set_amplitude_above_axis (gdouble spp);
83
84         void temporarily_hide_envelope (); ///< Dangerous!
85         void unhide_envelope ();           ///< Dangerous!
86
87         void update_envelope_visibility ();
88
89         void add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *event, bool with_guard_points);
90         void remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent *event);
91
92         boost::shared_ptr<AudioRegionGainLine> get_gain_line() const { return gain_line; }
93
94         void region_changed (const PBD::PropertyChange&);
95         void envelope_active_changed ();
96
97         GhostRegion* add_ghost (TimeAxisView&);
98
99         void reset_fade_in_shape_width (boost::shared_ptr<ARDOUR::AudioRegion> ar, framecnt_t, bool drag_active = false);
100         void reset_fade_out_shape_width (boost::shared_ptr<ARDOUR::AudioRegion> ar, framecnt_t, bool drag_active = false);
101
102         framepos_t get_fade_in_shape_width ();
103         framepos_t get_fade_out_shape_width ();
104
105         void set_fade_visibility (bool);
106         void update_coverage_frames (LayerDisplay);
107
108         void update_transient(float old_pos, float new_pos);
109         void remove_transient(float pos);
110
111         void show_region_editor ();
112
113         virtual void entered ();
114         virtual void exited ();
115
116         void thaw_after_trim ();
117
118         void drag_start ();
119         void drag_end ();
120
121         void redraw_start_xfade_to (boost::shared_ptr<ARDOUR::AudioRegion>, framecnt_t, ArdourCanvas::Points&, double, double);
122         void redraw_end_xfade_to (boost::shared_ptr<ARDOUR::AudioRegion>, framecnt_t, ArdourCanvas::Points&, double, double, double);
123         void redraw_start_xfade ();
124         void redraw_end_xfade ();
125
126         void hide_xfades ();
127         void hide_start_xfade ();
128         void hide_end_xfade ();
129         void show_xfades ();
130         void show_start_xfade ();
131         void show_end_xfade ();
132
133         bool start_xfade_visible () const {
134                 return _start_xfade_visible;
135         }
136
137         bool end_xfade_visible () const {
138                 return _end_xfade_visible;
139         }
140
141   protected:
142
143         /* this constructor allows derived types
144            to specify their visibility requirements
145            to the TimeAxisViewItem parent class
146         */
147
148         enum Flags {
149                 WaveformVisible = 0x4,
150                 WaveformRectified = 0x8,
151                 WaveformLogScaled = 0x10,
152         };
153
154         std::vector<ArdourCanvas::WaveView *> waves;
155         std::vector<ArdourCanvas::WaveView *> tmp_waves; ///< see ::create_waves()
156
157         std::list<std::pair<framepos_t, ArdourCanvas::Line*> > feature_lines;
158
159         ArdourCanvas::Polygon*          sync_mark; ///< polgyon for sync position
160         ArdourCanvas::Rectangle*        fade_in_handle; ///< fade in handle, or 0
161         ArdourCanvas::Rectangle*        fade_out_handle; ///< fade out handle, or 0
162         ArdourCanvas::Rectangle*        fade_in_trim_handle; ///< fade in trim handle, or 0
163         ArdourCanvas::Rectangle*        fade_out_trim_handle; ///< fade out trim handle, or 0
164         ArdourCanvas::Rectangle*        pending_peak_data;
165
166         static Cairo::RefPtr<Cairo::Pattern> pending_peak_pattern;
167
168         ArdourCanvas::XFadeCurve* start_xfade_curve;
169         ArdourCanvas::Rectangle*  start_xfade_rect;
170         bool _start_xfade_visible;
171
172         ArdourCanvas::XFadeCurve* end_xfade_curve;
173         ArdourCanvas::Rectangle*  end_xfade_rect;
174         bool _end_xfade_visible;
175
176         boost::shared_ptr<AudioRegionGainLine> gain_line;
177
178         double _amplitude_above_axis;
179
180         void reset_fade_shapes ();
181         void reset_fade_in_shape ();
182         void reset_fade_out_shape ();
183         void fade_in_changed ();
184         void fade_out_changed ();
185         void fade_in_active_changed ();
186         void fade_out_active_changed ();
187
188         void region_resized (const PBD::PropertyChange&);
189         void region_muted ();
190         void region_scale_amplitude_changed ();
191         void region_renamed ();
192
193         void create_one_wave (uint32_t, bool);
194         void peaks_ready_handler (uint32_t);
195
196         void set_colors ();
197         void set_waveform_colors ();
198         void reset_width_dependent_items (double pixel_width);
199         void set_frame_color ();
200
201         void color_handler ();
202
203         void transients_changed();
204
205         AutomationLine::VisibleAspects automation_line_visibility () const;
206
207 private:
208         void setup_fade_handle_positions ();
209
210         void parameter_changed (std::string const &);
211         void setup_waveform_visibility ();
212         void set_some_waveform_colors (std::vector<ArdourCanvas::WaveView*>& waves_to_color);
213
214         /** A ScopedConnection for each PeaksReady callback (one per channel).  Each member
215          *  may be 0 if no connection exists.
216          */
217         std::vector<PBD::ScopedConnection*> _data_ready_connections;
218
219         /** RegionViews that we hid the xfades for at the start of the current drag;
220          *  first list is for start xfades, second list is for end xfades.
221          */
222         std::pair<std::list<AudioRegionView*>, std::list<AudioRegionView*> > _hidden_xfades;
223
224         bool trim_fade_in_drag_active;
225         bool trim_fade_out_drag_active;
226 };
227
228 #endif /* __gtk_ardour_audio_region_view_h__ */