lollipop pixel pushing
This commit is contained in:
parent
1a4ef77222
commit
7e4a3dce01
@ -45,6 +45,8 @@
|
|||||||
|
|
||||||
using namespace Temporal;
|
using namespace Temporal;
|
||||||
|
|
||||||
|
static double const lollipop_radius = 8.0;
|
||||||
|
|
||||||
VelocityGhostRegion::VelocityGhostRegion (MidiRegionView& mrv, TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos)
|
VelocityGhostRegion::VelocityGhostRegion (MidiRegionView& mrv, TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos)
|
||||||
: MidiGhostRegion (mrv, tv, source_tv, initial_unit_pos)
|
: MidiGhostRegion (mrv, tv, source_tv, initial_unit_pos)
|
||||||
{
|
{
|
||||||
@ -59,7 +61,7 @@ VelocityGhostRegion::update_contents_height ()
|
|||||||
{
|
{
|
||||||
for (auto const & ev : events) {
|
for (auto const & ev : events) {
|
||||||
ArdourCanvas::Lollipop* l = dynamic_cast<ArdourCanvas::Lollipop*> (ev.second->item);
|
ArdourCanvas::Lollipop* l = dynamic_cast<ArdourCanvas::Lollipop*> (ev.second->item);
|
||||||
l->set_length (ev.second->event->note()->velocity() / 127.0 * base_rect->y1 ());
|
l->set (ArdourCanvas::Duple (l->x(), base_rect->y1()), ev.second->event->note()->velocity() / 127.0 * base_rect->y1 (), lollipop_radius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,11 +78,10 @@ VelocityGhostRegion::add_note (NoteBase* n)
|
|||||||
MidiStreamView* mv = midi_view();
|
MidiStreamView* mv = midi_view();
|
||||||
|
|
||||||
if (mv) {
|
if (mv) {
|
||||||
|
|
||||||
if (!n->item()->visible()) {
|
if (!n->item()->visible()) {
|
||||||
event->item->hide();
|
l->hide();
|
||||||
} else {
|
} else {
|
||||||
l->set (ArdourCanvas::Duple (n->x0(), base_rect->y1()), n->note()->velocity() / 127.0 * base_rect->y1(), 10);
|
l->set (ArdourCanvas::Duple (n->x0() - 1.0, base_rect->y1()), n->note()->velocity() / 127.0 * base_rect->y1(), lollipop_radius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +90,7 @@ void
|
|||||||
VelocityGhostRegion::update_note (GhostEvent* n)
|
VelocityGhostRegion::update_note (GhostEvent* n)
|
||||||
{
|
{
|
||||||
ArdourCanvas::Lollipop* l = dynamic_cast<ArdourCanvas::Lollipop*> (n->item);
|
ArdourCanvas::Lollipop* l = dynamic_cast<ArdourCanvas::Lollipop*> (n->item);
|
||||||
l->set (ArdourCanvas::Duple (n->event->x0(), base_rect->y1()), n->event->note()->velocity() / 127.0 * base_rect->y1(), 10);
|
l->set (ArdourCanvas::Duple (n->event->x0() - 1.0, base_rect->y1()), n->event->note()->velocity() / 127.0 * base_rect->y1(), lollipop_radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -102,4 +103,8 @@ VelocityGhostRegion::remove_note (NoteBase*)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
VelocityGhostRegion::set_colors ()
|
||||||
|
{
|
||||||
|
base_rect->set_fill_color (Gtkmm2ext::Color (0xff0000ff));
|
||||||
|
}
|
||||||
|
@ -35,6 +35,8 @@ public:
|
|||||||
void update_hit (GhostEvent* hit);
|
void update_hit (GhostEvent* hit);
|
||||||
void remove_note (NoteBase*);
|
void remove_note (NoteBase*);
|
||||||
|
|
||||||
|
void set_colors ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,18 +50,9 @@ public:
|
|||||||
void set (Duple const &, Coord, Coord);
|
void set (Duple const &, Coord, Coord);
|
||||||
void set_x (Coord);
|
void set_x (Coord);
|
||||||
|
|
||||||
Coord x0 () const {
|
Coord x () const { return _points[0].x; }
|
||||||
return _points[0].x;
|
Coord y0 () const { return _points[0].y; }
|
||||||
}
|
Coord y1 () const { return _points[1].y; }
|
||||||
Coord y0 () const {
|
|
||||||
return _points[0].y;
|
|
||||||
}
|
|
||||||
Coord x1 () const {
|
|
||||||
return _points[1].x;
|
|
||||||
}
|
|
||||||
Coord y1 () const {
|
|
||||||
return _points[1].y;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Duple _points[2];
|
Duple _points[2];
|
||||||
|
@ -73,7 +73,8 @@ Lollipop::render (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
context->move_to (p0.x, p0.y);
|
context->move_to (p0.x, p0.y);
|
||||||
context->line_to (p1.x, p1.y);
|
/* Do not enter the circle */
|
||||||
|
context->line_to (p1.x, p1.y + _radius);
|
||||||
context->stroke ();
|
context->stroke ();
|
||||||
|
|
||||||
/* the circle */
|
/* the circle */
|
||||||
@ -125,6 +126,7 @@ Lollipop::set_length (Coord len)
|
|||||||
{
|
{
|
||||||
if (_points[1].y != _points[0].y - len) {
|
if (_points[1].y != _points[0].y - len) {
|
||||||
begin_change ();
|
begin_change ();
|
||||||
|
/* draw upwards */
|
||||||
_points[1].y = _points[0].y - len;
|
_points[1].y = _points[0].y - len;
|
||||||
end_change ();
|
end_change ();
|
||||||
}
|
}
|
||||||
@ -135,14 +137,15 @@ Lollipop::set (Duple const & d, Coord l, Coord r)
|
|||||||
{
|
{
|
||||||
begin_change ();
|
begin_change ();
|
||||||
|
|
||||||
|
_radius = r;
|
||||||
|
|
||||||
_points[0].x = d.x;
|
_points[0].x = d.x;
|
||||||
_points[1].x = d.x;
|
_points[1].x = d.x;
|
||||||
|
|
||||||
_points[0].y = d.y;
|
_points[0].y = d.y;
|
||||||
|
/* Draw upwards */
|
||||||
_points[1].y = _points[0].y - l;
|
_points[1].y = _points[0].y - l;
|
||||||
|
|
||||||
_radius = r;
|
|
||||||
|
|
||||||
end_change ();
|
end_change ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,12 +161,14 @@ Lollipop::covers (Duple const & point) const
|
|||||||
|
|
||||||
if (_points[0].x == _points[1].x) {
|
if (_points[0].x == _points[1].x) {
|
||||||
/* line is vertical, just check x coordinate */
|
/* line is vertical, just check x coordinate */
|
||||||
return fabs (_points[0].x - p.x) <= threshold;
|
if (fabs (_points[0].x - p.x) <= threshold) {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (_points[0].y == _points[1].y) {
|
} else if (_points[0].y == _points[1].y) {
|
||||||
/* line is horizontal, just check y coordinate */
|
/* line is horizontal, just check y coordinate */
|
||||||
return fabs (_points[0].y - p.y) <= threshold;
|
if (fabs (_points[0].y - p.y) <= threshold) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Duple at;
|
Duple at;
|
||||||
|
Loading…
Reference in New Issue
Block a user