2 Copyright (C) 2001-2006 Paul Davis
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.
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.
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.
19 #ifndef __gtk_ardour_audio_region_view_h__
20 #define __gtk_ardour_audio_region_view_h__
24 #include <libgnomecanvasmm.h>
25 #include <libgnomecanvasmm/polygon.h>
26 #include <sigc++/signal.h>
27 #include <ardour/audioregion.h>
29 #include "region_view.h"
30 #include "route_time_axis.h"
31 #include "time_axis_view_item.h"
32 #include "automation_line.h"
43 class AudioTimeAxisView;
44 class AudioRegionGainLine;
45 class AudioRegionEditor;
47 class AutomationTimeAxisView;
49 class AudioRegionView : public RegionView
52 AudioRegionView (ArdourCanvas::Group *,
54 boost::shared_ptr<ARDOUR::AudioRegion>,
55 double initial_samples_per_unit,
56 Gdk::Color& basic_color);
58 AudioRegionView (const AudioRegionView& other);
62 virtual void init (Gdk::Color& base_color, bool wait_for_data = false);
64 boost::shared_ptr<ARDOUR::AudioRegion> audio_region() const;
66 void set_y_position_and_height (double, double);
67 void set_samples_per_unit (double);
69 void set_amplitude_above_axis (gdouble spp);
71 void temporarily_hide_envelope (); ///< Dangerous!
72 void unhide_envelope (); ///< Dangerous!
74 void set_envelope_visible (bool);
75 void set_waveform_visible (bool yn);
76 void set_waveform_shape (WaveformShape);
77 void set_waveform_scale (WaveformScale);
79 bool waveform_rectified() const { return _flags & WaveformRectified; }
80 bool waveform_logscaled() const { return _flags & WaveformLogScaled; }
81 bool waveform_visible() const { return _flags & WaveformVisible; }
82 bool envelope_visible() const { return _flags & EnvelopeVisible; }
84 void show_region_editor ();
86 void add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *event);
87 void remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent *event);
89 AudioRegionGainLine* get_gain_line() const { return gain_line; }
91 void region_changed (ARDOUR::Change);
92 void envelope_active_changed ();
94 GhostRegion* add_ghost (AutomationTimeAxisView&);
96 void reset_fade_in_shape_width (nframes_t);
97 void reset_fade_out_shape_width (nframes_t);
99 virtual void entered ();
100 virtual void exited ();
104 /* this constructor allows derived types
105 to specify their visibility requirements
106 to the TimeAxisViewItem parent class
109 AudioRegionView (ArdourCanvas::Group *,
111 boost::shared_ptr<ARDOUR::AudioRegion>,
112 double samples_per_unit,
113 Gdk::Color& basic_color,
114 TimeAxisViewItem::Visibility);
117 EnvelopeVisible = 0x1,
118 WaveformVisible = 0x4,
119 WaveformRectified = 0x8,
120 WaveformLogScaled = 0x10,
123 vector<ArdourCanvas::WaveView *> waves;
124 vector<ArdourCanvas::WaveView *> tmp_waves; ///< see ::create_waves()
125 ArdourCanvas::Polygon* sync_mark; ///< polgyon for sync position
126 ArdourCanvas::SimpleLine* zero_line;
127 ArdourCanvas::Polygon* fade_in_shape;
128 ArdourCanvas::Polygon* fade_out_shape;
129 ArdourCanvas::SimpleRect* fade_in_handle;
130 ArdourCanvas::SimpleRect* fade_out_handle;
132 AudioRegionGainLine * gain_line;
134 double _amplitude_above_axis;
141 void reset_fade_shapes ();
142 void reset_fade_in_shape ();
143 void reset_fade_out_shape ();
144 void fade_in_changed ();
145 void fade_out_changed ();
146 void fade_in_active_changed ();
147 void fade_out_active_changed ();
149 void region_resized (ARDOUR::Change);
150 void region_moved (void *);
151 void region_muted ();
152 void region_scale_amplitude_changed ();
153 void region_renamed ();
155 void create_waves ();
156 void create_one_wave (uint32_t, bool);
157 void manage_zero_line ();
158 void peaks_ready_handler (uint32_t);
159 void set_flags (XMLNode *);
163 void compute_colors (Gdk::Color&);
164 void reset_width_dependent_items (double pixel_width);
165 void set_waveview_data_src();
167 void color_handler (ColorID, uint32_t);
169 vector<GnomeCanvasWaveViewCache*> wave_caches;
173 void setup_fade_handle_positions ();
176 #endif /* __gtk_ardour_audio_region_view_h__ */