summaryrefslogtreecommitdiff
path: root/libs/canvas/polygon.cc
blob: b89a7ca8802bf587008fd7ed2c8b72ed989e1cf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "pbd/xml++.h"
#include "canvas/polygon.h"

using namespace ArdourCanvas;

Polygon::Polygon (Group* parent)
	: Item (parent)
	, PolyItem (parent)
	, Fill (parent)
{

}

void
Polygon::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{
	if (_outline) {
		setup_outline_context (context);
		render_path (area, context);
		
		if (!_points.empty ()) {
			context->move_to (_points.front().x, _points.front().y);
		}

		context->stroke_preserve ();
	}

	if (_fill) {
		setup_fill_context (context);
		context->fill ();
	}
}

XMLNode *
Polygon::get_state () const
{
	XMLNode* node = new XMLNode ("Polygon");
#ifdef CANVAS_DEBUG
	if (!name.empty ()) {
		node->add_property ("name", name);
	}
#endif	
	add_poly_item_state (node);
	add_outline_state (node);
	add_fill_state (node);
	return node;
}


void
Polygon::set_state (XMLNode const * node)
{
	set_poly_item_state (node);
	set_outline_state (node);
	set_fill_state (node);
}