[Scummvm-git-logs] scummvm master -> aa9cbdc6abb066c5a297d5f2d17698973546da9a

lephilousophe lephilousophe at users.noreply.github.com
Sun Jun 20 11:34:17 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
aa9cbdc6ab GUI: Fix invalid rect when list width goes too small


Commit: aa9cbdc6abb066c5a297d5f2d17698973546da9a
    https://github.com/scummvm/scummvm/commit/aa9cbdc6abb066c5a297d5f2d17698973546da9a
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2021-06-20T13:33:38+02:00

Commit Message:
GUI: Fix invalid rect when list width goes too small

Changed paths:
    gui/widgets/list.cpp


diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index dc8c01e172..8d3c500565 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -610,7 +610,12 @@ void ListWidget::drawWidget() {
 
 Common::Rect ListWidget::getEditRect() const {
 	const int scrollbarW = (_scrollBar && _scrollBar->isVisible()) ? _scrollBarWidth : 0;
-	Common::Rect r(_hlLeftPadding, 0, _w - _hlRightPadding - scrollbarW, kLineHeight - 2);
+	int editWidth = _w - _hlLeftPadding - _hlRightPadding - scrollbarW;
+	// Ensure r will always be a valid rect
+	if (editWidth < 0) {
+		editWidth = 0;
+	}
+	Common::Rect r(_hlLeftPadding, 0, _hlLeftPadding + editWidth, kLineHeight - 2);
 	const int offset = (_selectedItem - _currentPos) * kLineHeight + _topPadding;
 	r.top += offset;
 	r.bottom += offset;
@@ -619,6 +624,10 @@ Common::Rect ListWidget::getEditRect() const {
 		// FIXME: Assumes that all digits have the same width.
 		Common::String temp = Common::String::format("%2d. ", (_list.size() - 1 + _numberingMode));
 		r.left += g_gui.getStringWidth(temp) + _leftPadding;
+		// Make sure we don't go farther than right
+		if (r.right < r.left) {
+			r.right = r.left;
+		}
 	}
 
 	return r;




More information about the Scummvm-git-logs mailing list