[Scummvm-git-logs] scummvm master -> 2effd5865e52da7506056fc21e1926b58dd301d3
bluegr
noreply at scummvm.org
Tue Jun 10 05:06:45 UTC 2025
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
5f434f2a1b GUI: Only scroll list to selected item if necessary
8ce67ef55c GUI: Fix list item selection when removing game
2effd5865e GUI: Cleanup game removal code
Commit: 5f434f2a1b43e7b7a39569be9038ac97b1034772
https://github.com/scummvm/scummvm/commit/5f434f2a1b43e7b7a39569be9038ac97b1034772
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2025-06-10T08:06:41+03:00
Commit Message:
GUI: Only scroll list to selected item if necessary
Fixes launcher scrolling when removing a game
Changed paths:
gui/widgets/groupedlist.cpp
gui/widgets/list.cpp
gui/widgets/list.h
diff --git a/gui/widgets/groupedlist.cpp b/gui/widgets/groupedlist.cpp
index ec027e30368..f9ef882376a 100644
--- a/gui/widgets/groupedlist.cpp
+++ b/gui/widgets/groupedlist.cpp
@@ -229,8 +229,11 @@ void GroupedListWidget::setSelected(int item) {
// Notify clients that the selection changed.
sendCommand(kListSelectionChangedCmd, _selectedItem);
- _currentPos = _selectedItem - _entriesPerPage / 2;
- scrollToCurrent();
+ if (!isItemVisible(_selectedItem)) {
+ // scroll selected item to center if possible
+ _currentPos = _selectedItem - _entriesPerPage / 2;
+ scrollToCurrent();
+ }
markAsDirty();
}
}
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index 46aa057bfe2..936e782cf58 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -183,8 +183,11 @@ void ListWidget::setSelected(int item) {
// Notify clients that the selection changed.
sendCommand(kListSelectionChangedCmd, _selectedItem);
- _currentPos = _selectedItem - _entriesPerPage / 2;
- scrollToCurrent();
+ if (!isItemVisible(_selectedItem)) {
+ // scroll selected item to center if possible
+ _currentPos = _selectedItem - _entriesPerPage / 2;
+ scrollToCurrent();
+ }
markAsDirty();
}
}
@@ -315,8 +318,7 @@ void ListWidget::handleMouseLeft(int button) {
int ListWidget::findItem(int x, int y) const {
if (y < _topPadding) return -1;
int item = (y - _topPadding) / kLineHeight + _currentPos;
- if (item >= _currentPos && item < _currentPos + _entriesPerPage &&
- item < (int)_list.size())
+ if (isItemVisible(item) && item < (int)_list.size())
return item;
else
return -1;
diff --git a/gui/widgets/list.h b/gui/widgets/list.h
index 564e403e441..2e85474c4d4 100644
--- a/gui/widgets/list.h
+++ b/gui/widgets/list.h
@@ -121,6 +121,7 @@ public:
void scrollTo(int item);
void scrollToEnd();
int getCurrentScrollPos() const { return _currentPos; }
+ bool isItemVisible(int item) const { return _currentPos <= item && item < _currentPos + _entriesPerPage; }
void enableQuickSelect(bool enable) { _quickSelect = enable; }
Common::String getQuickSelectString() const { return _quickSelectStr; }
Commit: 8ce67ef55c6ca66569cdb904b3753236a31aa8b5
https://github.com/scummvm/scummvm/commit/8ce67ef55c6ca66569cdb904b3753236a31aa8b5
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2025-06-10T08:06:41+03:00
Commit Message:
GUI: Fix list item selection when removing game
Fixes the wrong item being selected when grouping is enabled
Changed paths:
gui/widgets/groupedlist.cpp
diff --git a/gui/widgets/groupedlist.cpp b/gui/widgets/groupedlist.cpp
index f9ef882376a..2388bd560c4 100644
--- a/gui/widgets/groupedlist.cpp
+++ b/gui/widgets/groupedlist.cpp
@@ -304,7 +304,7 @@ int GroupedListWidget::getNextPos(int oldSel) {
for (uint i = 0; i < _listIndex.size(); i++) {
if (_listIndex[i] == oldSel) {
return pos;
- } else if (_listIndex[i] > 0) {
+ } else if (_listIndex[i] >= 0) { // skip headers
pos++;
}
}
Commit: 2effd5865e52da7506056fc21e1926b58dd301d3
https://github.com/scummvm/scummvm/commit/2effd5865e52da7506056fc21e1926b58dd301d3
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2025-06-10T08:06:41+03:00
Commit Message:
GUI: Cleanup game removal code
Changed paths:
gui/launcher.cpp
gui/launcher.h
gui/widgets/grid.cpp
gui/widgets/grid.h
gui/widgets/groupedlist.cpp
gui/widgets/groupedlist.h
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index c83400d5188..f21ec89e0e7 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -450,13 +450,13 @@ void LauncherDialog::removeGame(int item) {
MessageDialog alert(_("Do you really want to remove this game configuration?"), _("Yes"), _("No"));
if (alert.runModal() == GUI::kMessageOK) {
- int nextPos = -1;
- if (_groupBy != kGroupByNone && getType() == kLauncherDisplayList) {
- // Find the position of the next item in the sorted list.
- nextPos = getNextPos(item);
- } else if (_groupBy != kGroupByNone && getType() == kLauncherDisplayGrid) {
- // Find the position of the next item in the sorted grid.
- nextPos = getNextPos(item);
+ // Get position of game item if grouping is enabled.
+ // This will be used to select the next item.
+ // If grouping method is None then updateListing() will
+ // ignore selPos and use the current selection instead.
+ int selPos = -1;
+ if (_groupBy != kGroupByNone) {
+ selPos = getItemPos(item);
}
// Remove the currently selected game from the list
@@ -467,7 +467,7 @@ void LauncherDialog::removeGame(int item) {
ConfMan.flushToDisk();
// Update the ListWidget/GridWidget and force a redraw
- updateListing(nextPos);
+ updateListing(selPos);
g_gui.scheduleTopDialogRedraw();
}
}
@@ -995,7 +995,7 @@ public:
protected:
void updateListing(int selPos = -1) override;
- int getNextPos(int item) override;
+ int getItemPos(int item) override;
void groupEntries(const Common::Array<LauncherEntry> &metadata);
void updateButtons() override;
void selectTarget(const Common::String &target) override;
@@ -1111,20 +1111,19 @@ void LauncherSimple::build() {
void LauncherSimple::updateListing(int selPos) {
Common::U32StringArray l;
- ThemeEngine::FontColor color;
- int numEntries = ConfMan.getInt("gui_list_max_scan_entries");
+ const int numEntries = ConfMan.getInt("gui_list_max_scan_entries");
// Retrieve a list of all games defined in the config file
_domains.clear();
const Common::ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
- bool scanEntries = numEntries == -1 ? true : ((int)domains.size() <= numEntries);
+ const bool scanEntries = (numEntries == -1) || ((int)domains.size() <= numEntries);
// Turn it into a sorted list of entries
Common::Array<LauncherEntry> domainList = generateEntries(domains);
// And fill out our structures
for (const auto &curDomain : domainList) {
- color = ThemeEngine::kFontColorNormal;
+ ThemeEngine::FontColor color = ThemeEngine::kFontColorNormal;
if (scanEntries) {
Common::String path;
@@ -1165,8 +1164,8 @@ void LauncherSimple::updateListing(int selPos) {
_list->loadClosedGroups(Common::U32String(groupingModes[_groupBy].name));
}
-int LauncherSimple::getNextPos(int item) {
- return _list->getNextPos(item);
+int LauncherSimple::getItemPos(int item) {
+ return _list->getItemPos(item);
}
void LauncherSimple::groupEntries(const Common::Array<LauncherEntry> &metadata) {
@@ -1596,8 +1595,8 @@ void LauncherGrid::updateListing(int selPos) {
_grid->loadClosedGroups(Common::U32String(groupingModes[_groupBy].name));
}
-int LauncherGrid::getNextPos(int oldSel) {
- return _grid->getNextPos(oldSel);
+int LauncherGrid::getItemPos(int item) {
+ return _grid->getItemPos(item);
}
void LauncherGrid::updateButtons() {
diff --git a/gui/launcher.h b/gui/launcher.h
index efe7cdc3c83..2831f6ae3a9 100644
--- a/gui/launcher.h
+++ b/gui/launcher.h
@@ -166,7 +166,7 @@ protected:
*/
virtual void updateListing(int selPos = -1) = 0;
- virtual int getNextPos(int item) = 0;
+ virtual int getItemPos(int item) = 0;
virtual void updateButtons() = 0;
@@ -242,7 +242,7 @@ public:
protected:
void updateListing(int selPos = -1) override;
- int getNextPos(int item) override;
+ int getItemPos(int item) override;
void groupEntries(const Common::Array<LauncherEntry> &metadata);
void updateButtons() override;
void selectTarget(const Common::String &target) override;
diff --git a/gui/widgets/grid.cpp b/gui/widgets/grid.cpp
index 83efc40d25f..9246f2ee1da 100644
--- a/gui/widgets/grid.cpp
+++ b/gui/widgets/grid.cpp
@@ -888,12 +888,11 @@ void GridWidget::assignEntriesToItems() {
}
}
-int GridWidget::getNextPos(int oldSel) {
+int GridWidget::getItemPos(int item) {
int pos = 0;
- // Find the next item in the grid
for (uint i = 0; i < _sortedEntryList.size(); i++) {
- if (_sortedEntryList[i]->entryID == oldSel) {
+ if (_sortedEntryList[i]->entryID == item) {
return pos;
} else if (!_sortedEntryList[i]->isHeader) {
pos++;
diff --git a/gui/widgets/grid.h b/gui/widgets/grid.h
index 54db57ca393..2484a5c50c7 100644
--- a/gui/widgets/grid.h
+++ b/gui/widgets/grid.h
@@ -210,7 +210,7 @@ public:
void scrollToEntry(int id, bool forceToTop);
void assignEntriesToItems();
- int getNextPos(int oldSel);
+ int getItemPos(int item);
int getNewSel(int index);
int getScrollPos() const { return _scrollPos; }
int getSelected() const { return ((_selectedEntry == nullptr) ? -1 : _selectedEntry->entryID); }
diff --git a/gui/widgets/groupedlist.cpp b/gui/widgets/groupedlist.cpp
index 2388bd560c4..df730722032 100644
--- a/gui/widgets/groupedlist.cpp
+++ b/gui/widgets/groupedlist.cpp
@@ -297,12 +297,11 @@ void GroupedListWidget::handleCommand(CommandSender *sender, uint32 cmd, uint32
}
}
-int GroupedListWidget::getNextPos(int oldSel) {
+int GroupedListWidget::getItemPos(int item) {
int pos = 0;
- // Find the position of the new selection in the list.
for (uint i = 0; i < _listIndex.size(); i++) {
- if (_listIndex[i] == oldSel) {
+ if (_listIndex[i] == item) {
return pos;
} else if (_listIndex[i] >= 0) { // skip headers
pos++;
diff --git a/gui/widgets/groupedlist.h b/gui/widgets/groupedlist.h
index 4cc97368c48..6b04d914795 100644
--- a/gui/widgets/groupedlist.h
+++ b/gui/widgets/groupedlist.h
@@ -67,7 +67,7 @@ public:
void setGroupsVisibility(bool val) { _groupsVisible = val; }
- int getNextPos(int oldSel);
+ int getItemPos(int item);
int getNewSel(int index);
void startEditMode() override { error("Edit mode is not supported for Grouped Lists"); }
More information about the Scummvm-git-logs
mailing list