aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorJohannes Schickel2013-11-24 00:49:18 +0100
committerJohannes Schickel2013-11-24 01:15:27 +0100
commitfe7f28bf6c955715f1180a0da315ec4ade38fdd0 (patch)
treead7b1726bd29c343a742bfc490ee1e1571687654 /gui
parentb487c1fc38405ca80683b0d30318d0c4bd408b67 (diff)
downloadscummvm-rg350-fe7f28bf6c955715f1180a0da315ec4ade38fdd0.tar.gz
scummvm-rg350-fe7f28bf6c955715f1180a0da315ec4ade38fdd0.tar.bz2
scummvm-rg350-fe7f28bf6c955715f1180a0da315ec4ade38fdd0.zip
GUI: Do not draw text outside edit rect in EditableWidget.
Diffstat (limited to 'gui')
-rw-r--r--gui/widgets/editable.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp
index 9ce4defde4..6f550b5642 100644
--- a/gui/widgets/editable.cpp
+++ b/gui/widgets/editable.cpp
@@ -261,7 +261,8 @@ void EditableWidget::drawCaret(bool erase) {
int x = editRect.left;
int y = editRect.top;
- x += getCaretOffset();
+ const int caretOffset = getCaretOffset();
+ x += caretOffset;
if (y < 0 || y + editRect.height() > _h)
return;
@@ -290,7 +291,16 @@ void EditableWidget::drawCaret(bool erase) {
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);
+ // TODO: Right now we manually prevent text from being drawn outside
+ // the edit area here. We might want to consider to use
+ // setTextDrawableArea for this. However, it seems that only
+ // EditTextWidget uses that but not ListWidget. Thus, one should check
+ // whether we can unify the drawing in the text area first to avoid
+ // possible glitches due to different methods used.
+ width = MIN(editRect.width() - caretOffset, width);
+ if (width > 0) {
+ 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;