[Scummvm-git-logs] scummvm master -> a38ae354af31077d9396470d8e3fcc4cc911fa44
eriktorbjorn
noreply at scummvm.org
Sun Nov 19 14:47:11 UTC 2023
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:
a38ae354af SCUMM: Require Mac widgets to return true/false from handleMouseUp()
Commit: a38ae354af31077d9396470d8e3fcc4cc911fa44
https://github.com/scummvm/scummvm/commit/a38ae354af31077d9396470d8e3fcc4cc911fa44
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2023-11-19T15:45:39+01:00
Commit Message:
SCUMM: Require Mac widgets to return true/false from handleMouseUp()
Returning true means runDialog() returns so that the function that calls
it can act. Also, it's the "Open" button's responsibility to figure out
which save slot to use, not the list box. We may not have clicked on a
save slot yet. (I hope I understood this correctly.)
Changed paths:
engines/scumm/gfx_mac.cpp
engines/scumm/gfx_mac.h
diff --git a/engines/scumm/gfx_mac.cpp b/engines/scumm/gfx_mac.cpp
index 36ebb56b1cc..6f4aaca34b1 100644
--- a/engines/scumm/gfx_mac.cpp
+++ b/engines/scumm/gfx_mac.cpp
@@ -488,9 +488,10 @@ void MacGui::MacCheckbox::draw(bool drawFocused) {
_fullRedraw = false;
}
-void MacGui::MacCheckbox::handleMouseUp(Common::Event &event) {
+bool MacGui::MacCheckbox::handleMouseUp(Common::Event &event) {
_value = _value ? 0 : 1;
setRedraw();
+ return true;
}
// ---------------------------------------------------------------------------
@@ -1206,7 +1207,7 @@ void MacGui::MacSlider::handleMouseDown(Common::Event &event) {
redrawHandle(oldValue, _value);
}
-void MacGui::MacSlider::handleMouseUp(Common::Event &event) {
+bool MacGui::MacSlider::handleMouseUp(Common::Event &event) {
if (_upArrowPressed) {
_upArrowPressed = false;
drawUpArrow(true);
@@ -1230,6 +1231,8 @@ void MacGui::MacSlider::handleMouseUp(Common::Event &event) {
_handlePos = -1;
_clickPos.x = -1;
_clickPos.y = -1;
+
+ return false;
}
void MacGui::MacSlider::handleMouseMove(Common::Event &event) {
@@ -1434,7 +1437,7 @@ void MacGui::MacPictureSlider::handleMouseDown(Common::Event &event) {
handleMouseMove(event);
}
-void MacGui::MacPictureSlider::handleMouseUp(Common::Event &event) {
+bool MacGui::MacPictureSlider::handleMouseUp(Common::Event &event) {
// Erase the drag rect, since the handle might not end up in
// the exact same spot.
int newValue = calculateValueFromPos();
@@ -1445,6 +1448,8 @@ void MacGui::MacPictureSlider::handleMouseUp(Common::Event &event) {
eraseHandle();
setValue(newValue);
drawHandle();
+
+ return false;
}
void MacGui::MacPictureSlider::handleMouseMove(Common::Event &event) {
@@ -1559,9 +1564,7 @@ void MacGui::MacListBox::draw(bool drawFocused) {
}
void MacGui::MacListBox::handleMouseDown(Common::Event &event) {
- Common::Point mousePos = _window->getMousePos();
-
- if (_slider->findWidget(mousePos.x, mousePos.y)) {
+ if (_slider->findWidget(event.mouse.x, event.mouse.y)) {
int oldValue = _slider->getValue();
_sliderFocused = true;
@@ -1576,14 +1579,25 @@ void MacGui::MacListBox::handleMouseDown(Common::Event &event) {
int offset = _slider->getValue();
for (uint i = 0; i < _textWidgets.size(); i++) {
- if (_textWidgets[i]->findWidget(mousePos.x, mousePos.y)) {
+ if (_textWidgets[i]->findWidget(event.mouse.x, event.mouse.y)) {
setValue(i + offset);
break;
}
}
}
-void MacGui::MacListBox::handleMouseUp(Common::Event &event) {
+void MacGui::MacListBox::handleDoubleClick(Common::Event &event) {
+ int offset = _slider->getValue();
+
+ for (uint i = 0; i < _textWidgets.size(); i++) {
+ if (_textWidgets[i]->findWidget(event.mouse.x, event.mouse.y)) {
+ debug("Double-clicked on '%s'", _texts[i + offset].c_str());
+ break;
+ }
+ }
+}
+
+bool MacGui::MacListBox::handleMouseUp(Common::Event &event) {
if (_sliderFocused) {
int oldValue = _slider->getValue();
@@ -1593,6 +1607,8 @@ void MacGui::MacListBox::handleMouseUp(Common::Event &event) {
if (_slider->getValue() != oldValue)
updateTexts();
}
+
+ return false;
}
void MacGui::MacListBox::handleMouseMove(Common::Event &event) {
@@ -2029,10 +2045,11 @@ int MacGui::MacDialogWindow::runDialog(Common::Array<int> &deferredActionIds) {
updateCursor();
if (widget->findWidget(event.mouse.x, event.mouse.y)) {
- clearFocusedWidget();
widgetId = widget->getId();
- widget->handleMouseUp(event);
- return widgetId;
+ if (widget->handleMouseUp(event)) {
+ clearFocusedWidget();
+ return widgetId;
+ }
}
clearFocusedWidget();
@@ -3493,6 +3510,9 @@ bool MacLoomGui::runOpenDialog(int &saveSlotToHandle) {
int clicked = window->runDialog(deferredActionsIds);
if (clicked == 0) {
+ saveSlotToHandle =
+ window->getWidgetValue(3) < ARRAYSIZE(slotIds) ?
+ slotIds[window->getWidgetValue(3)] : -1;
ret = true;
break;
}
@@ -3504,12 +3524,6 @@ bool MacLoomGui::runOpenDialog(int &saveSlotToHandle) {
if (runOkCancelDialog("Are you sure you want to delete the saved game?"))
runOkCancelDialog("Deleting savegames is currently unsupported in ScummVM.");
}
-
- if (clicked == 3) {
- saveSlotToHandle =
- window->getWidgetValue(3) < ARRAYSIZE(slotIds) ?
- slotIds[window->getWidgetValue(3)] : -1;
- }
}
delete window;
@@ -5260,16 +5274,13 @@ bool MacIndy3Gui::runOpenDialog(int &saveSlotToHandle) {
if (clicked == 0) {
ret = true;
+ saveSlotToHandle =
+ listBox->getValue() < ARRAYSIZE(slotIds) ? slotIds[listBox->getValue()] : -1;
break;
}
if (clicked == 2)
break;
-
- if (clicked == 10) {
- saveSlotToHandle =
- listBox->getValue() < ARRAYSIZE(slotIds) ? slotIds[listBox->getValue()] : -1;
- }
}
delete window;
diff --git a/engines/scumm/gfx_mac.h b/engines/scumm/gfx_mac.h
index 0c5e07da6ef..fc33d70d7f8 100644
--- a/engines/scumm/gfx_mac.h
+++ b/engines/scumm/gfx_mac.h
@@ -194,12 +194,12 @@ public:
virtual void draw(bool drawFocused = false) = 0;
virtual void handleMouseDown(Common::Event &event) {}
- virtual void handleMouseUp(Common::Event &event) {}
+ virtual void handleDoubleClick(Common::Event &event) {}
+ virtual bool handleMouseUp(Common::Event &event) { return false; }
virtual void handleMouseMove(Common::Event &event) {}
virtual void handleMouseHeld() {}
virtual void handleWheelUp() {}
virtual void handleWheelDown() {}
- virtual void handleDoubleClick(Common::Event &event) {}
virtual bool handleKeyDown(Common::Event &event) { return false; }
};
@@ -215,6 +215,8 @@ public:
MacButton(MacGui::MacDialogWindow *window, Common::Rect bounds, Common::String text, bool enabled) : MacWidget(window, bounds, text, enabled) {}
void draw(bool drawFocused = false);
+
+ bool handleMouseUp(Common::Event &event) { return true; }
};
class MacCheckbox : public MacWidget {
@@ -226,7 +228,7 @@ public:
bool findWidget(int x, int y) const;
void draw(bool drawFocused = false);
- void handleMouseUp(Common::Event &event);
+ bool handleMouseUp(Common::Event &event);
};
// The dialogs add texts as disabled, but we don't want it to be drawn
@@ -382,7 +384,7 @@ public:
void redrawHandle(int oldValue, int newValue);
void handleMouseDown(Common::Event &event);
- void handleMouseUp(Common::Event &event);
+ bool handleMouseUp(Common::Event &event);
void handleMouseMove(Common::Event &event);
void handleMouseHeld();
void handleWheelUp();
@@ -409,7 +411,7 @@ public:
void draw(bool drawFocused = false);
void handleMouseDown(Common::Event &event);
- void handleMouseUp(Common::Event &event);
+ bool handleMouseUp(Common::Event &event);
void handleMouseMove(Common::Event &event);
void handleWheelUp();
void handleWheelDown();
@@ -448,7 +450,8 @@ public:
void draw(bool drawFocused = false);
void handleMouseDown(Common::Event &event);
- void handleMouseUp(Common::Event &event);
+ void handleDoubleClick(Common::Event &event);
+ bool handleMouseUp(Common::Event &event);
void handleMouseMove(Common::Event &event);
void handleMouseHeld();
void handleWheelUp();
More information about the Scummvm-git-logs
mailing list