Commit e877b786 authored by hybrid's avatar hybrid

Patch by Auria, which allows to render text in gui static text elements over...

Patch by Auria, which allows to render text in gui static text elements over the element clip area. This makes handling of changing text simpler. As default, this feature is turned off.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3483 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 8b5ed2bc
......@@ -91,6 +91,12 @@ namespace gui
/** If the text is broken, this returns the width of the widest line
\return The width of the text, or the widest broken line. */
virtual s32 getTextWidth(void) const = 0;
//! Set whether the text in this label should be clipped if it goes outside bounds
virtual void setTextRestrainedInside(bool restrainedInside) = 0;
//! Checks if the text in this label should be clipped if it goes outside bounds
virtual bool isTextRestrainedInside() const = 0;
};
......
......@@ -32,6 +32,7 @@ CGUIStaticText::CGUIStaticText(const wchar_t* text, bool border,
#endif
Text = text;
RestrainTextInside = true;
if (environment && environment->getSkin())
{
BGColor = environment->getSkin()->getColor(gui::EGDC_3D_FACE);
......@@ -102,7 +103,7 @@ void CGUIStaticText::draw()
font->draw(Text.c_str(), frameRect,
OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT),
HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, &AbsoluteClippingRect);
HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, (RestrainTextInside ? &AbsoluteClippingRect : NULL));
}
else
{
......@@ -131,7 +132,7 @@ void CGUIStaticText::draw()
font->draw(BrokenText[i].c_str(), r,
OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT),
HAlign == EGUIA_CENTER, false, &AbsoluteClippingRect);
HAlign == EGUIA_CENTER, false, (RestrainTextInside ? &AbsoluteClippingRect : NULL));
r.LowerRightCorner.Y += height;
r.UpperLeftCorner.Y += height;
......@@ -199,6 +200,18 @@ void CGUIStaticText::setDrawBorder(bool draw)
}
void CGUIStaticText::setTextRestrainedInside(bool restrainTextInside)
{
RestrainTextInside = restrainTextInside;
}
bool CGUIStaticText::isTextRestrainedInside() const
{
return RestrainTextInside;
}
void CGUIStaticText::setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical)
{
HAlign = horizontal;
......@@ -432,6 +445,7 @@ void CGUIStaticText::serializeAttributes(io::IAttributes* out, io::SAttributeRea
out->addBool ("OverrideBGColorEnabled",OverrideBGColorEnabled);
out->addBool ("WordWrap", WordWrap);
out->addBool ("Background", Background);
out->addBool ("RestrainTextInside", RestrainTextInside);
out->addColor ("OverrideColor", OverrideColor);
out->addColor ("BGColor", BGColor);
out->addEnum ("HTextAlign", HAlign, GUIAlignmentNames);
......@@ -451,6 +465,7 @@ void CGUIStaticText::deserializeAttributes(io::IAttributes* in, io::SAttributeRe
OverrideBGColorEnabled = in->getAttributeAsBool("OverrideBGColorEnabled");
setWordWrap(in->getAttributeAsBool("WordWrap"));
Background = in->getAttributeAsBool("Background");
RestrainTextInside = in->getAttributeAsBool("RestrainTextInside");
OverrideColor = in->getAttributeAsColor("OverrideColor");
BGColor = in->getAttributeAsColor("BGColor");
......
......@@ -61,6 +61,12 @@ namespace gui
//! Checks if an override color is enabled
virtual bool isOverrideColorEnabled() const;
//! Set whether the text in this label should be clipped if it goes outside bounds
virtual void setTextRestrainedInside(bool restrainedInside);
//! Checks if the text in this label should be clipped if it goes outside bounds
virtual bool isTextRestrainedInside() const;
//! Enables or disables word wrap for using the static text as
//! multiline text control.
virtual void setWordWrap(bool enable);
......@@ -97,6 +103,7 @@ namespace gui
bool OverrideBGColorEnabled;
bool WordWrap;
bool Background;
bool RestrainTextInside;
video::SColor OverrideColor, BGColor;
gui::IGUIFont* OverrideFont;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment