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 ();
70 void set_show_zero_line (bool);
71 bool show_zero_line() const { return _show_zero; }
72 void set_zero_color (Color);
73 void set_clip_color (Color);
74 void set_logscaled (bool);
75 void set_gradient_depth (double);
76 double gradient_depth() const { return _gradient_depth; }
77 void set_shape (Shape);
80 /* currently missing because we don't need them (yet):
81 set_shape_independent();
82 set_logscaled_independent()
85 static void set_global_gradient_depth (double);
86 static void set_global_logscaled (bool);
87 static void set_global_shape (Shape);
89 static double global_gradient_depth() { return _global_gradient_depth; }
90 static bool global_logscaled() { return _global_logscaled; }
91 static Shape global_shape() { return _global_shape; }
93 void set_amplitude_above_axis (double v);
94 double amplitude_above_axis () const { return _amplitude_above_axis; }
96 #ifdef CANVAS_COMPATIBILITY
97 void*& property_gain_src () {
100 void*& property_gain_function () {
108 /** A cached, pre-rendered image of some section of a waveform.
110 It spans a range given relative to the start of the source
111 of the waveform data, so a range from N..M corresponds
112 to the sample range N..M within the source.
114 Invalidated by a changes to:
125 CacheEntry (WaveView const *, double, double, int);
128 double start () const {
132 double end () const {
136 boost::shared_array<ARDOUR::PeakData> peaks () const {
140 Cairo::RefPtr<Cairo::ImageSurface> image();
144 Coord position (Coord) const;
146 WaveView const * _wave_view;
152 boost::shared_array<ARDOUR::PeakData> _peaks;
153 Cairo::RefPtr<Cairo::ImageSurface> _image;
156 friend class CacheEntry;
157 friend class ::WaveViewTest;
159 void invalidate_whole_cache ();
160 void invalidate_image_cache ();
162 boost::shared_ptr<ARDOUR::AudioRegion> _region;
164 double _samples_per_pixel;
172 double _gradient_depth;
173 bool _shape_independent;
174 bool _logscaled_independent;
175 bool _gradient_depth_independent;
176 double _amplitude_above_axis;
178 /** The `start' value to use for the region; we can't use the region's
179 * value as the crossfade editor needs to alter it.
181 ARDOUR::frameoffset_t _region_start;
183 mutable std::list<CacheEntry*> _cache;
185 PBD::ScopedConnection invalidation_connection;
187 static double _global_gradient_depth;
188 static bool _global_logscaled;
189 static Shape _global_shape;
191 static PBD::Signal0<void> VisualPropertiesChanged;
193 void handle_visual_property_change ();