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