When sounding notes on selection / note movements, play the note for as long as the...
[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         bool r = true;
26
27         if (!CanvasNoteEvent::on_event (ev)) {
28                 r = _region.get_time_axis_view().editor().canvas_note_event (ev, this);
29         }
30
31         if (ev->type == GDK_BUTTON_RELEASE) {
32                 _region.note_button_release ();
33         }
34         
35         return r;
36 }
37
38 void
39 CanvasNote::move_event(double dx, double dy)
40 {
41         property_x1() = property_x1() + dx;
42         property_y1() = property_y1() + dy;
43         property_x2() = property_x2() + dx;
44         property_y2() = property_y2() + dy;
45
46         if (_text) {
47                 _text->hide();
48                 _text->property_x() = _text->property_x() + dx;
49                 _text->property_y() = _text->property_y() + dy;
50                 _text->show();
51         }
52 }
53
54
55 } // namespace Gnome
56 } // namespace Canvas