mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-09 07:05:43 +01:00
lollipop pixel pushing
This commit is contained in:
parent
1a4ef77222
commit
7e4a3dce01
4 changed files with 29 additions and 26 deletions
|
|
@ -50,18 +50,9 @@ public:
|
|||
void set (Duple const &, Coord, Coord);
|
||||
void set_x (Coord);
|
||||
|
||||
Coord x0 () const {
|
||||
return _points[0].x;
|
||||
}
|
||||
Coord y0 () const {
|
||||
return _points[0].y;
|
||||
}
|
||||
Coord x1 () const {
|
||||
return _points[1].x;
|
||||
}
|
||||
Coord y1 () const {
|
||||
return _points[1].y;
|
||||
}
|
||||
Coord x () const { return _points[0].x; }
|
||||
Coord y0 () const { return _points[0].y; }
|
||||
Coord y1 () const { return _points[1].y; }
|
||||
|
||||
private:
|
||||
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->line_to (p1.x, p1.y);
|
||||
/* Do not enter the circle */
|
||||
context->line_to (p1.x, p1.y + _radius);
|
||||
context->stroke ();
|
||||
|
||||
/* the circle */
|
||||
|
|
@ -125,6 +126,7 @@ Lollipop::set_length (Coord len)
|
|||
{
|
||||
if (_points[1].y != _points[0].y - len) {
|
||||
begin_change ();
|
||||
/* draw upwards */
|
||||
_points[1].y = _points[0].y - len;
|
||||
end_change ();
|
||||
}
|
||||
|
|
@ -135,14 +137,15 @@ Lollipop::set (Duple const & d, Coord l, Coord r)
|
|||
{
|
||||
begin_change ();
|
||||
|
||||
_radius = r;
|
||||
|
||||
_points[0].x = d.x;
|
||||
_points[1].x = d.x;
|
||||
|
||||
_points[0].y = d.y;
|
||||
/* Draw upwards */
|
||||
_points[1].y = _points[0].y - l;
|
||||
|
||||
_radius = r;
|
||||
|
||||
end_change ();
|
||||
}
|
||||
|
||||
|
|
@ -158,12 +161,14 @@ Lollipop::covers (Duple const & point) const
|
|||
|
||||
if (_points[0].x == _points[1].x) {
|
||||
/* line is vertical, just check x coordinate */
|
||||
return fabs (_points[0].x - p.x) <= threshold;
|
||||
}
|
||||
|
||||
if (_points[0].y == _points[1].y) {
|
||||
if (fabs (_points[0].x - p.x) <= threshold) {
|
||||
return true;
|
||||
}
|
||||
} else if (_points[0].y == _points[1].y) {
|
||||
/* 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue