1 #include "canvas/flag.h"
2 #include "canvas/text.h"
3 #include "canvas/rectangle.h"
4 #include "canvas/line.h"
7 using namespace ArdourCanvas;
9 Flag::Flag (Group* parent, Distance height, Color outline_color, Color fill_color, Duple position)
12 , _outline_color (outline_color)
13 , _fill_color (fill_color)
15 _text = new Text (this);
16 _text->set_alignment (Pango::ALIGN_CENTER);
17 _text->set_color (_outline_color);
19 _line = new Line (this);
20 _line->set_outline_color (_outline_color);
23 _rectangle = new Rectangle (this);
24 _rectangle->set_outline_color (_outline_color);
25 _rectangle->set_fill_color (_fill_color);
27 _text->raise_to_top ();
29 set_position (position);
33 Flag::set_text (string const & text)
36 boost::optional<Rect> bbox = _text->bounding_box ();
39 Duple flag_size (bbox.get().width() + 10, bbox.get().height() + 3);
41 _text->set_position (flag_size / 2);
42 _rectangle->set (Rect (0, 0, flag_size.x, flag_size.y));
46 Flag::set_height (Distance)
48 _line->set (Duple (0, 0), Duple (0, _height));