GRAPHICS: MACGUI: Do not add input line to the original MacText content
During resize we were replaying all MacText appends, which was including whole history of the input. Eek.
This commit is contained in:
parent
59d6b63b0f
commit
4e044d7bd3
4 changed files with 19 additions and 12 deletions
|
@ -378,15 +378,17 @@ uint getNewlinesInString(const Common::String &str) {
|
|||
return newLines;
|
||||
}
|
||||
|
||||
void MacText::appendText(Common::String str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular) {
|
||||
void MacText::appendText(Common::String str, int fontId, int fontSize, int fontSlant, bool skipAdd) {
|
||||
uint oldLen = _textLines.size();
|
||||
|
||||
MacFontRun fontRun = MacFontRun(_wm, fontId, fontSlant, fontSize, 0, 0, 0);
|
||||
|
||||
_currentFormatting = fontRun;
|
||||
|
||||
_str += fontRun.toString();
|
||||
_str += str;
|
||||
if (!skipAdd) {
|
||||
_str += fontRun.toString();
|
||||
_str += str;
|
||||
}
|
||||
|
||||
splitString(str);
|
||||
recalcDims();
|
||||
|
@ -394,13 +396,15 @@ void MacText::appendText(Common::String str, int fontId = kMacFontChicago, int f
|
|||
render(oldLen - 1, _textLines.size());
|
||||
}
|
||||
|
||||
void MacText::appendTextDefault(Common::String str) {
|
||||
void MacText::appendTextDefault(Common::String str, bool skipAdd) {
|
||||
uint oldLen = _textLines.size();
|
||||
|
||||
_currentFormatting = _defaultFormatting;
|
||||
|
||||
_str += _defaultFormatting.toString();
|
||||
_str += str;
|
||||
if (!skipAdd) {
|
||||
_str += _defaultFormatting.toString();
|
||||
_str += str;
|
||||
}
|
||||
|
||||
splitString(str);
|
||||
recalcDims();
|
||||
|
|
|
@ -102,8 +102,8 @@ public:
|
|||
}
|
||||
|
||||
void draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int yoff);
|
||||
void appendText(Common::String str, int fontId, int fontSize, int fontSlant);
|
||||
void appendTextDefault(Common::String str);
|
||||
void appendText(Common::String str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular, bool skipAdd = false);
|
||||
void appendTextDefault(Common::String str, bool skipAdd = false);
|
||||
void clearText();
|
||||
void replaceLastLine(Common::String str);
|
||||
void removeLastLine();
|
||||
|
|
|
@ -78,8 +78,8 @@ void MacTextWindow::resize(int w, int h) {
|
|||
MacWindow::resize(w, h);
|
||||
}
|
||||
|
||||
void MacTextWindow::appendText(Common::String str, const MacFont *macFont) {
|
||||
_mactext->appendText(str, macFont->getId(), macFont->getSize(), macFont->getSlant());
|
||||
void MacTextWindow::appendText(Common::String str, const MacFont *macFont, bool skipAdd) {
|
||||
_mactext->appendText(str, macFont->getId(), macFont->getSize(), macFont->getSlant(), skipAdd);
|
||||
|
||||
_contentIsDirty = true;
|
||||
|
||||
|
@ -188,6 +188,9 @@ void MacTextWindow::undrawInput() {
|
|||
for (uint i = 0; i < _inputTextHeight; i++)
|
||||
_mactext->removeLastLine();
|
||||
|
||||
if (_inputTextHeight)
|
||||
appendText("\n", _font, true);
|
||||
|
||||
_inputTextHeight = 0;
|
||||
}
|
||||
|
||||
|
@ -201,7 +204,7 @@ void MacTextWindow::drawInput() {
|
|||
_inputTextHeight = MAX(1u, text.size()); // We always have line to clean
|
||||
|
||||
// And add new input line to the text
|
||||
appendText(_inputText, _font);
|
||||
appendText(_inputText, _font, true);
|
||||
|
||||
_cursorX = _inputText.empty() ? 0 : _fontRef->getStringWidth(text[_inputTextHeight - 1]);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
void setTextWindowFont(const MacFont *macFont);
|
||||
const MacFont *getTextWindowFont();
|
||||
|
||||
void appendText(Common::String str, const MacFont *macFont);
|
||||
void appendText(Common::String str, const MacFont *macFont, bool skipAdd = false);
|
||||
void clearText();
|
||||
|
||||
void setSelection(int selStartX, int selStartY, int selEndX, int selEndY);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue