[Scummvm-git-logs] scummvm master -> 1daaf95326ddf51add624929a6800cbd639925bc

criezy noreply at scummvm.org
Wed Jun 11 22:04:31 UTC 2025


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

Summary:
e66a8bc9d8 GUI: Fix selecting some items in GroupedListWidget when groups are collapsed
7814999d7b GUI: Simplify GroupedListWidget::setSelected(int)
d6fb379297 GUI: Do not scroll GroupedListWidget to top when failing to select item
ed9748a61d GUI: Fix filter not applied after closing the game options
60c56419a3 GUI: Try to preserve the selection in GroupedListWidget when changing the filter
2d44bc8f26 GUI: Fix preserving the selection in GroupedListWidget when changing group
f277307910 GUI: Add function in GroupListWidget to find an index from the original list
1daaf95326 GUI: Try to preserve the selection in GroupListWidget when opening or closing group


Commit: e66a8bc9d80bc6e8ab9120c47e0ad69583e93bc0
    https://github.com/scummvm/scummvm/commit/e66a8bc9d80bc6e8ab9120c47e0ad69583e93bc0
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2025-06-11T23:04:25+01:00

Commit Message:
GUI: Fix selecting some items in GroupedListWidget when groups are collapsed

In this case the number of displayed items (the _list) may be smaller
than the total number of items (the _dataList). The index passed to the
function refers to the latter, but the sanity checked compared the index
to the size of the former.

This fixes bug #15959.

Changed paths:
    gui/widgets/groupedlist.cpp


diff --git a/gui/widgets/groupedlist.cpp b/gui/widgets/groupedlist.cpp
index df730722032..5457c6949db 100644
--- a/gui/widgets/groupedlist.cpp
+++ b/gui/widgets/groupedlist.cpp
@@ -206,7 +206,7 @@ void GroupedListWidget::setSelected(int item) {
 		item = filteredItem;
 	}
 
-	if (item < -1 || item >= (int)_list.size())
+	if (item < -1 || item >= (int)_dataList.size())
 		return;
 
 	// We only have to do something if the widget is enabled and the selection actually changes


Commit: 7814999d7b31c0a517824e24841faa7dc0e6c4bc
    https://github.com/scummvm/scummvm/commit/7814999d7b31c0a517824e24841faa7dc0e6c4bc
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2025-06-11T23:04:25+01:00

Commit Message:
GUI: Simplify GroupedListWidget::setSelected(int)

The given index needs to be mapped to a displayed item index in all
cases, whether a filter is applied or not. This was done, but in a
different place of the function. This is now consolidated in a single
place.

Changed paths:
    gui/widgets/groupedlist.cpp


