mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-12 12:09:15 +00:00
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
This commit is contained in:
parent
70245181f1
commit
dd76a20acd
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user