1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-27 17:28:41 +00:00

StaticText/EnrichedString: Styling support (#9187)

* StaticText/EnrichedString: Styling support

* Fix tooltip fg/bgcolor

* Fix default color for substr(), add unittests
This commit is contained in:
SmallJoker 2020-01-22 19:09:11 +01:00 committed by GitHub
parent fab3f5f7c8
commit 1892ff3c0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 224 additions and 205 deletions

View file

@ -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_