2 Copyright (C) 2011-2013 Paul Davis
3 Author: Carl Hetherington <cth@carlh.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <boost/shared_ptr.hpp>
22 #include <boost/shared_array.hpp>
24 #include "pbd/properties.h"
26 #include "ardour/types.h"
28 #include <glibmm/refptr.h>
30 #include "canvas/item.h"
31 #include "canvas/fill.h"
32 #include "canvas/outline.h"
44 namespace ArdourCanvas {
46 class WaveView : virtual public Item, public Outline, public Fill
54 WaveView (Group *, boost::shared_ptr<ARDOUR::AudioRegion>);
56 void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
57 void compute_bounding_box () const;
59 void set_samples_per_pixel (double);
60 void set_height (Distance);
61 void set_channel (int);
62 void set_region_start (ARDOUR::frameoffset_t);
64 void set_fill_color (Color);
65 void set_outline_color (Color);
67 void region_resized ();
69 void set_show_zero_line (bool);
70 bool show_zero_line() const { return _show_zero; }
71 void set_zero_color (Color);
72 void set_clip_color (Color);
73 void set_amplitude (double);
74 void set_logscaled (bool);
75 void set_shape (Shape);
76 double amplitude() const { return _amplitude; }
78 /* currently missing because we don't need them (yet):
79 set_shape_independent();
80 set_logscaled_independent()
83 static void set_gradient_waveforms (bool);
84 static void set_global_logscaled (bool);
85 static void set_global_shape (Shape);
87 static bool gradient_waveforms() { return _gradient_waveforms; }
88 static bool global_logscaled() { return _global_logscaled; }
89 static Shape global_shape() { return _global_shape; }
91 #ifdef CANVAS_COMPATIBILITY
92 void*& property_gain_src () {
95 void*& property_gain_function () {
98 double& property_amplitude_above_axis () {
112 CacheEntry (WaveView const *, int, int);
123 boost::shared_array<ARDOUR::PeakData> peaks () const {
127 Cairo::RefPtr<Cairo::ImageSurface> image();
131 Coord position (Coord) const;
133 WaveView const * _wave_view;
137 boost::shared_array<ARDOUR::PeakData> _peaks;
138 Cairo::RefPtr<Cairo::ImageSurface> _image;
141 friend class CacheEntry;
142 friend class ::WaveViewTest;
144 void invalidate_whole_cache ();
145 void invalidate_image_cache ();
147 boost::shared_ptr<ARDOUR::AudioRegion> _region;
149 double _samples_per_pixel;
158 bool _shape_independent;
159 bool _logscaled_independent;
161 /** The `start' value to use for the region; we can't use the region's
162 * value as the crossfade editor needs to alter it.
164 ARDOUR::frameoffset_t _region_start;
166 mutable std::list<CacheEntry*> _cache;
168 PBD::ScopedConnection invalidation_connection;
170 static bool _gradient_waveforms;
171 static bool _global_logscaled;
172 static Shape _global_shape;
174 static PBD::Signal0<void> VisualPropertiesChanged;
176 void handle_visual_property_change ();