mirror of
https://github.com/scummvm/scummvm.git
synced 2026-11-18 21:34:48 +00:00
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
This commit is contained in:
1 parent
ba0dabd5ca
commit
97f8a4e42e
1 file changed
+5
-5
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user