remove all XML related API from canvas. it may have been useful during development...
[ardour.git] / libs / canvas / canvas / wave_view.h
1 /*
2     Copyright (C) 2011-2013 Paul Davis
3     Author: Carl Hetherington <cth@carlh.net>
4
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.
9
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.
14
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.
18
19 */
20
21 #include <boost/shared_ptr.hpp>
22 #include <boost/shared_array.hpp>
23
24 #include "pbd/properties.h"
25
26 #include "ardour/types.h"
27
28 #include <glibmm/refptr.h>
29
30 #include "canvas/item.h"
31 #include "canvas/fill.h"
32 #include "canvas/outline.h"
33
34 namespace ARDOUR {
35         class AudioRegion;
36 }
37
38 namespace Gdk {
39         class Pixbuf;
40 }
41
42 class WaveViewTest;
43         
44 namespace ArdourCanvas {
45
46 class WaveView : virtual public Item, public Outline, public Fill
47 {
48 public:
49         WaveView (Group *, boost::shared_ptr<ARDOUR::AudioRegion>);
50
51         void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
52         void compute_bounding_box () const;
53
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);
58         
59         void region_resized ();
60
61         /* XXX */
62         void rebuild () {}
63
64 #ifdef CANVAS_COMPATIBILITY     
65         void*& property_gain_src () {
66                 return _foo_void;
67         }
68         void*& property_gain_function () {
69                 return _foo_void;
70         }
71         bool& property_rectified () {
72                 return _foo_bool;
73         }
74         bool& property_logscaled () {
75                 return _foo_bool;
76         }
77         double& property_amplitude_above_axis () {
78                 return _foo_double;
79         }
80         Color& property_clip_color () {
81                 return _foo_uint;
82         }
83         Color& property_zero_color () {
84                 return _foo_uint;
85         }
86
87 private:
88         void* _foo_void;
89         bool _foo_bool;
90         int _foo_int;
91         Color _foo_uint;
92         double _foo_double;
93 #endif
94
95         class CacheEntry
96         {
97         public:
98                 CacheEntry (WaveView const *, int, int);
99                 ~CacheEntry ();
100
101                 int start () const {
102                         return _start;
103                 }
104
105                 int end () const {
106                         return _end;
107                 }
108
109                 boost::shared_array<ARDOUR::PeakData> peaks () const {
110                         return _peaks;
111                 }
112
113                 Cairo::RefPtr<Cairo::ImageSurface> image();
114                 void clear_image ();
115
116         private:
117                 Coord position (float) const;
118                 
119                 WaveView const * _wave_view;
120                 int _start;
121                 int _end;
122                 int _n_peaks;
123                 boost::shared_array<ARDOUR::PeakData> _peaks;
124                 Cairo::RefPtr<Cairo::ImageSurface> _image;
125         };
126
127         friend class CacheEntry;
128         friend class ::WaveViewTest;
129
130         void invalidate_whole_cache ();
131         void invalidate_image_cache ();
132
133         boost::shared_ptr<ARDOUR::AudioRegion> _region;
134         int _channel;
135         double _samples_per_pixel;
136         Coord _height;
137         Color _wave_color;
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.
140          */
141         ARDOUR::frameoffset_t _region_start;
142         
143         mutable std::list<CacheEntry*> _cache;
144 };
145
146 }