Add IGUIImage::setDrawBackground to allow disabling background drawing even when no texture is set.
I considered also adding more flags to allow background drawing when a texture is set, but couldn't really find a good use-case for that, so keeping it simple (also that case could be done otherwise with a second element and disabling background drawing for top-element completely). git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5563 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
99f957efe9
commit
a03af926e9
@ -1,5 +1,6 @@
|
|||||||
--------------------------
|
--------------------------
|
||||||
Changes in 1.9 (not yet released)
|
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.
|
- 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.
|
- 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.
|
- Prevent initializing/quitting SDL several times when using more than one Irrlicht device.
|
||||||
|
@ -15,7 +15,6 @@ namespace video
|
|||||||
}
|
}
|
||||||
namespace gui
|
namespace gui
|
||||||
{
|
{
|
||||||
|
|
||||||
//! GUI element displaying an image.
|
//! GUI element displaying an image.
|
||||||
class IGUIImage : public IGUIElement
|
class IGUIImage : public IGUIElement
|
||||||
{
|
{
|
||||||
@ -71,6 +70,14 @@ namespace gui
|
|||||||
|
|
||||||
//! Get drawing-area restrictions.
|
//! Get drawing-area restrictions.
|
||||||
virtual core::rect<f32> getDrawBounds() const = 0;
|
virtual core::rect<f32> 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ namespace gui
|
|||||||
//! constructor
|
//! constructor
|
||||||
CGUIImage::CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
|
CGUIImage::CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
|
||||||
: IGUIImage(environment, parent, id, rectangle), Texture(0), Color(255,255,255,255),
|
: 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
|
#ifdef _DEBUG
|
||||||
setDebugName("CGUIImage");
|
setDebugName("CGUIImage");
|
||||||
@ -104,7 +104,7 @@ void CGUIImage::draw()
|
|||||||
&clippingRect, Color, UseAlphaChannel);
|
&clippingRect, Color, UseAlphaChannel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if ( DrawBackground )
|
||||||
{
|
{
|
||||||
core::rect<s32> clippingRect(AbsoluteClippingRect);
|
core::rect<s32> clippingRect(AbsoluteClippingRect);
|
||||||
checkBounds(clippingRect);
|
checkBounds(clippingRect);
|
||||||
@ -188,6 +188,7 @@ void CGUIImage::serializeAttributes(io::IAttributes* out, io::SAttributeReadWrit
|
|||||||
out->addFloat ("DrawBoundsY1", DrawBounds.UpperLeftCorner.Y);
|
out->addFloat ("DrawBoundsY1", DrawBounds.UpperLeftCorner.Y);
|
||||||
out->addFloat ("DrawBoundsX2", DrawBounds.LowerRightCorner.X);
|
out->addFloat ("DrawBoundsX2", DrawBounds.LowerRightCorner.X);
|
||||||
out->addFloat ("DrawBoundsY2", DrawBounds.LowerRightCorner.Y);
|
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.X = in->getAttributeAsFloat("DrawBoundsX2", DrawBounds.LowerRightCorner.X);
|
||||||
DrawBounds.LowerRightCorner.Y = in->getAttributeAsFloat("DrawBoundsY2", DrawBounds.LowerRightCorner.Y);
|
DrawBounds.LowerRightCorner.Y = in->getAttributeAsFloat("DrawBoundsY2", DrawBounds.LowerRightCorner.Y);
|
||||||
setDrawBounds(DrawBounds);
|
setDrawBounds(DrawBounds);
|
||||||
|
|
||||||
|
setDrawBackground(in->getAttributeAsBool("DrawBackground", DrawBackground));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +64,18 @@ namespace gui
|
|||||||
//! Get drawing-area restrictions.
|
//! Get drawing-area restrictions.
|
||||||
virtual core::rect<f32> getDrawBounds() const _IRR_OVERRIDE_;
|
virtual core::rect<f32> 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.
|
//! Writes attributes of the element.
|
||||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
|
||||||
|
|
||||||
@ -89,6 +101,7 @@ namespace gui
|
|||||||
bool ScaleImage;
|
bool ScaleImage;
|
||||||
core::rect<s32> SourceRect;
|
core::rect<s32> SourceRect;
|
||||||
core::rect<f32> DrawBounds;
|
core::rect<f32> DrawBounds;
|
||||||
|
bool DrawBackground;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user