diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-03-06 13:26:36 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-03-06 13:26:36 -0500 |
commit | 37de3e2f67b63e7f0972589c9d33df2df5be9d12 (patch) | |
tree | 238ab286491cdcc5fca7e93b1fa77de7eaf14fe4 /gtk2_ardour/hit.cc | |
parent | 7d17db09acf5d1090e3c49b58a840e69086ddcc5 (diff) |
make Hit (percussive note display item) actually draw something and fix up its coordinates
Diffstat (limited to 'gtk2_ardour/hit.cc')
-rw-r--r-- | gtk2_ardour/hit.cc | 86 |
1 files changed, 46 insertions, 40 deletions
diff --git a/gtk2_ardour/hit.cc b/gtk2_ardour/hit.cc index 4d2498a0d5..de63e187e4 100644 --- a/gtk2_ardour/hit.cc +++ b/gtk2_ardour/hit.cc @@ -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; +} |