Merge branch 'master' into cairocanvas
[ardour.git] / gtk2_ardour / hit.cc
1 /*
2     Copyright (C) 2007 Paul Davis
3     Author: Dave Robillard
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include "evoral/Note.hpp"
21 #include "canvas/polygon.h"
22 #include "midi_region_view.h"
23 #include "public_editor.h"
24 #include "utils.h"
25 #include "hit.h"
26
27 using namespace ARDOUR;
28 using namespace ArdourCanvas;
29
30 Hit::Hit (
31         MidiRegionView&                   region,
32         Group*                            group,
33         double                            /*size*/,
34         const boost::shared_ptr<NoteType> note,
35         bool with_events) 
36         : NoteBase (region, with_events, note)
37 {
38         _polygon = new Polygon (group);
39         set_item (_polygon);
40 }
41
42 void
43 Hit::move_event (double dx, double dy)
44 {
45         _polygon->move (Duple (dx, dy));
46 }
47
48 Coord
49 Hit::x0 () const
50 {
51         boost::optional<Rect> bbox = _polygon->bounding_box ();
52         assert (bbox);
53         return bbox.get().x0;
54 }
55
56 Coord
57 Hit::x1 () const
58 {
59         boost::optional<Rect> bbox = _polygon->bounding_box ();
60         assert (bbox);
61         return bbox.get().x1;
62 }
63
64 Coord
65 Hit::y0 () const
66 {
67         boost::optional<Rect> bbox = _polygon->bounding_box ();
68         assert (bbox);
69         return bbox.get().y0;
70 }
71
72 Coord
73 Hit::y1 () const
74 {
75         boost::optional<Rect> bbox = _polygon->bounding_box ();
76         assert (bbox);
77         return bbox.get().y1;
78 }
79
80 void
81 Hit::set_outline_color (uint32_t color)
82 {
83         _polygon->set_outline_color (color);
84 }
85
86 void
87 Hit::set_fill_color (uint32_t color)
88 {
89         _polygon->set_fill_color (color);
90 }
91
92 void
93 Hit::show ()
94 {
95         _polygon->show ();
96 }
97
98 void
99 Hit::hide ()
100 {
101         _polygon->hide ();
102 }
103
104 void
105 Hit::set_height (Distance /*height*/)
106 {
107         /* XXX */
108 }
109
110 void
111 Hit::set_position (Duple position)
112 {
113         _polygon->set_position (position);
114 }