2 Copyright (C) 2011-2013 Paul Davis
3 Author: Carl Hetherington <cth@carlh.net>
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.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "canvas/flag.h"
21 #include "canvas/text.h"
22 #include "canvas/rectangle.h"
23 #include "canvas/line.h"
26 using namespace ArdourCanvas;
28 Flag::Flag (Group* parent, Distance height, Color outline_color, Color fill_color, Duple position)
31 , _outline_color (outline_color)
32 , _fill_color (fill_color)
34 _text = new Text (this);
35 _text->set_alignment (Pango::ALIGN_CENTER);
36 _text->set_color (_outline_color);
38 _line = new Line (this);
39 _line->set_outline_color (_outline_color);
42 _rectangle = new Rectangle (this);
43 _rectangle->set_outline_color (_outline_color);
44 _rectangle->set_fill_color (_fill_color);
46 _text->raise_to_top ();
48 set_position (position);
52 Flag::set_text (string const & text)
55 boost::optional<Rect> bbox = _text->bounding_box ();
58 Duple flag_size (bbox.get().width() + 10, bbox.get().height() + 3);
60 _text->set_position (flag_size / 2);
61 _rectangle->set (Rect (0, 0, flag_size.x, flag_size.y));
65 Flag::set_height (Distance)
67 _line->set (Duple (0, 0), Duple (0, _height));
71 Flag::covers (Duple const & point) const
74 return _rectangle->covers (point);