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_gradient_depth (double);
76 double gradient_depth() const { return _gradient_depth; }
77 void set_shape (Shape);
78 double amplitude() const { return _amplitude; }
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 #ifdef CANVAS_COMPATIBILITY
94 void*& property_gain_src () {
97 void*& property_gain_function () {
100 double& property_amplitude_above_axis () {
114 CacheEntry (WaveView const *, int, int);
125 boost::shared_array<ARDOUR::PeakData> peaks () const {
129 Cairo::RefPtr<Cairo::ImageSurface> image();
133 Coord position (Coord) const;
135 WaveView const * _wave_view;
139 boost::shared_array<ARDOUR::PeakData> _peaks;
140 Cairo::RefPtr<Cairo::ImageSurface> _image;
143 friend class CacheEntry;
144 friend class ::WaveViewTest;
146 void invalidate_whole_cache ();
147 void invalidate_image_cache ();
149 boost::shared_ptr<ARDOUR::AudioRegion> _region;
151 double _samples_per_pixel;
159 double _gradient_depth;
161 bool _shape_independent;
162 bool _logscaled_independent;
163 bool _gradient_depth_independent;
165 /** The `start' value to use for the region; we can't use the region's
166 * value as the crossfade editor needs to alter it.
168 ARDOUR::frameoffset_t _region_start;
170 mutable std::list<CacheEntry*> _cache;
172 PBD::ScopedConnection invalidation_connection;
174 static double _global_gradient_depth;
175 static bool _global_logscaled;
176 static Shape _global_shape;
178 static PBD::Signal0<void> VisualPropertiesChanged;
180 void handle_visual_property_change ();