merge with master and fix 4 conflicts by hand
[ardour.git] / libs / canvas / canvas / curve.h
1 /*
2     Copyright (C) 2013 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #ifndef __CANVAS_CURVE_H__
20 #define __CANVAS_CURVE_H__
21
22 #include "canvas/visibility.h"
23
24 #include "canvas/interpolated_curve.h"
25 #include "canvas/poly_item.h"
26 #include "canvas/fill.h"
27
28 namespace ArdourCanvas {
29
30 class XFadeCurve;
31
32 class LIBCANVAS_API Curve : public PolyItem, public Fill, public InterpolatedCurve
33 {
34 public:
35     Curve (Group *);
36
37     enum CurveFill {
38             None,
39             Inside,
40             Outside,
41     };
42
43     void compute_bounding_box () const;
44     void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
45     void set (Points const &);
46
47     void set_points_per_segment (uint32_t n);
48
49     bool covers (Duple const &) const;
50     void set_fill_mode (CurveFill cf) { curve_fill = cf; }
51
52   private:
53     Points samples;
54     Points::size_type n_samples;
55     uint32_t points_per_segment;
56     InterpolatedCurve::SplineType curve_type;
57     CurveFill curve_fill;
58
59     void interpolate ();
60 };
61
62 }
63
64 #endif