e5a7768f348d05ca1d5060220f64218b9ac74265
[ardour.git] / gtk2_ardour / canvas-program-change.cc
1 #include "canvas-program-change.h"
2 #include <iostream>
3 #include "ardour_ui.h"
4
5 using namespace Gnome::Canvas;
6 using namespace std;
7
8 CanvasProgramChange::CanvasProgramChange(
9                 MidiRegionView&                       region,
10                 Group&                                parent,
11                 boost::shared_ptr<Evoral::Event>      event,
12                 double                                height,
13                 double                                x,
14                 double                                y)
15         : Group(parent, x, y)
16         , _region(region)
17         , _event(event)
18         , _text(0)
19         , _line(0)
20         , _rect(0)
21 {
22         char pgm_str[4];
23         snprintf(pgm_str, 4, "%d", (int)event->pgm_number());
24         _text = new Text(*this, 0.0, 0.0, pgm_str);
25         _text->property_justification() = Gtk::JUSTIFY_CENTER;
26         _text->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiProgramChangeOutline.get();
27         double flagwidth  = _text->property_text_width()  + 10.0;
28         double flagheight = _text->property_text_height() + 3.0;
29         _text->property_x() = flagwidth / 2.0;
30         _text->property_y() = flagheight / 2.0;
31         _text->show();
32         _line = new SimpleLine(*this, 0.0, 0.0, 0.0, height);
33         _line->property_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiProgramChangeOutline.get();
34         _rect = new SimpleRect(*this, 0.0, 0.0, flagwidth, flagheight);
35         _rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiProgramChangeOutline.get();
36         _rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiProgramChangeFill.get();
37         _text->lower_to_bottom();
38         _text->raise(2);
39 }
40
41 CanvasProgramChange::~CanvasProgramChange()
42 {
43         delete _line;
44         delete _rect;
45         delete _text;
46 }
47