2 Copyright (C) 2007 Paul Davis
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.
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.
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.
20 #include "evoral/Note.hpp"
22 #include "canvas/polygon.h"
23 #include "canvas/debug.h"
27 using namespace ARDOUR;
28 using namespace ArdourCanvas;
30 Hit::Hit (MidiRegionView& region, Item* parent, double size, const boost::shared_ptr<NoteType> note, bool with_events)
31 : NoteBase (region, with_events, note)
33 _polygon = new ArdourCanvas::Polygon (parent);
34 CANVAS_DEBUG_NAME (_polygon, "note");
45 Hit::move_event (double dx, double dy)
47 Points points = _polygon->get();
49 for (Points::iterator p = points.begin(); p != points.end(); ++p) {
50 moved.push_back ((*p).translate (ArdourCanvas::Duple (dx, dy)));
52 _polygon->set (moved);
56 Hit::set_outline_color (uint32_t color)
58 _polygon->set_outline_color (color);
62 Hit::set_fill_color (uint32_t color)
64 _polygon->set_fill_color (color);
80 Hit::points(Distance height)
86 const double half_height = height/2.0;
87 p.push_back (Duple (-half_height, 0)); // left, middle
88 p.push_back (Duple (0, -half_height)); // top
89 p.push_back (Duple (+half_height, 0)); // right, middle
90 p.push_back (Duple (0, +half_height)); // bottom
96 Hit::set_height (Distance height)
98 _polygon->set (points(height));
104 return _polygon->position ();
108 Hit::set_position (Duple position)
110 _polygon->set_position (position);
117 return _polygon->position().x + _polygon->get()[0].x;
124 return _polygon->position().x + _polygon->get()[2].x;
131 return _polygon->position().y + _polygon->get()[1].y;
138 return _polygon->position().y + _polygon->get()[3].y;
142 Hit::set_ignore_events (bool ignore)
144 _polygon->set_ignore_events (ignore);