finished merge of cairocanvas with windows and windows+cc branches
[ardour.git] / gtk2_ardour / note.cc
1 /*
2     Copyright (C) 2007 Paul Davis
3     Author: Dave Robillard
4     Author: Hans Baier
5
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "evoral/Note.hpp"
22 #include "canvas/rectangle.h"
23 #include "note.h"
24 #include "midi_region_view.h"
25 #include "public_editor.h"
26
27 using namespace ARDOUR;
28 using namespace ArdourCanvas;
29
30 Note::Note (
31         MidiRegionView&                   region,
32         Group*                            group,
33         const boost::shared_ptr<NoteType> note,
34         bool with_events
35         )
36         : NoteBase (region, with_events, note)
37 {
38         _rectangle = new ArdourCanvas::Rectangle (group);
39 #ifdef CANVAS_DEBUG
40         _rectangle->name = "note";
41 #endif
42         set_item (_rectangle);
43 }
44
45 Note::~Note ()
46 {
47         delete _rectangle;
48 }
49
50 void
51 Note::move_event (double dx, double dy)
52 {
53         _rectangle->move (Duple (dx, dy));
54
55         /* XXX */
56         // if (_text) {
57         //      _text->hide();
58         //      _text->property_x() = _text->property_x() + dx;
59         //      _text->property_y() = _text->property_y() + dy;
60         //      _text->show();
61         // }
62 }
63
64 Coord
65 Note::x0 () const
66 {
67         return _rectangle->x0 ();
68 }
69
70 Coord
71 Note::x1 () const
72 {
73         return _rectangle->x1 ();
74 }
75
76 Coord
77 Note::y0 () const
78 {
79         return _rectangle->y0 ();
80 }
81
82 Coord
83 Note::y1 () const
84 {
85         return _rectangle->y1 ();
86 }
87
88 void
89 Note::set_outline_color (uint32_t color)
90 {
91         _rectangle->set_outline_color (color);
92 }
93
94 void
95 Note::set_fill_color (uint32_t color)
96 {
97         _rectangle->set_fill_color (color);
98 }
99
100 void
101 Note::show ()
102 {
103         _rectangle->show ();
104 }
105
106 void
107 Note::hide ()
108 {
109         _rectangle->hide ();
110 }
111
112 void
113 Note::set_x0 (Coord x0)
114 {
115         _rectangle->set_x0 (x0);
116 }
117
118 void
119 Note::set_y0 (Coord y0)
120 {
121         _rectangle->set_y0 (y0);
122 }
123
124 void
125 Note::set_x1 (Coord x1)
126 {
127         _rectangle->set_x1 (x1);
128 }
129
130 void
131 Note::set_y1 (Coord y1)
132 {
133         _rectangle->set_y1 (y1);
134 }
135
136 void
137 Note::set_outline_what (int what)
138 {
139         _rectangle->set_outline_what (what);
140 }
141
142 void
143 Note::set_ignore_events (bool ignore)
144 {
145         _rectangle->set_ignore_events (ignore);
146 }