aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorJohannes Schickel2010-09-14 00:15:20 +0000
committerJohannes Schickel2010-09-14 00:15:20 +0000
commitdd76a20acd16df90457eb7eb11006902f8e3290b (patch)
treeb4fb36bfc27bfc4d5edd6ed2d674c8af51cfc218 /gui
parent70245181f1fce247ba2f9ffbbd93c4032358d29f (diff)
downloadscummvm-rg350-dd76a20acd16df90457eb7eb11006902f8e3290b.tar.gz
scummvm-rg350-dd76a20acd16df90457eb7eb11006902f8e3290b.tar.bz2
scummvm-rg350-dd76a20acd16df90457eb7eb11006902f8e3290b.zip
GUI: Fix caret undrawing. (Regression from r48551)
Starting with r48551 the caret undrawing caused the text selection color in ListWidgets to be removed. It also added a slight offset to the character next to the undrawn caret. All this is fixed now. svn-id: r52716
Diffstat (limited to 'gui')
-rw-r--r--gui/EditTextWidget.cpp2
-rw-r--r--gui/ListWidget.cpp12
-rw-r--r--gui/editable.cpp5
-rw-r--r--gui/editable.h2
4 files changed, 12 insertions, 9 deletions
diff --git a/gui/EditTextWidget.cpp b/gui/EditTextWidget.cpp
index 7079453173..e5de1c6e7f 100644
--- a/gui/EditTextWidget.cpp
+++ b/gui/EditTextWidget.cpp
@@ -88,7 +88,7 @@ void EditTextWidget::drawWidget() {
}
Common::Rect EditTextWidget::getEditRect() const {
- Common::Rect r(2 + _leftPadding, 1, _w - 2 - _leftPadding - _rightPadding, _h-1);
+ Common::Rect r(2 + _leftPadding, 2, _w - 2 - _leftPadding - _rightPadding, _h-1);
return r;
}
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp
index 4447b62244..f5f41bba80 100644
--- a/gui/ListWidget.cpp
+++ b/gui/ListWidget.cpp
@@ -449,11 +449,15 @@ bool ListWidget::handleKeyUp(Common::KeyState state) {
}
void ListWidget::receivedFocusWidget() {
+ _inversion = ThemeEngine::kTextInversionFocus;
+
// Redraw the widget so the selection color will change
draw();
}
void ListWidget::lostFocusWidget() {
+ _inversion = ThemeEngine::kTextInversion;
+
// If we lose focus, we simply forget the user changes
_editMode = false;
g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);
@@ -491,12 +495,8 @@ void ListWidget::drawWidget() {
ThemeEngine::TextInversionState inverted = ThemeEngine::kTextInversionNone;
// Draw the selected item inverted, on a highlighted background.
- if (_selectedItem == pos) {
- if (_hasFocus)
- inverted = ThemeEngine::kTextInversionFocus;
- else
- inverted = ThemeEngine::kTextInversion;
- }
+ if (_selectedItem == pos)
+ inverted = _inversion;
Common::Rect r(getEditRect());
int pad = _leftPadding;
diff --git a/gui/editable.cpp b/gui/editable.cpp
index 755e34e380..1ebe307bb0 100644
--- a/gui/editable.cpp
+++ b/gui/editable.cpp
@@ -48,6 +48,7 @@ void EditableWidget::init() {
_editScrollOffset = 0;
_font = ThemeEngine::kFontStyleBold;
+ _inversion = ThemeEngine::kTextInversionNone;
}
EditableWidget::~EditableWidget() {
@@ -237,7 +238,7 @@ void EditableWidget::drawCaret(bool erase) {
Common::Rect editRect = getEditRect();
int x = editRect.left;
- int y = editRect.top + 1;
+ int y = editRect.top;
x += getCaretOffset();
@@ -253,7 +254,7 @@ void EditableWidget::drawCaret(bool erase) {
if ((uint)_caretPos < _editString.size()) {
GUI::EditableWidget::String chr(_editString[_caretPos]);
int chrWidth = g_gui.getCharWidth(_editString[_caretPos], _font);
- g_gui.theme()->drawText(Common::Rect(x, y, x + chrWidth, y + editRect.height() - 2), chr, _state, Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone, 0, false, _font);
+ g_gui.theme()->drawText(Common::Rect(x, y, x + chrWidth, y + editRect.height() - 2), chr, _state, Graphics::kTextAlignLeft, _inversion, 0, false, _font);
}
}
diff --git a/gui/editable.h b/gui/editable.h
index 8ff5298511..4a2d98349e 100644
--- a/gui/editable.h
+++ b/gui/editable.h
@@ -54,6 +54,8 @@ protected:
ThemeEngine::FontStyle _font;
+ ThemeEngine::TextInversionState _inversion;
+
public:
EditableWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip = 0, uint32 cmd = 0);
EditableWidget(GuiObject *boss, const String &name, const char *tooltip = 0, uint32 cmd = 0);