diff --git a/gui/widgets/groupedlist.cpp b/gui/widgets/groupedlist.cpp
index 5457c6949db..9e01bc3c5c3 100644
--- a/gui/widgets/groupedlist.cpp
+++ b/gui/widgets/groupedlist.cpp
@@ -190,22 +190,6 @@ void GroupedListWidget::saveClosedGroups(const Common::U32String &groupName) {
 }
 
 void GroupedListWidget::setSelected(int item) {
-	// HACK/FIXME: If our _listIndex has a non zero size,
-	// we will need to look up, whether the user selected
-	// item is present in that list
-	if (!_filter.empty()) {
-		int filteredItem = -1;
-
-		for (uint i = 0; i < _listIndex.size(); ++i) {
-			if (_listIndex[i] == item) {
-				filteredItem = i;
-				break;
-			}
-		}
-
-		item = filteredItem;
-	}
-
 	if (item < -1 || item >= (int)_dataList.size())
 		return;
 
@@ -214,15 +198,11 @@ void GroupedListWidget::setSelected(int item) {
 		if (_editMode)
 			abortEditMode();
 
-		if (!_filter.empty()) {
-			_selectedItem = item;
-		} else {
-			_selectedItem = -1;
-			for (uint i = 0; i < _listIndex.size(); ++i) {
-				if (_listIndex[i] == item) {
-					_selectedItem = i;
-					break;
-				}
+		_selectedItem = -1;
+		for (uint i = 0; i < _listIndex.size(); ++i) {
+			if (_listIndex[i] == item) {
+				_selectedItem = i;
+				break;
 			}
 		}
 


Commit: d6fb379297071699386e7c2390e655895eee5eb6
    https://github.com/scummvm/scummvm/commit/d6fb379297071699386e7c2390e655895eee5eb6
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2025-06-11T23:04:25+01:00

Commit Message:
GUI: Do not scroll GroupedListWidget to top when failing to select item

Setting the selected item can fail in the GroupedListWidget if the item
is not visible, either because of a filter, or because the group is
collapsed. Normally this should not happen, but could happen if for
example editing manually the lastselectedgame in the config file.

Changed paths:
    gui/widgets/groupedlist.cpp


diff --git a/gui/widgets/groupedlist.cpp b/gui/widgets/groupedlist.cpp
index 9e01bc3c5c3..81ae51f9a9d 100644
--- a/gui/widgets/groupedlist.cpp
+++ b/gui/widgets/groupedlist.cpp
@@ -209,7 +209,7 @@ void GroupedListWidget::setSelected(int item) {
 		// Notify clients that the selection changed.
 		sendCommand(kListSelectionChangedCmd, _selectedItem);
 
-		if (!isItemVisible(_selectedItem)) {
+		if (_selectedItem != -1 && !isItemVisible(_selectedItem)) {
 			// scroll selected item to center if possible
 			_currentPos = _selectedItem - _entriesPerPage / 2;
 			scrollToCurrent();


Commit: ed9748a61dad89c06f395afd093b8e7de45ee718
    https://github.com/scummvm/scummvm/commit/ed9748a61dad89c06f395afd093b8e7de45ee718
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2025-06-11T23:04:25+01:00

Commit Message:
GUI: Fix filter not applied after closing the game options

When rebuilding the list of games for the grouped list widget  we
need to apply the filter after reloading the list of closed groups.
Otherwise the filter is lost when we set the closed groups.

Changed paths:
    gui/launcher.cpp


diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index f21ec89e0e7..2595c9588f7 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -1156,12 +1156,12 @@ void LauncherSimple::updateListing(int selPos) {
 		_list->setSelected(_list->getList().size() - 1);
 	updateButtons();
 
+	// Close groups that the user closed earlier
+	_list->loadClosedGroups(Common::U32String(groupingModes[_groupBy].name));
+
 	// Update the filter settings, those are lost when "setList"
 	// is called.
 	_list->setFilter(_searchWidget->getEditString());
-
-	// Close groups that the user closed earlier
-	_list->loadClosedGroups(Common::U32String(groupingModes[_groupBy].name));
 }
 
 int LauncherSimple::getItemPos(int item) {


Commit: 60c56419a37bbfcee99b63544bcf64115fb059f8
    https://github.com/scummvm/scummvm/commit/60c56419a37bbfcee99b63544bcf64115fb059f8
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2025-06-11T23:04:25+01:00

Commit Message:
GUI: Try to preserve the selection in GroupedListWidget when changing the filter

This also ensure that kListSelectionChangedCmd command is sent even
if the selection could not be preserved, which properly disables
the buttons in the Launcher dialog.

Changed paths:
    gui/widgets/groupedlist.cpp


diff --git a/gui/widgets/groupedlist.cpp b/gui/widgets/groupedlist.cpp
index 81ae51f9a9d..0e508805706 100644
--- a/gui/widgets/groupedlist.cpp
+++ b/gui/widgets/groupedlist.cpp
@@ -415,6 +415,8 @@ void GroupedListWidget::setFilter(const Common::U32String &filter, bool redraw)
 	if (_filter == filt) // Filter was not changed
 		return;
 
+	int selectedItem = getSelected();
+
 	_filter = filt;
 
 	if (_filter.empty()) {
@@ -452,6 +454,9 @@ void GroupedListWidget::setFilter(const Common::U32String &filter, bool redraw)
 
 	_currentPos = 0;
 	_selectedItem = -1;
+	// Try to preserve the previous selection
+	if (selectedItem != -1)
+		setSelected(selectedItem);
 
 	if (redraw) {
 		scrollBarRecalc();


Commit: 2d44bc8f26fd108ca92482f7dcc06b6af1e848ce
    https://github.com/scummvm/scummvm/commit/2d44bc8f26fd108ca92482f7dcc06b6af1e848ce
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2025-06-11T23:04:25+01:00

Commit Message:
GUI: Fix preserving the selection in GroupedListWidget when changing group

The selection needs to be reset after reloading the closed groups
and reaplying the filter. Otherwise it may be lost when we do so.

Changed paths:
    gui/launcher.cpp


diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 2595c9588f7..3d98d78edd1 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -1147,6 +1147,13 @@ void LauncherSimple::updateListing(int selPos) {
 
 	groupEntries(domainList);
 
+	// Close groups that the user closed earlier
+	_list->loadClosedGroups(Common::U32String(groupingModes[_groupBy].name));
+
+	// Update the filter settings, those are lost when "setList"
+	// is called.
+	_list->setFilter(_searchWidget->getEditString());
+
 	if (_groupBy != kGroupByNone && selPos != -1) {
 		_list->setSelected(_list->getNewSel(selPos));
 	} else if (oldSel < (int)l.size() && oldSel >= 0)
@@ -1155,13 +1162,6 @@ void LauncherSimple::updateListing(int selPos) {
 		// Select the last entry if the list has been reduced
 		_list->setSelected(_list->getList().size() - 1);
 	updateButtons();
-
-	// Close groups that the user closed earlier
-	_list->loadClosedGroups(Common::U32String(groupingModes[_groupBy].name));
-
-	// Update the filter settings, those are lost when "setList"
-	// is called.
-	_list->setFilter(_searchWidget->getEditString());
 }
 
 int LauncherSimple::getItemPos(int item) {


Commit: f277307910b6d2dcd4ed89ad9af2f0b678144dd1
    https://github.com/scummvm/scummvm/commit/f277307910b6d2dcd4ed89ad9af2f0b678144dd1
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2025-06-11T23:04:25+01:00

Commit Message:
GUI: Add function in GroupListWidget to find an index from the original list

Changed paths:
    gui/widgets/groupedlist.cpp
    gui/widgets/groupedlist.h


diff --git a/gui/widgets/groupedlist.cpp b/gui/widgets/groupedlist.cpp
index 0e508805706..474d5b967d0 100644
--- a/gui/widgets/groupedlist.cpp
+++ b/gui/widgets/groupedlist.cpp
@@ -189,6 +189,19 @@ void GroupedListWidget::saveClosedGroups(const Common::U32String &groupName) {
 	ConfMan.flushToDisk();
 }
 
+int GroupedListWidget::findDataIndex(int data_index) const {
+	// The given index is an index in the _dataList.
+	// We want the index in the current _listIndex (which may be filtered and sorted) for this data.
+	// Sanity check to avoid iterating on the _listIndex if we know the given index is invalid.
+	if (data_index < -1 || data_index >= (int)_dataList.size())
+		return -1;
+	for (uint i = 0; i < _listIndex.size(); ++i) {
+		if (_listIndex[i] == data_index)
+			return i;
+	}
+	return -1;
+}
+
 void GroupedListWidget::setSelected(int item) {
 	if (item < -1 || item >= (int)_dataList.size())
 		return;
@@ -198,13 +211,7 @@ void GroupedListWidget::setSelected(int item) {
 		if (_editMode)
 			abortEditMode();
 
-		_selectedItem = -1;
-		for (uint i = 0; i < _listIndex.size(); ++i) {
-			if (_listIndex[i] == item) {
-				_selectedItem = i;
-				break;
-			}
-		}
+		_selectedItem = findDataIndex(item);
 
 		// Notify clients that the selection changed.
 		sendCommand(kListSelectionChangedCmd, _selectedItem);
diff --git a/gui/widgets/groupedlist.h b/gui/widgets/groupedlist.h
index 6b04d914795..1edabdba7d8 100644
--- a/gui/widgets/groupedlist.h
+++ b/gui/widgets/groupedlist.h
@@ -76,6 +76,7 @@ protected:
 	void sortGroups();
 	void toggleGroup(int groupID);
 	void drawWidget() override;
+	int findDataIndex(int) const;
 };
 
 } // End of namespace GUI


Commit: 1daaf95326ddf51add624929a6800cbd639925bc
    https://github.com/scummvm/scummvm/commit/1daaf95326ddf51add624929a6800cbd639925bc
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2025-06-11T23:04:25+01:00

Commit Message:
GUI: Try to preserve the selection in GroupListWidget when opening or closing group

Changed paths:
    gui/widgets/groupedlist.cpp


diff --git a/gui/widgets/groupedlist.cpp b/gui/widgets/groupedlist.cpp
index 474d5b967d0..a2b33b7fddd 100644
--- a/gui/widgets/groupedlist.cpp
+++ b/gui/widgets/groupedlist.cpp
@@ -239,8 +239,14 @@ void GroupedListWidget::handleMouseDown(int x, int y, int button, int clickCount
 			sendCommand(kListSelectionChangedCmd, _selectedItem);
 		} else if (isGroupHeader(_listIndex[newSelectedItem])) {
 			int groupID = indexToGroupID(_listIndex[newSelectedItem]);
+			int oldSelection = getSelected();
 			_selectedItem = -1;
 			toggleGroup(groupID);
+			// Try to preserve the selection, but without scrolling
+			if (oldSelection != -1) {
+				_selectedItem = findDataIndex(oldSelection);
+				sendCommand(kListSelectionChangedCmd, _selectedItem);
+			}
 		}
 	}
 




More information about the Scummvm-git-logs mailing list