Mercurial > dillo_port1.3
changeset 1290:b91adf535e17
improve FltkViewBase::drawRectangle
* allow negative width / height
* clip rectangle to size of the view. This avoids issues with 16 bit X11
coordinates overflowing and seems to improve performance.
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> |
---|---|
date | Tue, 01 Sep 2009 20:21:55 +0200 |
parents | b317bfe7cf6f |
children | 63837a774687 |
files | dw/fltkviewbase.cc dw/fltkviewbase.hh |
diffstat | 2 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/dw/fltkviewbase.cc Mon Aug 31 22:09:34 2009 +0200 +++ b/dw/fltkviewbase.cc Tue Sep 01 20:21:55 2009 +0200 @@ -367,10 +367,23 @@ int x, int y, int width, int height) { setcolor(((FltkColor*)color)->colors[shading]); + if (width < 0) { + x += width; + width = -width; + } + if (height < 0) { + y += height; + height = -height; + } + int x1 = translateCanvasXToViewX (x); int y1 = translateCanvasYToViewY (y); int x2 = translateCanvasXToViewX (x + width); int y2 = translateCanvasYToViewY (y + height); + + clipPoint (&x1, &y1); + clipPoint (&x2, &y2); + ::fltk::Rectangle rect (x1, y1, x2 - x1, y2 - y1); if (filled) fillrect (rect);
--- a/dw/fltkviewbase.hh Mon Aug 31 22:09:34 2009 +0200 +++ b/dw/fltkviewbase.hh Tue Sep 01 20:21:55 2009 +0200 @@ -25,6 +25,16 @@ void draw (const core::Rectangle *rect, DrawType type); void drawChildWidgets (); + inline void clipPoint (int *x, int *y) { + if (*x < 0) + *x = 0; + if (*x > w ()) + *x = w (); + if (*y < 0) + *y = 0; + if (*y > h ()) + *y = h (); + } protected: core::Layout *theLayout;