Merged revision 3847 from 1.7 branch. Fix problems in textwrapping in CGUIStaticText. Did use wrong size and did ignore last word of the text. NOTE: this will need some more work now in trunk as trunk supports by now right-to-left text which probably needs similar fixes.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3874 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
0e61ebeb98
commit
e373bc4cf4
|
@ -286,6 +286,8 @@ The following names can be queried for the given types:
|
|||
|
||||
-----------------------------
|
||||
Changes in 1.7.3 (??.??.2011)
|
||||
- Fix problems in Textwrapping in CGUIStaticText. Did use wrong size and did ignore last word of the text in wrapping (thx @ Reiko for bugreport)
|
||||
|
||||
- Fix crash in collada (.dae) loading
|
||||
|
||||
- Fix memory-leaks in example 22 MaterialViewer
|
||||
|
|
|
@ -288,26 +288,29 @@ void CGUIStaticText::breakText()
|
|||
|
||||
BrokenText.clear();
|
||||
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
IGUIFont* font = getActiveFont();
|
||||
if (!font)
|
||||
return;
|
||||
|
||||
LastBreakFont = font;
|
||||
|
||||
core::stringw line;
|
||||
core::stringw word;
|
||||
core::stringw whitespace;
|
||||
s32 size = Text.size();
|
||||
s32 length = 0;
|
||||
s32 elWidth = RelativeRect.getWidth();
|
||||
if (Border)
|
||||
elWidth -= 2*skin->getSize(EGDS_TEXT_DISTANCE_X);
|
||||
wchar_t c;
|
||||
|
||||
// We have to deal with right-to-left and left-to-right differently
|
||||
// However, most parts of the following code is the same, it's just
|
||||
// some order and boundaries which change.
|
||||
if (!RightToLeft)
|
||||
{
|
||||
// regular (left-to-right)
|
||||
core::stringw line;
|
||||
core::stringw word;
|
||||
core::stringw whitespace;
|
||||
s32 size = Text.size();
|
||||
s32 length = 0;
|
||||
s32 elWidth = RelativeRect.getWidth() - 6;
|
||||
wchar_t c;
|
||||
|
||||
for (s32 i=0; i<size; ++i)
|
||||
{
|
||||
c = Text[i];
|
||||
|
@ -329,7 +332,14 @@ void CGUIStaticText::breakText()
|
|||
c = '\0';
|
||||
}
|
||||
|
||||
if (c==L' ' || c==0 || i==(size-1))
|
||||
bool isWhitespace = (c == L' ' || c == 0);
|
||||
if ( !isWhitespace )
|
||||
{
|
||||
// part of a word
|
||||
word += c;
|
||||
}
|
||||
|
||||
if ( isWhitespace || i == (size-1))
|
||||
{
|
||||
if (word.size())
|
||||
{
|
||||
|
@ -383,7 +393,10 @@ void CGUIStaticText::breakText()
|
|||
whitespace = L"";
|
||||
}
|
||||
|
||||
whitespace += c;
|
||||
if ( isWhitespace )
|
||||
{
|
||||
whitespace += c;
|
||||
}
|
||||
|
||||
// compute line break
|
||||
if (lineBreak)
|
||||
|
@ -397,11 +410,6 @@ void CGUIStaticText::breakText()
|
|||
length = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// yippee this is a word..
|
||||
word += c;
|
||||
}
|
||||
}
|
||||
|
||||
line += whitespace;
|
||||
|
@ -411,14 +419,6 @@ void CGUIStaticText::breakText()
|
|||
else
|
||||
{
|
||||
// right-to-left
|
||||
core::stringw line;
|
||||
core::stringw word;
|
||||
core::stringw whitespace;
|
||||
s32 size = Text.size();
|
||||
s32 length = 0;
|
||||
s32 elWidth = RelativeRect.getWidth() - 6;
|
||||
wchar_t c;
|
||||
|
||||
for (s32 i=size; i>=0; --i)
|
||||
{
|
||||
c = Text[i];
|
||||
|
|
Loading…
Reference in New Issue