diff options
author | Sebastian Geerken <devnull@localhost> | 2013-09-12 17:58:18 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2013-09-12 17:58:18 +0200 |
commit | 280994c5459fdd99e2dc0b9f791ccfdfdb8589ad (patch) | |
tree | 8d1f08ed3c03d420077af919328ea30cc2f35e56 | |
parent | 7173e6047f26d71718502570836ef0ab158deab2 (diff) |
Some cleanup and fixes for recent changes.
-rw-r--r-- | dw/style.cc | 25 | ||||
-rw-r--r-- | dw/style.hh | 6 | ||||
-rw-r--r-- | dw/widget.cc | 33 |
3 files changed, 32 insertions, 32 deletions
diff --git a/dw/style.cc b/dw/style.cc index 089faae2..373ffa8d 100644 --- a/dw/style.cc +++ b/dw/style.cc @@ -869,7 +869,7 @@ static void drawBorderRight(View *view, Style *style, * * Used by dw::core::Widget::drawBox and dw::core::Widget::drawWidgetBox. */ -void drawBorder (View *view, Rectangle *area, +void drawBorder (View *view, Layout *layout, Rectangle *area, int x, int y, int width, int height, Style *style, bool inverse) { @@ -906,17 +906,32 @@ void drawBorder (View *view, Rectangle *area, * according to style. * * Used by dw::core::Widget::drawBox and dw::core::Widget::drawWidgetBox. + * + * "atTop" should be true, only if the area is drawn directly on the + * canvas, not on top of other areas; this is only true for the + * toplevel widget itself (not parts of its contents). Toplevel widget + * background colors are already set as viewport background color, so + * that drawing again is is not neccessary, but some time can be + * saved. + * + * Otherwise, the caller should not try to increase the performance by + * doing some tests befre; this is all done in this method. */ -void drawBackground (View *view, Rectangle *area, +void drawBackground (View *view, Layout *layout, Rectangle *area, int x, int y, int width, int height, - Style *style, bool inverse) + Style *style, bool inverse, bool atTop) { - Rectangle bgArea, intersection; - bool bgColor = style->backgroundColor != NULL; + bool bgColor = style->backgroundColor != NULL && + (!atTop || layout->getBgColor () != style->backgroundColor); bool bgImage = (style->backgroundImage != NULL && style->backgroundImage->getImgbuf() != NULL); + // Since widgets are always drawn from top to bottom, it is *not* + // necessary to draw the background if background color and image + // are not set (NULL), i. e. shining through. + if (bgColor || bgImage) { + Rectangle bgArea, intersection; bgArea.x = x + style->margin.left + style->borderWidth.left; bgArea.y = y + style->margin.top + style->borderWidth.top; bgArea.width = diff --git a/dw/style.hh b/dw/style.hh index 754b9667..187cd6be 100644 --- a/dw/style.hh +++ b/dw/style.hh @@ -717,12 +717,12 @@ public: inline ImgRenderer *getMainImgRenderer () { return imgRendererDist; } }; -void drawBorder (View *view, Rectangle *area, +void drawBorder (View *view, Layout *layout, Rectangle *area, int x, int y, int width, int height, Style *style, bool inverse); -void drawBackground (View *view, Rectangle *area, +void drawBackground (View *view, Layout *layout, Rectangle *area, int x, int y, int width, int height, - Style *style, bool inverse); + Style *style, bool inverse, bool atTop); void numtostr (int num, char *buf, int buflen, ListStyleType listStyleType); } // namespace style diff --git a/dw/widget.cc b/dw/widget.cc index 9c6fe380..648f629b 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -346,14 +346,13 @@ void Widget::drawBox (View *view, style::Style *style, Rectangle *area, viewArea.width = area->width; viewArea.height = area->height; - style::drawBorder (view, &viewArea, allocation.x + x, allocation.y + y, + style::drawBorder (view, layout, &viewArea, + allocation.x + x, allocation.y + y, width, height, style, inverse); - /** \todo Background images? */ - if (style->backgroundColor) - style::drawBackground (view, &viewArea, - allocation.x + x, allocation.y + y, width, height, - style, inverse); + style::drawBackground (view, layout, &viewArea, + allocation.x + x, allocation.y + y, width, height, + style, inverse, false); } /** @@ -370,26 +369,12 @@ void Widget::drawWidgetBox (View *view, Rectangle *area, bool inverse) viewArea.width = area->width; viewArea.height = area->height; - style::drawBorder (view, &viewArea, allocation.x, allocation.y, + style::drawBorder (view, layout, &viewArea, allocation.x, allocation.y, allocation.width, getHeight (), style, inverse); - /** \todo Adjust following comment from the old dw sources. */ - /* - * - Toplevel widget background colors are set as viewport - * background color. This is not crucial for the rendering, but - * looks a bit nicer when scrolling. Furthermore, the viewport - * does anything else in this case. - * - * - Since widgets are always drawn from top to bottom, it is - * *not* necessary to draw the background if - * widget->style->background_color is NULL (shining through). - */ - /** \todo Background images? */ - - if (style->backgroundColor && - (parent || layout->getBgColor () != style->backgroundColor)) - style::drawBackground (view, &viewArea, allocation.x, allocation.y, - allocation.width, getHeight (), style, inverse); + style::drawBackground (view, layout, &viewArea, allocation.x, allocation.y, + allocation.width, getHeight (), style, inverse, + parent == NULL); } /* |