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
49 WaveView (Group *, boost::shared_ptr<ARDOUR::AudioRegion>);
51 void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
52 void compute_bounding_box () const;
54 void set_samples_per_pixel (double);
55 void set_height (Distance);
56 void set_channel (int);
57 void set_region_start (ARDOUR::frameoffset_t);
59 void region_resized ();
64 #ifdef CANVAS_COMPATIBILITY
65 void*& property_gain_src () {
68 void*& property_gain_function () {
71 bool& property_rectified () {
74 bool& property_logscaled () {
77 double& property_amplitude_above_axis () {
80 Color& property_clip_color () {
83 Color& property_zero_color () {
98 CacheEntry (WaveView const *, int, int);
109 boost::shared_array<ARDOUR::PeakData> peaks () const {
113 Cairo::RefPtr<Cairo::ImageSurface> image();
117 Coord position (float) const;
119 WaveView const * _wave_view;
123 boost::shared_array<ARDOUR::PeakData> _peaks;
124 Cairo::RefPtr<Cairo::ImageSurface> _image;
127 friend class CacheEntry;
128 friend class ::WaveViewTest;
130 void invalidate_whole_cache ();
131 void invalidate_image_cache ();
133 boost::shared_ptr<ARDOUR::AudioRegion> _region;
135 double _samples_per_pixel;
138 /** The `start' value to use for the region; we can't use the region's
139 * value as the crossfade editor needs to alter it.
141 ARDOUR::frameoffset_t _region_start;
143 mutable std::list<CacheEntry*> _cache;