Added: Remove hardcoded text overflow indicator

--HG--
branch : experimental-ui-scaling
feature/pipeline-tools
Nimetu 8 years ago
parent 4a722c7783
commit b5717de4fc

@ -90,6 +90,7 @@ namespace NLGUI
void setShadowOutline (bool bShadowOutline); void setShadowOutline (bool bShadowOutline);
void setShadowColor (const NLMISC::CRGBA &color); void setShadowColor (const NLMISC::CRGBA &color);
void setLineMaxW (sint nMaxW, bool invalidate=true); void setLineMaxW (sint nMaxW, bool invalidate=true);
void setOverflowText(const ucstring &text) { _OverflowText = text; }
void setMultiLine (bool bMultiLine); void setMultiLine (bool bMultiLine);
void setMultiLineSpace (sint nMultiLineSpace); void setMultiLineSpace (sint nMultiLineSpace);
void setMultiLineMaxWOnly (bool state); void setMultiLineMaxWOnly (bool state);
@ -114,6 +115,7 @@ namespace NLGUI
bool getShadowOutline() { return _ShadowOutline; } bool getShadowOutline() { return _ShadowOutline; }
NLMISC::CRGBA getShadowColor() { return _ShadowColor; } NLMISC::CRGBA getShadowColor() { return _ShadowColor; }
sint getLineMaxW() const { return _LineMaxW; } sint getLineMaxW() const { return _LineMaxW; }
ucstring getOverflowText() const { return _OverflowText; }
bool getMultiLine() const { return _MultiLine; } bool getMultiLine() const { return _MultiLine; }
sint getMultiLineSpace() const { return _MultiLineSpace; } sint getMultiLineSpace() const { return _MultiLineSpace; }
bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; } bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; }
@ -259,6 +261,7 @@ namespace NLGUI
sint32 _LineMaxW; sint32 _LineMaxW;
/// For single line, true if the text is clamped (ie displayed with "...") /// For single line, true if the text is clamped (ie displayed with "...")
bool _SingleLineTextClamped; bool _SingleLineTextClamped;
ucstring _OverflowText;
/// Multiple lines handling /// Multiple lines handling
bool _MultiLine; bool _MultiLine;

@ -99,6 +99,7 @@ namespace NLGUI
_AutoClamp = false; _AutoClamp = false;
_ClampRight = true; // clamp on the right of the text _ClampRight = true; // clamp on the right of the text
_OverflowText = "...";
_LetterColors = NULL; _LetterColors = NULL;
_Setuped= false; _Setuped= false;
@ -1880,12 +1881,15 @@ namespace NLGUI
_Lines.back()->clear(*TextContext); _Lines.back()->clear(*TextContext);
_Lines.pop_back(); _Lines.pop_back();
} }
_Lines.pop_back(); if (_OverflowText.size() > 0)
CViewText::CLine *endLine = new CViewText::CLine; {
CViewText::CWord w; _Lines.pop_back();
w.build(string("..."), *TextContext, _Scale); CViewText::CLine *endLine = new CViewText::CLine;
endLine->addWord(w, _FontWidth); CViewText::CWord w;
_Lines.push_back(TLineSPtr(endLine)); w.build(_OverflowText, *TextContext, _Scale);
endLine->addWord(w, _FontWidth);
_Lines.push_back(TLineSPtr(endLine));
}
} }
// Calculate size // Calculate size
@ -1947,10 +1951,20 @@ namespace NLGUI
UTextContext::CStringInfo si; UTextContext::CStringInfo si;
ucstring ucCurrentLine; ucstring ucCurrentLine;
ucCurrentLine.reserve(_Text.size()); ucCurrentLine.reserve(_Text.size());
// Append ... to the end of line // Append ... to the end of line
si = TextContext->getStringInfo (ucstring("...")); float dotWidth;
float dotWidth= si.StringWidth / _Scale; if (_OverflowText.size() > 0)
float rWidthCurrentLine = 0, rWidthLetter; {
si = TextContext->getStringInfo (ucstring(_OverflowText));
dotWidth = si.StringWidth / _Scale;
}
else
{
dotWidth = 0.0f;
}
float rWidthCurrentLine = 0, rWidthLetter;
// for all the text // for all the text
if (_ClampRight) if (_ClampRight)
{ {
@ -1974,7 +1988,10 @@ namespace NLGUI
} }
// Add the dots // Add the dots
ucCurrentLine+= "..."; if (_OverflowText.size() > 0)
{
ucCurrentLine += _OverflowText;
}
} }
else else
{ {
@ -1998,7 +2015,10 @@ namespace NLGUI
} }
// Add the dots // Add the dots
ucCurrentLine = "..." + ucCurrentLine; if (_OverflowText.size() > 0)
{
ucCurrentLine = _OverflowText + ucCurrentLine;
}
} }
// And so setup this trunc text // And so setup this trunc text

Loading…
Cancel
Save