Fix polygon redrawing -- #8148

Polygons used PolyLine::render() to render the path.
However since 7bb8ca1e76, the PolyLine path is constrained
(for automation lanes), and closed shaped polygons were not
always completely redrawn.
This commit is contained in:
Robin Gareus 2020-07-09 02:10:28 +02:00
parent 4d76388b8d
commit ce8846d13f
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -46,15 +46,23 @@ Polygon::~Polygon ()
void void
Polygon::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const Polygon::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{ {
Points::size_type npoints = _points.size();
if (npoints < 2) {
return;
}
if (_outline || _fill) { if (_outline || _fill) {
render_path (area, context); const double pixel_adjust = (_outline_width == 1.0 ? 0.5 : 0.0);
if (!_points.empty ()) { for (Points::size_type i = 0; i < npoints; i++) {
/* close path */ Duple c = item_to_window (Duple (_points[i].x, _points[i].y));
Duple p = item_to_window (Duple (_points.front().x, _points.front().y)); if (i == 0) {
context->line_to (p.x, p.y); context->move_to (c.x + pixel_adjust, c.y + pixel_adjust);
} else {
context->line_to (c.x + pixel_adjust, c.y + pixel_adjust);
}
} }
context->close_path ();
} }
if (_outline) { if (_outline) {