various fixes to MidiRegionView selection handling, key handling, drawing of ghost...
[ardour2.git] / gtk2_ardour / canvas-flag.cc
blob30299641ede5eecbf156ac72b303f651c5d2d47d
1 #include "canvas-flag.h"
2 #include <iostream>
3 #include "ardour_ui.h"
5 using namespace Gnome::Canvas;
6 using namespace std;
8 CanvasFlag::CanvasFlag (MidiRegionView& region,
9 Group& parent,
10 double height,
11 guint outline_color_rgba,
12 guint fill_color_rgba,
13 double x,
14 double y)
15 : Group(parent, x, y)
16 , _text(0)
17 , _height(height)
18 , _outline_color_rgba(outline_color_rgba)
19 , _fill_color_rgba(fill_color_rgba)
20 , _region(region)
21 , _line(0)
22 , _rect(0)
24 /* XXX this connection is needed if ::on_event() is changed to actually do anything */
25 signal_event().connect (sigc::mem_fun (*this, &CanvasFlag::on_event));
28 void
29 CanvasFlag::delete_allocated_objects()
31 delete _text;
32 _text = 0;
34 delete _line;
35 _line = 0;
37 delete _rect;
38 _rect = 0;
41 void
42 CanvasFlag::set_text(const string& a_text)
44 delete_allocated_objects();
46 _text = new Text (*this, 0.0, 0.0, a_text);
47 _text->property_justification() = Gtk::JUSTIFY_CENTER;
48 _text->property_fill_color_rgba() = _outline_color_rgba;
49 double flagwidth = _text->property_text_width() + 10.0;
50 double flagheight = _text->property_text_height() + 3.0;
51 _text->property_x() = flagwidth / 2.0;
52 _text->property_y() = flagheight / 2.0;
53 _text->show();
54 _line = new SimpleLine(*this, 0.0, 0.0, 0.0, _height);
55 _line->property_color_rgba() = _outline_color_rgba;
56 _rect = new SimpleRect(*this, 0.0, 0.0, flagwidth, flagheight);
57 _rect->property_outline_color_rgba() = _outline_color_rgba;
58 _rect->property_fill_color_rgba() = _fill_color_rgba;
59 _text->raise_to_top();
61 /* XXX these two connections are needed if ::on_event() is changed to actually do anything */
62 //_rect->signal_event().connect (sigc::mem_fun (*this, &CanvasFlag::on_event));
63 //_text->signal_event().connect (sigc::mem_fun (*this, &CanvasFlag::on_event));
66 CanvasFlag::~CanvasFlag()
68 delete_allocated_objects();
71 bool
72 CanvasFlag::on_event(GdkEvent* /*ev*/)
74 /* XXX if you change this function to actually do anything, be sure
75 to fix the connections commented out elsewhere in this file.
77 return false;
80 void
81 CanvasFlag::set_height (double h)
83 _height = h;
85 if (_line) {
86 _line->property_y2() = _height;