13
0

Canvas: modify Arc to work with layout

This commit is contained in:
Paul Davis 2020-06-10 15:49:25 -06:00
parent ad39faeb3e
commit f17160ee0e
2 changed files with 22 additions and 0 deletions

View File

@ -146,3 +146,23 @@ Arc::covers (Duple const & point) const
(angle_degs <= (_start_degrees + _arc_degrees)) &&
(radius < _radius);
}
void
Arc::size_allocate (Rect const & r)
{
begin_change ();
Item::size_allocate (r);
/* This is an arc - some section of a circle, so any difference between
* height and width cannot change what is drawn. Pick width arbitrarily
* as the "key" dimension
*/
_radius = min (r.width(),r.height()) / 2.0;
_center = Duple ((r.width()/2.), (r.height() /2.));
_bounding_box_dirty = true;
end_change ();
}

View File

@ -37,6 +37,8 @@ public:
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
void compute_bounding_box () const;
void size_allocate (Rect const & r);
void set_center (Duple const &);
void set_radius (Coord);
void set_arc (double degrees);