1 /*
2  * Copyright (C) 2013-2014 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2014 Robin Gareus <robin@gareus.org>
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 along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef __CANVAS_CURVE_H__
21 #define __CANVAS_CURVE_H__
22 
23 #include "canvas/visibility.h"
24 
25 #include "canvas/interpolated_curve.h"
26 #include "canvas/poly_item.h"
27 #include "canvas/fill.h"
28 
29 namespace ArdourCanvas {
30 
31 class XFadeCurve;
32 
33 class LIBCANVAS_API Curve : public PolyItem, public InterpolatedCurve
34 {
35   public:
36     Curve (Canvas*);
37     Curve (Item*);
38 
39     enum CurveFill {
40 	    None,
41 	    Inside,
42 	    Outside,
43     };
44 
45     void compute_bounding_box () const;
46     void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
47     void set (Points const &);
48 
49     void set_points_per_segment (uint32_t n);
50 
51     bool covers (Duple const &) const;
set_fill_mode(CurveFill cf)52     void set_fill_mode (CurveFill cf) { curve_fill = cf; }
53 
54   private:
55     Points samples;
56     Points::size_type n_samples;
57     uint32_t points_per_segment;
58     CurveFill curve_fill;
59 
60     void interpolate ();
61 };
62 
63 }
64 
65 #endif
66