2 * Copyright (C) 2013-2017 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2014 David Robillard <d@drobilla.net>
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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "temporal/beats.h"
22 #include "evoral/Note.hpp"
24 #include "canvas/polygon.h"
25 #include "canvas/debug.h"
29 using namespace ARDOUR;
30 using namespace ArdourCanvas;
32 Hit::Hit (MidiRegionView& region, Item* parent, double size, const boost::shared_ptr<NoteType> note, bool with_events)
33 : NoteBase (region, with_events, note)
35 _polygon = new ArdourCanvas::Polygon (parent);
36 CANVAS_DEBUG_NAME (_polygon, "note");
47 Hit::move_event (double dx, double dy)
49 Points points = _polygon->get();
51 for (Points::iterator p = points.begin(); p != points.end(); ++p) {
52 moved.push_back ((*p).translate (ArdourCanvas::Duple (dx, dy)));
54 _polygon->set (moved);
58 Hit::set_outline_color (uint32_t color)
60 _polygon->set_outline_color (color);
64 Hit::set_fill_color (uint32_t color)
66 _polygon->set_fill_color (color);
82 Hit::points(Distance height)
88 const double half_height = height/2.0;
89 p.push_back (Duple (-half_height, 0)); // left, middle
90 p.push_back (Duple (0, -half_height)); // top
91 p.push_back (Duple (+half_height, 0)); // right, middle
92 p.push_back (Duple (0, +half_height)); // bottom
98 Hit::set_height (Distance height)
100 _polygon->set (points(height));
106 return _polygon->position ();
110 Hit::set_position (Duple position)
112 _polygon->set_position (position);
119 return _polygon->position().x + _polygon->get()[0].x;
126 return _polygon->position().x + _polygon->get()[2].x;
133 return _polygon->position().y + _polygon->get()[1].y;
140 return _polygon->position().y + _polygon->get()[3].y;
144 Hit::set_ignore_events (bool ignore)
146 _polygon->set_ignore_events (ignore);