diff options
author | Sebastian Geerken <devnull@localhost> | 2013-10-04 16:00:53 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2013-10-04 16:00:53 +0200 |
commit | 8ef6e194f3c77f6f21ffbe9fea5a5961b502541e (patch) | |
tree | 119c7f156eeaabbb62e181ad76fa77c7ef5dcbc5 /dw/layout.cc | |
parent | e8f04035f76c6a31f42ec3465902854569905c1d (diff) |
Background image for view(port)s; no updates yet.
Diffstat (limited to 'dw/layout.cc')
-rw-r--r-- | dw/layout.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/dw/layout.cc b/dw/layout.cc index 3f493d8a..61ff8a38 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -189,6 +189,7 @@ Layout::Layout (Platform *platform) DBG_OBJ_CREATE (this, "DwRenderLayout"); bgColor = NULL; + bgImage = NULL; cursor = style::CURSOR_DEFAULT; canvasWidth = canvasAscent = canvasDescent = 0; @@ -228,6 +229,8 @@ Layout::~Layout () platform->removeIdle (resizeIdleId); if (bgColor) bgColor->unref (); + if (bgImage) + bgImage->unref (); if (topLevel) { Widget *w = topLevel; topLevel = NULL; @@ -508,6 +511,23 @@ void Layout::draw (View *view, Rectangle *area) { Rectangle widgetArea, intersection, widgetDrawArea; + // First of all, draw background image. (Unlike background *color*, + // this is not a feature of the views.) + if (bgImage != NULL && bgImage->getImgbuf() != NULL) + style::drawBackgroundImage (view, bgImage, bgRepeat, bgAttachment, + bgPositionX, bgPositionY, + area->x, area->y, area->width, + area->height, 0, 0, + // Reference area: maximum of canvas size and + // viewport size. + misc::max (viewportWidth + - (canvasHeightGreater ? + vScrollbarThickness : 0), + canvasWidth), + misc::max (viewportHeight + - hScrollbarThickness, + canvasAscent + canvasDescent)); + if (scrollIdleId != -1) { /* scroll is pending, defer draw until after scrollIdle() */ drawAfterScrollReq = true; @@ -650,6 +670,24 @@ void Layout::setBgColor (style::Color *color) view->setBgColor (bgColor); } +void Layout::setBgImage (style::StyleImage *bgImage, + style::BackgroundRepeat bgRepeat, + style::BackgroundAttachment bgAttachment, + style::Length bgPositionX, style::Length bgPositionY) +{ + bgImage->ref (); + + if (this->bgImage) + this->bgImage->unref (); + + this->bgImage = bgImage; + this->bgRepeat = bgRepeat; + this->bgAttachment = bgAttachment; + this->bgPositionX = bgPositionX; + this->bgPositionY = bgPositionY; +} + + void Layout::resizeIdle () { //static int calls = 0; |