mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-31 19:07:43 +01:00
lollis: potentially clip circle with a bounding parent
This commit is contained in:
parent
62bb8ccbeb
commit
a6c1a3d9d0
2 changed files with 24 additions and 2 deletions
|
|
@ -33,6 +33,7 @@ Lollipop::Lollipop (Canvas* c)
|
|||
: Item (c)
|
||||
, _radius (8)
|
||||
, _length (0)
|
||||
, bounding_parent (0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -40,9 +41,16 @@ Lollipop::Lollipop (Item* parent)
|
|||
: Item (parent)
|
||||
, _radius (8)
|
||||
, _length (0)
|
||||
, bounding_parent (0)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Lollipop::set_bounding_parent (Item* bp)
|
||||
{
|
||||
bounding_parent = bp;
|
||||
}
|
||||
|
||||
void
|
||||
Lollipop::compute_bounding_box () const
|
||||
{
|
||||
|
|
@ -67,10 +75,17 @@ Lollipop::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) cons
|
|||
/* the line */
|
||||
|
||||
context->move_to (l.x, l.y + _radius);
|
||||
context->line_to (l.x, l.y + _length - _radius);
|
||||
context->line_to (l.x, l.y + _length);
|
||||
context->stroke ();
|
||||
|
||||
/* the circle */
|
||||
/* the circle: clip to avoid weirdness at top and bottom of parent */
|
||||
|
||||
if (bounding_parent) {
|
||||
context->save ();
|
||||
Rect b (bounding_parent->item_to_window (bounding_parent->bounding_box()));
|
||||
context->rectangle (b.x0, b.y0, b.width(), b.height());
|
||||
context->clip();
|
||||
}
|
||||
|
||||
context->arc (p.x, p.y, _radius, 0.0 * (M_PI/180.0), 360.0 * (M_PI/180.0));
|
||||
|
||||
|
|
@ -88,6 +103,10 @@ Lollipop::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) cons
|
|||
context->stroke ();
|
||||
}
|
||||
|
||||
if (bounding_parent) {
|
||||
context->restore ();
|
||||
}
|
||||
|
||||
render_children (area, context);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue