[Scummvm-git-logs] scummvm master -> a82b200ae71f6b5ee9a13778974f33983e0a32aa
bluegr
bluegr at gmail.com
Sun Jan 10 07:53:47 UTC 2021
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:
a82b200ae7 GUI: Allow specifying a command for PopUp widgets
Commit: a82b200ae71f6b5ee9a13778974f33983e0a32aa
https://github.com/scummvm/scummvm/commit/a82b200ae71f6b5ee9a13778974f33983e0a32aa
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-01-10T09:53:43+02:00
Commit Message:
GUI: Allow specifying a command for PopUp widgets
Changed paths:
gui/options.cpp
gui/widgets/popup.cpp
gui/widgets/popup.h
diff --git a/gui/options.cpp b/gui/options.cpp
index ca78c7152a..131f64340a 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -113,6 +113,7 @@ enum {
#ifdef USE_CLOUD
enum {
+ kStoragePopUpCmd = 'sPup',
kSyncSavesStorageCmd = 'ssst',
kDownloadStorageCmd = 'dlst',
kRunServerCmd = 'rnsv',
@@ -2194,7 +2195,7 @@ void GlobalOptionsDialog::addMiscControls(GuiObject *boss, const Common::String
#ifdef USE_LIBCURL
void GlobalOptionsDialog::addCloudControls(GuiObject *boss, const Common::String &prefix, bool lowres) {
_storagePopUpDesc = new StaticTextWidget(boss, prefix + "StoragePopupDesc", _("Active storage:"), _("Active cloud storage"));
- _storagePopUp = new PopUpWidget(boss, prefix + "StoragePopup");
+ _storagePopUp = new PopUpWidget(boss, prefix + "StoragePopup", Common::U32String(), kStoragePopUpCmd);
Common::StringArray list = CloudMan.listStorages();
for (uint32 i = 0; i < list.size(); ++i) {
_storagePopUp->appendEntry(_(list[i]), i);
@@ -2643,7 +2644,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
setupCloudTab();
break;
}
- case kPopUpItemSelectedCmd: {
+ case kStoragePopUpCmd: {
if (_storageWizardCodeBox)
_storageWizardCodeBox->setEditString(Common::U32String());
// update container's scrollbar
diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp
index 148abd7be0..8170bdb71d 100644
--- a/gui/widgets/popup.cpp
+++ b/gui/widgets/popup.cpp
@@ -428,19 +428,21 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) {
// PopUpWidget
//
-PopUpWidget::PopUpWidget(GuiObject *boss, const String &name, const U32String &tooltip)
+PopUpWidget::PopUpWidget(GuiObject *boss, const String &name, const U32String &tooltip, uint32 cmd)
: Widget(boss, name, tooltip), CommandSender(boss) {
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_IGNORE_DRAG);
_type = kPopUpWidget;
+ _cmd = cmd;
_selectedItem = -1;
_leftPadding = _rightPadding = 0;
}
-PopUpWidget::PopUpWidget(GuiObject *boss, int x, int y, int w, int h, const U32String &tooltip)
+PopUpWidget::PopUpWidget(GuiObject *boss, int x, int y, int w, int h, const U32String &tooltip, uint32 cmd)
: Widget(boss, x, y, w, h, tooltip), CommandSender(boss) {
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_IGNORE_DRAG);
_type = kPopUpWidget;
+ _cmd = cmd;
_selectedItem = -1;
@@ -463,7 +465,7 @@ void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount) {
int newSel = popupDialog.runModal();
if (newSel != -1 && _selectedItem != newSel) {
_selectedItem = newSel;
- sendCommand(kPopUpItemSelectedCmd, _entries[_selectedItem].tag);
+ sendCommand(_cmd, _entries[_selectedItem].tag);
markAsDirty();
}
}
@@ -483,7 +485,7 @@ void PopUpWidget::handleMouseWheel(int x, int y, int direction) {
if ((newSelection >= 0) && (newSelection < (int)_entries.size()) &&
(newSelection != _selectedItem)) {
_selectedItem = newSelection;
- sendCommand(kPopUpItemSelectedCmd, _entries[_selectedItem].tag);
+ sendCommand(_cmd, _entries[_selectedItem].tag);
markAsDirty();
}
}
diff --git a/gui/widgets/popup.h b/gui/widgets/popup.h
index 79e0f57449..b066aa5613 100644
--- a/gui/widgets/popup.h
+++ b/gui/widgets/popup.h
@@ -30,15 +30,11 @@
namespace GUI {
-enum {
- kPopUpItemSelectedCmd = 'POPs'
-};
-
/**
* Popup or dropdown widget which, when clicked, "pop up" a list of items and
* lets the user pick on of them.
*
- * Implementation wise, when the user selects an item, then a kPopUpItemSelectedCmd
+ * Implementation wise, when the user selects an item, then the specified command
* is broadcast, with data being equal to the tag value of the selected entry.
*/
class PopUpWidget : public Widget, public CommandSender {
@@ -56,10 +52,11 @@ protected:
int _leftPadding;
int _rightPadding;
+ uint32 _cmd;
public:
- PopUpWidget(GuiObject *boss, const String &name, const U32String &tooltip = U32String());
- PopUpWidget(GuiObject *boss, int x, int y, int w, int h, const U32String &tooltip = U32String());
+ PopUpWidget(GuiObject *boss, const String &name, const U32String &tooltip = U32String(), uint32 cmd = 0);
+ PopUpWidget(GuiObject *boss, int x, int y, int w, int h, const U32String &tooltip = U32String(), uint32 cmd = 0);
void handleMouseDown(int x, int y, int button, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override;
More information about the Scummvm-git-logs
mailing list