aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorJohannes Schickel2013-11-24 00:38:47 +0100
committerJohannes Schickel2013-11-24 00:38:47 +0100
commitb487c1fc38405ca80683b0d30318d0c4bd408b67 (patch)
treec2a0d7d70816aba08c6af1653942315b270f07b7 /gui
parent95f07fd405cd72822faef1a0e0bffe953a8856df (diff)
downloadscummvm-rg350-b487c1fc38405ca80683b0d30318d0c4bd408b67.tar.gz
scummvm-rg350-b487c1fc38405ca80683b0d30318d0c4bd408b67.tar.bz2
scummvm-rg350-b487c1fc38405ca80683b0d30318d0c4bd408b67.zip
GUI: Fix undrawing caret glitch when the edit text is inversed.
This is prominently visible in the list based save/load chooser since the edit string is drawn on a special green background there. When the caret is at the end of the edit string this would result in the green color missing at the place of the (undrawn) caret. To avoid this we simply draw a fake space now.
Diffstat (limited to 'gui')
-rw-r--r--gui/widgets/editable.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp
index fca9702690..9ce4defde4 100644
--- a/gui/widgets/editable.cpp
+++ b/gui/widgets/editable.cpp
@@ -272,13 +272,25 @@ void EditableWidget::drawCaret(bool erase) {
g_gui.theme()->drawCaret(Common::Rect(x, y, x + 1, y + editRect.height()), erase);
if (erase) {
+ GUI::EditableWidget::String character;
+ int width;
+
if ((uint)_caretPos < _editString.size()) {
- GUI::EditableWidget::String chr(_editString[_caretPos]);
- int chrWidth = g_gui.getCharWidth(_editString[_caretPos], _font);
+ const byte chr = _editString[_caretPos];
+ width = g_gui.getCharWidth(chr, _font);
+ character = chr;
+
const uint last = (_caretPos > 0) ? _editString[_caretPos - 1] : 0;
- x += g_gui.getKerningOffset(last, _editString[_caretPos], _font);
- g_gui.theme()->drawText(Common::Rect(x, y, x + chrWidth, y + editRect.height()), chr, _state, Graphics::kTextAlignLeft, _inversion, 0, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
+ x += g_gui.getKerningOffset(last, chr, _font);
+ } else {
+ // We draw a fake space here to assure that removing the caret
+ // does not result in color glitches in case the edit rect is
+ // drawn with an inversion.
+ width = g_gui.getCharWidth(' ', _font);
+ character = " ";
}
+
+ g_gui.theme()->drawText(Common::Rect(x, y, x + width, y + editRect.height()), character, _state, Graphics::kTextAlignLeft, _inversion, 0, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
}
_caretVisible = !erase;