[Scummvm-git-logs] scummvm master -> 697840c372e4a067fc8e7fda8dfc3175452ac76d

sluicebox noreply at scummvm.org
Thu May 23 01:47:12 UTC 2024


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

Summary:
e83073df0a GUI: Disable quick select on save/load list
7fb6052aa7 GUI: Allow delete/backspace on editable ListWidgets
4308849811 GUI: Add ListWidget commands: single click and edit start
697840c372 GUI: Improve save/load list input handling


Commit: e83073df0ab8420f67ea5b8de361f50578c1424f
    https://github.com/scummvm/scummvm/commit/e83073df0ab8420f67ea5b8de361f50578c1424f
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-05-22T21:47:07-04:00

Commit Message:
GUI: Disable quick select on save/load list

Fixes alphanumeric keys causing unpredictable item selection.
Quick select is only for sorted lists.

Changed paths:
    gui/saveload-dialog.cpp


diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp
index c764f29c70c..668025e6e70 100644
--- a/gui/saveload-dialog.cpp
+++ b/gui/saveload-dialog.cpp
@@ -444,6 +444,7 @@ SaveLoadChooserSimple::SaveLoadChooserSimple(const Common::U32String &title, con
 	_list = new ListWidget(this, "SaveLoadChooser.List");
 	_list->setNumberingMode(kListNumberingZero);
 	_list->setEditable(saveMode);
+	_list->enableQuickSelect(false); // quick select is only useful on sorted list
 
 	_gfxWidget = new GraphicsWidget(this, 0, 0, 10, 10);
 


Commit: 7fb6052aa73c714114e94ad1e76cc13ab56522e1
    https://github.com/scummvm/scummvm/commit/7fb6052aa73c714114e94ad1e76cc13ab56522e1
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-05-22T21:47:07-04:00

Commit Message:
GUI: Allow delete/backspace on editable ListWidgets

Fixes the delete/backspace hotkey on the save list dialog; it was only
working on the load list even though they both have the same delete
functionality.

This is a check from 17 years ago that I believe was confused and had
no effect at the time. I believe the intent was to ignore these keys
while in edit mode, which makes sense, but instead this code ignored
these keys on all editable lists when *not* in edit mode. This wasn't
noticeable because there's only one editable ListWidget in ScummVM,
the save list, and it didn't listen for kListItemRemovalRequestCmd
until three years ago: aac1eb12bf9e91b880e4f1f8e73e69ede402cf45

Changed paths:
    gui/widgets/list.cpp


diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index f739ba1f39c..c3cee87c619 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -406,11 +406,7 @@ bool ListWidget::handleKeyDown(Common::KeyState state) {
 		case Common::KEYCODE_BACKSPACE:
 		case Common::KEYCODE_DELETE:
 			if (_selectedItem >= 0) {
-				if (_editable) {
-					// Ignore delete and backspace when the list item is editable
-				} else {
-					sendCommand(kListItemRemovalRequestCmd, _selectedItem);
-				}
+				sendCommand(kListItemRemovalRequestCmd, _selectedItem);
 			}
 			break;
 


Commit: 4308849811f6e270a3997bc2cad8863668271bbb
    https://github.com/scummvm/scummvm/commit/4308849811f6e270a3997bc2cad8863668271bbb
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-05-22T21:47:07-04:00

Commit Message:
GUI: Add ListWidget commands: single click and edit start

These commands allow greater control over editable ListWidgets, although
the save dialog's list is currently the only one.

kListItemSingleClickedCmd allows clients to respond to selection changes
based on the method used (mouse vs keyboard) and allows responding to
clicking on an already selected item. In the next commit, this will fix
multiple save issues.

kListItemEditModeStartedCmd allows clients to initialize edit mode
consistently. The save dialog has been doing custom initialization after
calling startEditMode, but this is incorrect because ListWidget calls
startEditMode in response to Enter, so the initialization is skipped.

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


diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index c3cee87c619..20598e41332 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -262,11 +262,15 @@ void ListWidget::handleMouseDown(int x, int y, int button, int clickCount) {
 		sendCommand(kListSelectionChangedCmd, _selectedItem);
 	}
 
+	// Notify clients if an item was clicked
+	if (newSelectedItem >= 0) {
+		sendCommand(kListItemSingleClickedCmd, _selectedItem);
+	}
+
 	// TODO: Determine where inside the string the user clicked and place the
 	// caret accordingly.
 	// See _editScrollOffset and EditTextWidget::handleMouseDown.
 	markAsDirty();
-
 }
 
 void ListWidget::handleMouseUp(int x, int y, int button, int clickCount) {
@@ -685,6 +689,7 @@ void ListWidget::startEditMode() {
 		_editColor = ThemeEngine::kFontColorNormal;
 		markAsDirty();
 		g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
+		sendCommand(kListItemEditModeStartedCmd, _selectedItem);
 	}
 }
 
diff --git a/gui/widgets/list.h b/gui/widgets/list.h
index 72ce9d3a844..564e403e441 100644
--- a/gui/widgets/list.h
+++ b/gui/widgets/list.h
@@ -39,9 +39,11 @@ enum NumberingMode {
 
 /// Some special commands
 enum {
-	kListItemDoubleClickedCmd	= 'LIdb',	///< double click on item - 'data' will be item index
+	kListItemSingleClickedCmd	= 'LIsc',	///< single click on item (sent on mouse down) - 'data' will be item index
+	kListItemDoubleClickedCmd	= 'LIdc',	///< double click on item (sent on mouse up) - 'data' will be item index
 	kListItemActivatedCmd		= 'LIac',	///< item activated by return/enter - 'data' will be item index
 	kListItemRemovalRequestCmd	= 'LIrm',	///< request to remove the item with the delete/backspace keys - 'data' will be item index
+	kListItemEditModeStartedCmd = 'LIes',	///< edit mode started - 'data' will be item index
 	kListSelectionChangedCmd	= 'Lsch'	///< selection changed - 'data' will be item index
 };
 


Commit: 697840c372e4a067fc8e7fda8dfc3175452ac76d
    https://github.com/scummvm/scummvm/commit/697840c372e4a067fc8e7fda8dfc3175452ac76d
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-05-22T21:47:07-04:00

Commit Message:
GUI: Improve save/load list input handling

- Selecting a list item with the keyboard no longer automatically enters
  edit mode; this makes keyboard navigation on the save list possible
  because subsequent keys are no longer trapped by the text field.
- Clicking a selected item that's not in edit mode will now correctly
  cause it to enter edit mode, instead of doing nothing.
- "Untitled saved game" edit mode initialization is no longer skipped
  when entering edit mode by pressing the Enter key.
- Deleting an item now leaves the slot selected so that the selection
  can be changed with the keyboard.

Changed paths:
    gui/saveload-dialog.cpp


diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp
index 668025e6e70..4ccb43ce8ac 100644
--- a/gui/saveload-dialog.cpp
+++ b/gui/saveload-dialog.cpp
@@ -496,6 +496,19 @@ void SaveLoadChooserSimple::handleCommand(CommandSender *sender, uint32 cmd, uin
 	int selItem = _list->getSelected();
 
 	switch (cmd) {
+	case kListItemSingleClickedCmd:
+		// This command is sent even if an item is clicked while in edit mode,
+		// but that's okay because startEditMode() does nothing when editing.
+		if (_list->isEditable() && _chooseButton->isEnabled()) {
+			_list->startEditMode();
+		}
+		break;
+	case kListItemEditModeStartedCmd:
+		if (_list->getSelectedString() == _("Untitled saved game")) {
+			_list->setEditString(Common::U32String());
+			_list->setEditColor(ThemeEngine::kFontColorNormal);
+		}
+		break;
 	case kListItemActivatedCmd:
 	case kListItemDoubleClickedCmd:
 		if (selItem >= 0 && _chooseButton->isEnabled()) {
@@ -530,10 +543,8 @@ void SaveLoadChooserSimple::handleCommand(CommandSender *sender, uint32 cmd, uin
 
 				setResult(-1);
 				int scrollPos = _list->getCurrentScrollPos();
-				_list->setSelected(-1); // resets scroll pos
+				updateSaveList(); // resets scroll pos
 				_list->scrollTo(scrollPos);
-
-				updateSaveList();
 				updateSelection(true);
 			}
 		}
@@ -622,7 +633,6 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) {
 
 	bool isDeletable = _delSupport;
 	bool isWriteProtected = false;
-	bool startEditMode = _list->isEditable();
 	bool isLocked = false;
 
 	// We used to support letting the themes specify the fill color with our
@@ -642,10 +652,6 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) {
 			_saveList[selItem].getWriteProtectedFlag();
 		isLocked = desc.getLocked();
 
-		// Don't allow the user to change the description of write protected games
-		if (isWriteProtected)
-			startEditMode = false;
-
 		if (_thumbnailSupport) {
 			const Graphics::Surface *thumb = desc.getThumbnail();
 			if (thumb && _gfxWidget->isVisible())
@@ -669,20 +675,10 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) {
 		}
 	}
 
-
 	if (_list->isEditable()) {
 		// Disable the save button if slot is locked, nothing is selected,
 		// or if the selected game is write protected
 		_chooseButton->setEnabled(!isLocked && selItem >= 0 && !isWriteProtected);
-
-		if (startEditMode) {
-			_list->startEditMode();
-
-			if (_chooseButton->isEnabled() && _list->getSelectedString() == _("Untitled saved game")) {
-				_list->setEditString(Common::U32String());
-				_list->setEditColor(ThemeEngine::kFontColorNormal);
-			}
-		}
 	} else {
 		// Disable the load button if slot is locked, nothing is selected,
 		// or if an empty list item is selected.




More information about the Scummvm-git-logs mailing list