2 Copyright (C) 2012 Paul Davis
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.
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.
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.
22 #include "gtkmm2ext/utils.h"
23 #include "gtkmm2ext/rgb_macros.h"
25 #include "ardour_ui.h"
26 #include "canvas-flag.h"
27 #include "canvas-noevent-pixbuf.h"
28 #include "time_axis_view_item.h"
31 using namespace Gnome::Canvas;
34 CanvasFlag::CanvasFlag (MidiRegionView& region,
37 guint outline_color_rgba,
38 guint fill_color_rgba,
44 , _outline_color_rgba(outline_color_rgba)
45 , _fill_color_rgba(fill_color_rgba)
47 , name_pixbuf_width (0)
54 CanvasFlag::delete_allocated_objects()
67 CanvasFlag::set_text (const string& text)
69 delete_allocated_objects();
71 _name_pixbuf = new ArdourCanvas::NoEventPixbuf (*this);
72 name_pixbuf_width = Gtkmm2ext::pixel_width (text, TimeAxisViewItem::NAME_FONT) + 2;
74 set_color (c, _outline_color_rgba);
75 _name_pixbuf->property_pixbuf() = Gtkmm2ext::pixbuf_from_string (text, TimeAxisViewItem::NAME_FONT, name_pixbuf_width,
76 TimeAxisViewItem::NAME_HEIGHT, c);
77 _name_pixbuf->property_x() = 10.0;
78 _name_pixbuf->property_y() = 2.0;
81 double flagwidth = name_pixbuf_width + 8.0;
82 double flagheight = TimeAxisViewItem::NAME_HEIGHT + 3.0;
83 _line = new SimpleLine(*this, 0.0, 0.0, 0.0, _height);
84 _line->property_color_rgba() = _outline_color_rgba;
85 _rect = new SimpleRect(*this, 0.0, 0.0, flagwidth, flagheight);
86 _rect->property_outline_color_rgba() = _outline_color_rgba;
87 _rect->property_fill_color_rgba() = _fill_color_rgba;
89 _name_pixbuf->raise_to_top();
92 CanvasFlag::~CanvasFlag()
94 delete_allocated_objects();
98 CanvasFlag::set_height (double h)
103 _line->property_y2() = _height;