b89a7ca8802bf587008fd7ed2c8b72ed989e1cf8
[ardour.git] / libs / canvas / polygon.cc
1 #include "pbd/xml++.h"
2 #include "canvas/polygon.h"
3
4 using namespace ArdourCanvas;
5
6 Polygon::Polygon (Group* parent)
7         : Item (parent)
8         , PolyItem (parent)
9         , Fill (parent)
10 {
11
12 }
13
14 void
15 Polygon::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
16 {
17         if (_outline) {
18                 setup_outline_context (context);
19                 render_path (area, context);
20                 
21                 if (!_points.empty ()) {
22                         context->move_to (_points.front().x, _points.front().y);
23                 }
24
25                 context->stroke_preserve ();
26         }
27
28         if (_fill) {
29                 setup_fill_context (context);
30                 context->fill ();
31         }
32 }
33
34 XMLNode *
35 Polygon::get_state () const
36 {
37         XMLNode* node = new XMLNode ("Polygon");
38 #ifdef CANVAS_DEBUG
39         if (!name.empty ()) {
40                 node->add_property ("name", name);
41         }
42 #endif  
43         add_poly_item_state (node);
44         add_outline_state (node);
45         add_fill_state (node);
46         return node;
47 }
48
49
50 void
51 Polygon::set_state (XMLNode const * node)
52 {
53         set_poly_item_state (node);
54         set_outline_state (node);
55         set_fill_state (node);
56 }