make Hit (percussive note display item) actually draw something and fix up its coordinates
This commit is contained in:
parent
7d17db09ac
commit
37de3e2f67
@ -18,7 +18,10 @@
|
||||
*/
|
||||
|
||||
#include "evoral/Note.hpp"
|
||||
|
||||
#include "canvas/polygon.h"
|
||||
#include "canvas/debug.h"
|
||||
|
||||
#include "midi_region_view.h"
|
||||
#include "public_editor.h"
|
||||
#include "utils.h"
|
||||
@ -27,16 +30,13 @@
|
||||
using namespace ARDOUR;
|
||||
using namespace ArdourCanvas;
|
||||
|
||||
Hit::Hit (
|
||||
MidiRegionView& region,
|
||||
Group* group,
|
||||
double /*size*/,
|
||||
const boost::shared_ptr<NoteType> note,
|
||||
bool with_events)
|
||||
Hit::Hit (MidiRegionView& region, Group* group, double size, const boost::shared_ptr<NoteType> note, bool with_events)
|
||||
: NoteBase (region, with_events, note)
|
||||
{
|
||||
_polygon = new ArdourCanvas::Polygon (group);
|
||||
CANVAS_DEBUG_NAME (_polygon, "note");
|
||||
set_item (_polygon);
|
||||
set_height (size);
|
||||
}
|
||||
|
||||
void
|
||||
@ -45,38 +45,6 @@ Hit::move_event (double dx, double dy)
|
||||
_polygon->move (Duple (dx, dy));
|
||||
}
|
||||
|
||||
Coord
|
||||
Hit::x0 () const
|
||||
{
|
||||
boost::optional<ArdourCanvas::Rect> bbox = _polygon->bounding_box ();
|
||||
assert (bbox);
|
||||
return bbox.get().x0;
|
||||
}
|
||||
|
||||
Coord
|
||||
Hit::x1 () const
|
||||
{
|
||||
boost::optional<ArdourCanvas::Rect> bbox = _polygon->bounding_box ();
|
||||
assert (bbox);
|
||||
return bbox.get().x1;
|
||||
}
|
||||
|
||||
Coord
|
||||
Hit::y0 () const
|
||||
{
|
||||
boost::optional<ArdourCanvas::Rect> bbox = _polygon->bounding_box ();
|
||||
assert (bbox);
|
||||
return bbox.get().y0;
|
||||
}
|
||||
|
||||
Coord
|
||||
Hit::y1 () const
|
||||
{
|
||||
boost::optional<ArdourCanvas::Rect> bbox = _polygon->bounding_box ();
|
||||
assert (bbox);
|
||||
return bbox.get().y1;
|
||||
}
|
||||
|
||||
void
|
||||
Hit::set_outline_color (uint32_t color)
|
||||
{
|
||||
@ -102,9 +70,19 @@ Hit::hide ()
|
||||
}
|
||||
|
||||
void
|
||||
Hit::set_height (Distance /*height*/)
|
||||
Hit::set_height (Distance height)
|
||||
{
|
||||
/* XXX */
|
||||
/* draw a diamond */
|
||||
|
||||
Points p;
|
||||
|
||||
const double half_height = height/2.0;
|
||||
p.push_back (Duple (-half_height, 0)); // left, middle
|
||||
p.push_back (Duple (0, -half_height)); // top
|
||||
p.push_back (Duple (+half_height, 0)); // right, middle
|
||||
p.push_back (Duple (0, +half_height)); // bottom
|
||||
|
||||
_polygon->set (p);
|
||||
}
|
||||
|
||||
void
|
||||
@ -112,3 +90,31 @@ Hit::set_position (Duple position)
|
||||
{
|
||||
_polygon->set_position (position);
|
||||
}
|
||||
|
||||
Coord
|
||||
Hit::x0 () const
|
||||
{
|
||||
/* left vertex */
|
||||
return _polygon->get()[0].x;
|
||||
}
|
||||
|
||||
Coord
|
||||
Hit::x1 () const
|
||||
{
|
||||
/* right vertex */
|
||||
return _polygon->get()[2].x;
|
||||
}
|
||||
|
||||
Coord
|
||||
Hit::y0 () const
|
||||
{
|
||||
/* top vertex */
|
||||
return _polygon->get()[1].y;
|
||||
}
|
||||
|
||||
Coord
|
||||
Hit::y1 () const
|
||||
{
|
||||
/* bottom vertex */
|
||||
return _polygon->get()[3].y;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user