diff options
author | Sebastian Geerken <devnull@localhost> | 2013-10-04 22:25:52 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2013-10-04 22:25:52 +0200 |
commit | 79c24d20a6dfa62e72085a45a29e148ad86d7009 (patch) | |
tree | 70e34594aa812dae8a0b2fba2a36eab72f40a891 | |
parent | 727dd780fddcf423400df4283c1587618ced0ed0 (diff) |
Background images for view(port)s are now updated.
-rw-r--r-- | dw/layout.cc | 79 | ||||
-rw-r--r-- | dw/layout.hh | 21 |
2 files changed, 100 insertions, 0 deletions
diff --git a/dw/layout.cc b/dw/layout.cc index 61ff8a38..7fa93046 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -32,6 +32,65 @@ using namespace lout::object; namespace dw { namespace core { +bool Layout::LayoutImgRenderer::readyToDraw () +{ + return true; +} + +void Layout::LayoutImgRenderer::getPaddingArea (int *x, int *y, int *width, + int *height) +{ + // TODO Actually not padding area, but visible area? + getRefArea (x, y, width, height); +} + +void Layout::LayoutImgRenderer::getRefArea (int *xRef, int *yRef, int *widthRef, + int *heightRef) +{ + *xRef = 0; + *yRef = 0; + *widthRef = misc::max (layout->viewportWidth + - (layout->canvasHeightGreater ? + layout->vScrollbarThickness : 0), + layout->canvasWidth); + *heightRef = misc::max (layout->viewportHeight + - layout->hScrollbarThickness, + layout->canvasAscent + layout->canvasDescent); +} + +style::StyleImage *Layout::LayoutImgRenderer::getBackgroundImage () +{ + return layout->bgImage; +} + +style::BackgroundRepeat Layout::LayoutImgRenderer::getBackgroundRepeat () +{ + return layout->bgRepeat; +} + +style::BackgroundAttachment + Layout::LayoutImgRenderer::getBackgroundAttachment () +{ + return layout->bgAttachment; +} + +style::Length Layout::LayoutImgRenderer::getBackgroundPositionX () +{ + return layout->bgPositionX; +} + +style::Length Layout::LayoutImgRenderer::getBackgroundPositionY () +{ + return layout->bgPositionY; +} + +void Layout::LayoutImgRenderer::draw (int x, int y, int width, int height) +{ + layout->queueDraw (x, y, width, height); +} + +// ---------------------------------------------------------------------- + void Layout::Receiver::canvasSizeChanged (int width, int ascent, int descent) { } @@ -217,6 +276,8 @@ Layout::Layout (Platform *platform) platform->setLayout (this); selectionState.setLayout(this); + + layoutImgRenderer = NULL; } Layout::~Layout () @@ -240,6 +301,12 @@ Layout::~Layout () delete view; delete anchorsTable; delete textZone; + + if (layoutImgRenderer) { + if (bgImage) + bgImage->removeExternalImgRenderer (layoutImgRenderer); + delete layoutImgRenderer; + } } void Layout::addWidget (Widget *widget) @@ -675,6 +742,9 @@ void Layout::setBgImage (style::StyleImage *bgImage, style::BackgroundAttachment bgAttachment, style::Length bgPositionX, style::Length bgPositionY) { + if (layoutImgRenderer && this->bgImage) + this->bgImage->removeExternalImgRenderer (layoutImgRenderer); + bgImage->ref (); if (this->bgImage) @@ -685,6 +755,15 @@ void Layout::setBgImage (style::StyleImage *bgImage, this->bgAttachment = bgAttachment; this->bgPositionX = bgPositionX; this->bgPositionY = bgPositionY; + + if (bgImage) { + // Create instance of LayoutImgRenderer when needed. Until this + // layout is deleted, "layoutImgRenderer" will be kept, since it + // is not specific to the style, but only to this layout. + if (layoutImgRenderer == NULL) + layoutImgRenderer = new LayoutImgRenderer (this); + bgImage->putExternalImgRenderer (layoutImgRenderer); + } } diff --git a/dw/layout.hh b/dw/layout.hh index 9687a2da..abc763b1 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -17,6 +17,27 @@ class Layout: public lout::object::Object { friend class Widget; +private: + class LayoutImgRenderer: public style::StyleImage::ExternalImgRenderer + { + Layout *layout; + + public: + LayoutImgRenderer (Layout *layout) { this->layout = layout; } + + bool readyToDraw (); + void getPaddingArea (int *x, int *y, int *width, int *height); + void getRefArea (int *xRef, int *yRef, int *widthRef, int *heightRef); + style::StyleImage *getBackgroundImage (); + style::BackgroundRepeat getBackgroundRepeat (); + style::BackgroundAttachment getBackgroundAttachment (); + style::Length getBackgroundPositionX (); + style::Length getBackgroundPositionY (); + void draw (int x, int y, int width, int height); + }; + + LayoutImgRenderer *layoutImgRenderer; + public: /** * \brief Receiver interface different signals. |