[Scummvm-git-logs] scummvm master -> 97f8a4e42e2fad250ea296b503083d9e886be231
criezy
criezy at scummvm.org
Thu Apr 22 00:42:59 UTC 2021
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ba0dabd5ca GUI: Fix position of character after caret
97f8a4e42e GUI: Fix getEditRect and implify rect handling in EditTextWidget
Commit: ba0dabd5ca3f7868391a33d36863dcea197ca96d
https://github.com/scummvm/scummvm/commit/ba0dabd5ca3f7868391a33d36863dcea197ca96d
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-22T01:40:12+01:00
Commit Message:
GUI: Fix position of character after caret
There was a discrepency in the vertical position of the text in
the drawText call on one hand, and in the getEditRect() and rect
passed to setTextDrawableArea() on the other. This discrepency
was introduced in commit c47b204ac. Since getEditRect() is used
in EditableWidget::drawCaret() to draw the character after the
caret (when erasing the caret) this caused this vertical shift.
This fixes bug #12336.
Changed paths:
gui/widgets/edittext.cpp
diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp
index 7c13d54d4c..fb990268e3 100644
--- a/gui/widgets/edittext.cpp
+++ b/gui/widgets/edittext.cpp
@@ -103,7 +103,7 @@ void EditTextWidget::drawWidget() {
// Draw the text
adjustOffset();
- const Common::Rect &r = Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 8, _y + _h);
+ const Common::Rect &r = Common::Rect(_x + 2 + _leftPadding, _y + 1, _x + _leftPadding + getEditRect().width() + 8, _y + _h);
setTextDrawableArea(r);
g_gui.theme()->drawText(
@@ -113,7 +113,7 @@ void EditTextWidget::drawWidget() {
}
Common::Rect EditTextWidget::getEditRect() const {
- Common::Rect r(2 + _leftPadding, 2, _w - 2 - _leftPadding - _rightPadding, _h);
+ Common::Rect r(2 + _leftPadding, 1, _w - 2 - _leftPadding - _rightPadding, _h);
return r;
}
Commit: 97f8a4e42e2fad250ea296b503083d9e886be231
https://github.com/scummvm/scummvm/commit/97f8a4e42e2fad250ea296b503083d9e886be231
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-22T01:40:12+01:00
Commit Message:
GUI: Fix getEditRect and implify rect handling in EditTextWidget
The same rect was hardcoded in three different places. Now it is
only in getEditRect and the other places use getEditRect.
There were actually differences between the rect width, but I put
that down to a bug in getEditRect. I see no reason to define the
right position of the rect as w - 2 - right_padding - left_padding.
Substracting the left padding would make sense if we were
specifying the rect width, but the Common:Rect constructor takes
the rect right location and not the width. There might have been
a confusion on that point by the developer who wrote that code
years ago. Also has the bottom right point is excluded, we should
only remove 1 and not 2.
This width that was smaller than it should be might have been the
reason why 6 additional pixels were arbitrarily added to the rect
passed to setTextDrawableArea later on.
There were actually
Changed paths:
gui/widgets/edittext.cpp
diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp
index fb990268e3..0b4bd0b119 100644
--- a/gui/widgets/edittext.cpp
+++ b/gui/widgets/edittext.cpp
@@ -102,18 +102,18 @@ void EditTextWidget::drawWidget() {
// Draw the text
adjustOffset();
-
- const Common::Rect &r = Common::Rect(_x + 2 + _leftPadding, _y + 1, _x + _leftPadding + getEditRect().width() + 8, _y + _h);
- setTextDrawableArea(r);
+ Common::Rect drawRect = getEditRect();
+ drawRect.translate(_x, _y);
+ setTextDrawableArea(drawRect);
g_gui.theme()->drawText(
- Common::Rect(_x + 2 + _leftPadding, _y + 1, _x + _leftPadding + getEditRect().width() + 2, _y + _h),
+ drawRect,
_editString, _state, _drawAlign, ThemeEngine::kTextInversionNone,
-_editScrollOffset, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
}
Common::Rect EditTextWidget::getEditRect() const {
- Common::Rect r(2 + _leftPadding, 1, _w - 2 - _leftPadding - _rightPadding, _h);
+ Common::Rect r(2 + _leftPadding, 1, _w - 1 - _rightPadding, _h);
return r;
}
More information about the Scummvm-git-logs
mailing list