f6497776a5063498271c92919383319c03bb1440
[ardour.git] / gtk2_ardour / canvas-note.cc
1 #include "canvas-note.h"
2 #include "midi_region_view.h"
3 #include "public_editor.h"
4 #include "evoral/Note.hpp"
5
6 using namespace ARDOUR;
7
8 namespace Gnome {
9 namespace Canvas {
10
11 CanvasNote::CanvasNote (MidiRegionView&                   region,
12                         Group&                            group,
13                         const boost::shared_ptr<NoteType> note,
14                         bool with_events)
15         : SimpleRect(group), CanvasNoteEvent(region, this, note)
16 {
17         if (with_events) {
18                 signal_event().connect (sigc::mem_fun (*this, &CanvasNote::on_event));
19         }
20 }
21
22 bool
23 CanvasNote::on_event(GdkEvent* ev)
24 {
25         if (!CanvasNoteEvent::on_event (ev)) {
26                 return _region.get_time_axis_view().editor().canvas_note_event (ev, this);
27         }
28
29         return true;
30 }
31
32 void
33 CanvasNote::move_event(double dx, double dy)
34 {
35         property_x1() = property_x1() + dx;
36         property_y1() = property_y1() + dy;
37         property_x2() = property_x2() + dx;
38         property_y2() = property_y2() + dy;
39
40         if (_text) {
41                 _text->hide();
42                 _text->property_x() = _text->property_x() + dx;
43                 _text->property_y() = _text->property_y() + dy;
44                 _text->show();
45         }
46 }
47
48
49 } // namespace Gnome
50 } // namespace Canvas