GUI: Fix bad EditTextWidget rect at low window widths

Fix bug https://bugs.scummvm.org/ticket/13339

Solution is taken from our ListWidget (gui/widgets/list.cpp) which performs a similar check in its ListWidget::getEditRect()
This commit is contained in:
antoniou79 2022-03-05 23:57:49 +02:00 committed by Lothar Serra Mari
parent 786800e831
commit 8fcfb7e585

View File

@ -112,7 +112,14 @@ void EditTextWidget::drawWidget() {
}
Common::Rect EditTextWidget::getEditRect() const {
Common::Rect r(2 + _leftPadding, 1, _w - 1 - _rightPadding, _h);
// Calculate (right - left) difference for editRect's X-axis coordinates:
// (_w - 1 - _rightPadding) - (2 + _leftPadding)
int editWidth = _w - _rightPadding - _leftPadding - 3;
// Ensure r will always be a valid rect
if (editWidth < 0) {
editWidth = 0;
}
Common::Rect r(2 + _leftPadding, 1, 2 + _leftPadding + editWidth, _h);
return r;
}