[Scummvm-git-logs] scummvm master -> 2460f39cb36ffa78702d9d78c15ee24e73f349d2

sev- noreply at scummvm.org
Thu Mar 12 01:22:16 UTC 2026


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

Summary:
2460f39cb3 GUI: Refactor PopUpDialog::findItem


Commit: 2460f39cb36ffa78702d9d78c15ee24e73f349d2
    https://github.com/scummvm/scummvm/commit/2460f39cb36ffa78702d9d78c15ee24e73f349d2
Author: tunnelsociety (tunnelsociety at mm.st)
Date: 2026-03-12T02:22:11+01:00

Commit Message:
GUI: Refactor PopUpDialog::findItem

Simplify the code (the formula is identical), but also return -1 instead
of 0 when the list is empty.

Changed paths:
    gui/widgets/popup.cpp


diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp
index 843287e303f..056479cabc2 100644
--- a/gui/widgets/popup.cpp
+++ b/gui/widgets/popup.cpp
@@ -304,20 +304,15 @@ void PopUpDialog::clearEntries() {
 }
 
 int PopUpDialog::findItem(int x, int y) const {
+	int entry = -1;
 	if (x >= 0 && x < _w && y >= 0 && y < _h) {
-		if (_twoColumns) {
-			uint entry = (y - 2) / _lineHeight;
-			if (x > _w / 2) {
-				entry += _entriesPerColumn;
-
-				if (entry >= _entries.size())
-					return -1;
-			}
-			return entry;
-		}
-		return (y - 2) / _lineHeight;
+		entry = (y - 2) / _lineHeight;
+		if (_twoColumns && x > _w / 2)
+			entry += _entriesPerColumn;
+		if (entry >= _entries.size())
+			entry = -1;
 	}
-	return -1;
+	return entry;
 }
 
 void PopUpDialog::setSelection(int item) {




More information about the Scummvm-git-logs mailing list