5883dd5b86f97337c6b1ae6efcb864ccb10b59ca
[ardour.git] / gtk2_ardour / canvas-program-change.cc
1 #include "canvas-program-change.h"
2 #include <iostream>
3
4 using namespace ArdourCanvas;
5 using namespace std;
6
7 CanvasProgramChange::CanvasProgramChange(
8                 MidiRegionView&                       region,
9                 Group&                                parent,
10                 boost::shared_ptr<MIDI::Event>        event,
11                 double                                height,
12                 double                                x,
13                 double                                y)
14         : Group(parent, x, y),
15           _region(region),
16           _event(event),
17           _text(0),
18           _line(0),
19           _rect(0),
20           _widget(0)
21 {
22         _text = new Text(*this);
23         ostringstream pgm(ios::ate);
24         pgm << int(event->pgm_number());
25         _text->property_text() = pgm.str();
26         _text->property_justification() = Gtk::JUSTIFY_CENTER;
27         _text->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiProgramChangeOutline.get();
28         double flagwidth  = _text->property_text_width()  + 10.0;
29         double flagheight = _text->property_text_height() + 3.0;
30         _text->property_x() = flagwidth / 2.0;
31         _text->property_y() = flagheight / 2.0;
32         _text->show();
33         _line = new SimpleLine(*this, 0.0, 0.0, 0.0, height);
34         _line->property_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiProgramChangeOutline.get();
35         _rect = new SimpleRect(*this, 0.0, 0.0, flagwidth, flagheight);
36         _rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiProgramChangeOutline.get();
37         _rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiProgramChangeFill.get();
38         _text->lower_to_bottom();
39         _text->raise(2);
40         assert(_widget == 0);
41         assert(_text != 0);
42         assert(_line != 0);
43         assert(_rect != 0);
44 }
45
46 CanvasProgramChange::~CanvasProgramChange()
47 {
48         if(_line)
49                 delete _line;
50         if(_rect)
51                 delete _rect;
52         if(_text)
53                 delete _text;
54         if(_widget)
55                 delete _widget;
56 }
57
58