summaryrefslogtreecommitdiff
path: root/gtk2_ardour/canvas-note.cc
blob: f6497776a5063498271c92919383319c03bb1440 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "canvas-note.h"
#include "midi_region_view.h"
#include "public_editor.h"
#include "evoral/Note.hpp"

using namespace ARDOUR;

namespace Gnome {
namespace Canvas {

CanvasNote::CanvasNote (MidiRegionView&                   region,
                        Group&                            group,
                        const boost::shared_ptr<NoteType> note,
                        bool with_events)
	: SimpleRect(group), CanvasNoteEvent(region, this, note)
{
	if (with_events) {
		signal_event().connect (sigc::mem_fun (*this, &CanvasNote::on_event));
	}
}

bool
CanvasNote::on_event(GdkEvent* ev)
{
	if (!CanvasNoteEvent::on_event (ev)) {
		return _region.get_time_axis_view().editor().canvas_note_event (ev, this);
	}

	return true;
}

void
CanvasNote::move_event(double dx, double dy)
{
	property_x1() = property_x1() + dx;
	property_y1() = property_y1() + dy;
	property_x2() = property_x2() + dx;
	property_y2() = property_y2() + dy;

	if (_text) {
		_text->hide();
		_text->property_x() = _text->property_x() + dx;
		_text->property_y() = _text->property_y() + dy;
		_text->show();
	}
}


} // namespace Gnome
} // namespace Canvas