From b5717de4fcc9657bc1f78bdb264cf6d2c4faf15a Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sun, 14 Aug 2016 02:25:19 +0300 Subject: [PATCH] Added: Remove hardcoded text overflow indicator --HG-- branch : experimental-ui-scaling --- code/nel/include/nel/gui/view_text.h | 3 ++ code/nel/src/gui/view_text.cpp | 42 ++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/code/nel/include/nel/gui/view_text.h b/code/nel/include/nel/gui/view_text.h index 95b8d2e4a..e0603895c 100644 --- a/code/nel/include/nel/gui/view_text.h +++ b/code/nel/include/nel/gui/view_text.h @@ -90,6 +90,7 @@ namespace NLGUI void setShadowOutline (bool bShadowOutline); void setShadowColor (const NLMISC::CRGBA &color); void setLineMaxW (sint nMaxW, bool invalidate=true); + void setOverflowText(const ucstring &text) { _OverflowText = text; } void setMultiLine (bool bMultiLine); void setMultiLineSpace (sint nMultiLineSpace); void setMultiLineMaxWOnly (bool state); @@ -114,6 +115,7 @@ namespace NLGUI bool getShadowOutline() { return _ShadowOutline; } NLMISC::CRGBA getShadowColor() { return _ShadowColor; } sint getLineMaxW() const { return _LineMaxW; } + ucstring getOverflowText() const { return _OverflowText; } bool getMultiLine() const { return _MultiLine; } sint getMultiLineSpace() const { return _MultiLineSpace; } bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; } @@ -259,6 +261,7 @@ namespace NLGUI sint32 _LineMaxW; /// For single line, true if the text is clamped (ie displayed with "...") bool _SingleLineTextClamped; + ucstring _OverflowText; /// Multiple lines handling bool _MultiLine; diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index 3e649c1c3..02b2600b4 100644 --- a/code/nel/src/gui/view_text.cpp +++ b/code/nel/src/gui/view_text.cpp @@ -99,6 +99,7 @@ namespace NLGUI _AutoClamp = false; _ClampRight = true; // clamp on the right of the text + _OverflowText = "..."; _LetterColors = NULL; _Setuped= false; @@ -1880,12 +1881,15 @@ namespace NLGUI _Lines.back()->clear(*TextContext); _Lines.pop_back(); } - _Lines.pop_back(); - CViewText::CLine *endLine = new CViewText::CLine; - CViewText::CWord w; - w.build(string("..."), *TextContext, _Scale); - endLine->addWord(w, _FontWidth); - _Lines.push_back(TLineSPtr(endLine)); + if (_OverflowText.size() > 0) + { + _Lines.pop_back(); + CViewText::CLine *endLine = new CViewText::CLine; + CViewText::CWord w; + w.build(_OverflowText, *TextContext, _Scale); + endLine->addWord(w, _FontWidth); + _Lines.push_back(TLineSPtr(endLine)); + } } // Calculate size @@ -1947,10 +1951,20 @@ namespace NLGUI UTextContext::CStringInfo si; ucstring ucCurrentLine; ucCurrentLine.reserve(_Text.size()); + // Append ... to the end of line - si = TextContext->getStringInfo (ucstring("...")); - float dotWidth= si.StringWidth / _Scale; - float rWidthCurrentLine = 0, rWidthLetter; + float dotWidth; + if (_OverflowText.size() > 0) + { + si = TextContext->getStringInfo (ucstring(_OverflowText)); + dotWidth = si.StringWidth / _Scale; + } + else + { + dotWidth = 0.0f; + } + + float rWidthCurrentLine = 0, rWidthLetter; // for all the text if (_ClampRight) { @@ -1974,7 +1988,10 @@ namespace NLGUI } // Add the dots - ucCurrentLine+= "..."; + if (_OverflowText.size() > 0) + { + ucCurrentLine += _OverflowText; + } } else { @@ -1998,7 +2015,10 @@ namespace NLGUI } // Add the dots - ucCurrentLine = "..." + ucCurrentLine; + if (_OverflowText.size() > 0) + { + ucCurrentLine = _OverflowText + ucCurrentLine; + } } // And so setup this trunc text