diff --git a/changes.txt b/changes.txt index 327e8549..40f1ddcc 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,6 @@ -------------------------- Changes in 1.9 (not yet released) +- Add IGUIImage::setDrawBackground to allow disabling background drawing even when no texture is set. - Add gui event EGET_ELEMENT_REMOVED. - Fix: IGUIContextMenu now raises sub-menu when they would otherwise be displayed below bottom-border of root gui element. - Prevent initializing/quitting SDL several times when using more than one Irrlicht device. diff --git a/include/IGUIImage.h b/include/IGUIImage.h index c7977034..c99de0dd 100644 --- a/include/IGUIImage.h +++ b/include/IGUIImage.h @@ -15,7 +15,6 @@ namespace video } namespace gui { - //! GUI element displaying an image. class IGUIImage : public IGUIElement { @@ -71,6 +70,14 @@ namespace gui //! Get drawing-area restrictions. virtual core::rect getDrawBounds() const = 0; + + //! Sets whether to draw a background color (EGDC_3D_DARK_SHADOW) when no texture is set + /** By default it's enabled */ + virtual void setDrawBackground(bool draw) = 0; + + //! Checks if a background is drawn when no texture is set + /** \return true if background drawing is enabled, false otherwise */ + virtual bool isDrawBackgroundEnabled() const = 0; }; diff --git a/source/Irrlicht/CGUIImage.cpp b/source/Irrlicht/CGUIImage.cpp index 40057756..a963b347 100644 --- a/source/Irrlicht/CGUIImage.cpp +++ b/source/Irrlicht/CGUIImage.cpp @@ -18,7 +18,7 @@ namespace gui //! constructor CGUIImage::CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) : IGUIImage(environment, parent, id, rectangle), Texture(0), Color(255,255,255,255), - UseAlphaChannel(false), ScaleImage(false), DrawBounds(0.f, 0.f, 1.f, 1.f) + UseAlphaChannel(false), ScaleImage(false), DrawBounds(0.f, 0.f, 1.f, 1.f), DrawBackground(true) { #ifdef _DEBUG setDebugName("CGUIImage"); @@ -104,7 +104,7 @@ void CGUIImage::draw() &clippingRect, Color, UseAlphaChannel); } } - else + else if ( DrawBackground ) { core::rect clippingRect(AbsoluteClippingRect); checkBounds(clippingRect); @@ -188,6 +188,7 @@ void CGUIImage::serializeAttributes(io::IAttributes* out, io::SAttributeReadWrit out->addFloat ("DrawBoundsY1", DrawBounds.UpperLeftCorner.Y); out->addFloat ("DrawBoundsX2", DrawBounds.LowerRightCorner.X); out->addFloat ("DrawBoundsY2", DrawBounds.LowerRightCorner.Y); + out->addBool ("DrawBackground", DrawBackground); } @@ -207,6 +208,8 @@ void CGUIImage::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWri DrawBounds.LowerRightCorner.X = in->getAttributeAsFloat("DrawBoundsX2", DrawBounds.LowerRightCorner.X); DrawBounds.LowerRightCorner.Y = in->getAttributeAsFloat("DrawBoundsY2", DrawBounds.LowerRightCorner.Y); setDrawBounds(DrawBounds); + + setDrawBackground(in->getAttributeAsBool("DrawBackground", DrawBackground)); } diff --git a/source/Irrlicht/CGUIImage.h b/source/Irrlicht/CGUIImage.h index 1de4eedf..034a8903 100644 --- a/source/Irrlicht/CGUIImage.h +++ b/source/Irrlicht/CGUIImage.h @@ -64,6 +64,18 @@ namespace gui //! Get drawing-area restrictions. virtual core::rect getDrawBounds() const _IRR_OVERRIDE_; + //! Sets whether to draw a background color (EGDC_3D_DARK_SHADOW) when no texture is set + virtual void setDrawBackground(bool draw) _IRR_OVERRIDE_ + { + DrawBackground = draw; + } + + //! Checks if a background is drawn when no texture is set + virtual bool isDrawBackgroundEnabled() const _IRR_OVERRIDE_ + { + return DrawBackground; + } + //! Writes attributes of the element. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_; @@ -89,6 +101,7 @@ namespace gui bool ScaleImage; core::rect SourceRect; core::rect DrawBounds; + bool DrawBackground; };