summaryrefslogtreecommitdiff
path: root/src/irrlicht_changes/static_text.h
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2020-01-22 19:09:11 +0100
committerGitHub <noreply@github.com>2020-01-22 19:09:11 +0100
commit1892ff3c0db23ccdf7b0f6dc83cb1bdf4579b4ec (patch)
treec49c16a69e9c555141960b4bca22a88df9b17a61 /src/irrlicht_changes/static_text.h
parentfab3f5f7c8ce0cbfc27e509f065e3f4cfe28c514 (diff)
downloadminetest-1892ff3c0db23ccdf7b0f6dc83cb1bdf4579b4ec.tar.gz
minetest-1892ff3c0db23ccdf7b0f6dc83cb1bdf4579b4ec.tar.bz2
minetest-1892ff3c0db23ccdf7b0f6dc83cb1bdf4579b4ec.zip
StaticText/EnrichedString: Styling support (#9187)
* StaticText/EnrichedString: Styling support * Fix tooltip fg/bgcolor * Fix default color for substr(), add unittests
Diffstat (limited to 'src/irrlicht_changes/static_text.h')
-rw-r--r--src/irrlicht_changes/static_text.h17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/irrlicht_changes/static_text.h b/src/irrlicht_changes/static_text.h
index 43c587284..1f111ea56 100644
--- a/src/irrlicht_changes/static_text.h
+++ b/src/irrlicht_changes/static_text.h
@@ -34,7 +34,8 @@ namespace gui
{
public:
- //! constructor
+ // StaticText is translated by EnrichedString.
+ // No need to use translate_string()
StaticText(const EnrichedString &text, bool border, IGUIEnvironment* environment,
IGUIElement* parent, s32 id, const core::rect<s32>& rectangle,
bool background = false);
@@ -201,23 +202,20 @@ namespace gui
private:
//! Breaks the single text line.
- void breakText();
+ void updateText();
EGUI_ALIGNMENT HAlign, VAlign;
bool Border;
- bool OverrideColorEnabled;
- bool OverrideBGColorEnabled;
bool WordWrap;
bool Background;
bool RestrainTextInside;
bool RightToLeft;
- video::SColor OverrideColor, BGColor;
gui::IGUIFont* OverrideFont;
gui::IGUIFont* LastBreakFont; // stored because: if skin changes, line break must be recalculated.
- EnrichedString cText;
- core::array< EnrichedString > BrokenText;
+ EnrichedString ColoredText;
+ std::vector<EnrichedString> BrokenText;
};
@@ -274,10 +272,7 @@ inline void setStaticText(irr::gui::IGUIStaticText *static_text, const EnrichedS
inline void setStaticText(irr::gui::IGUIStaticText *static_text, const wchar_t *text)
{
- auto color = static_text->isOverrideColorEnabled()
- ? static_text->getOverrideColor()
- : irr::video::SColor(255, 255, 255, 255);
- setStaticText(static_text, EnrichedString(text, color));
+ setStaticText(static_text, EnrichedString(text, static_text->getOverrideColor()));
}
#endif // _IRR_COMPILE_WITH_GUI_