commit immediately post linking
[ardour.git] / libs / canvas / canvas / wave_view.h
1 #include <boost/shared_ptr.hpp>
2
3 #include "pbd/properties.h"
4
5 #include "ardour/types.h"
6
7 #include <glibmm/refptr.h>
8
9 #include "canvas/item.h"
10 #include "canvas/fill.h"
11 #include "canvas/outline.h"
12
13 namespace ARDOUR {
14         class AudioRegion;
15 }
16
17 namespace Gdk {
18         class Pixbuf;
19 }
20
21 class WaveViewTest;
22         
23 namespace ArdourCanvas {
24
25 class WaveView : virtual public Item, public Outline, public Fill
26 {
27 public:
28         WaveView (Group *, boost::shared_ptr<ARDOUR::AudioRegion>);
29
30         void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
31         void compute_bounding_box () const;
32
33         XMLNode* get_state () const;
34         void set_state (XMLNode const *);
35
36         void set_frames_per_pixel (double);
37         void set_height (Distance);
38         void set_channel (int);
39         void set_region_start (ARDOUR::frameoffset_t);
40         
41         void region_resized ();
42
43         /* XXX */
44         void rebuild () {}
45
46 #ifdef CANVAS_COMPATIBILITY     
47         void*& property_gain_src () {
48                 return _foo_void;
49         }
50         void*& property_gain_function () {
51                 return _foo_void;
52         }
53         bool& property_rectified () {
54                 return _foo_bool;
55         }
56         bool& property_logscaled () {
57                 return _foo_bool;
58         }
59         double& property_amplitude_above_axis () {
60                 return _foo_double;
61         }
62         Color& property_clip_color () {
63                 return _foo_uint;
64         }
65         Color& property_zero_color () {
66                 return _foo_uint;
67         }
68
69 private:
70         void* _foo_void;
71         bool _foo_bool;
72         int _foo_int;
73         Color _foo_uint;
74         double _foo_double;
75 #endif
76
77         class CacheEntry
78         {
79         public:
80                 CacheEntry (WaveView const *, int, int);
81                 ~CacheEntry ();
82
83                 int start () const {
84                         return _start;
85                 }
86
87                 int end () const {
88                         return _end;
89                 }
90
91                 ARDOUR::PeakData* peaks () const {
92                         return _peaks;
93                 }
94
95                 Glib::RefPtr<Gdk::Pixbuf> pixbuf ();
96                 void clear_pixbuf ();
97
98         private:
99                 Coord position (float) const;
100                 
101                 WaveView const * _wave_view;
102                 int _start;
103                 int _end;
104                 int _n_peaks;
105                 ARDOUR::PeakData* _peaks;
106                 Glib::RefPtr<Gdk::Pixbuf> _pixbuf;
107         };
108
109         friend class CacheEntry;
110         friend class ::WaveViewTest;
111
112         void invalidate_whole_cache ();
113         void invalidate_pixbuf_cache ();
114
115         boost::shared_ptr<ARDOUR::AudioRegion> _region;
116         int _channel;
117         double _frames_per_pixel;
118         Coord _height;
119         Color _wave_color;
120         /** The `start' value to use for the region; we can't use the region's
121          *  value as the crossfade editor needs to alter it.
122          */
123         ARDOUR::frameoffset_t _region_start;
124         
125         mutable std::list<CacheEntry*> _cache;
126 };
127
128 }