GUI: Allow specifying a command for PopUp widgets
This commit is contained in:
parent
89e9932cc3
commit
a82b200ae7
3 changed files with 13 additions and 13 deletions
|
@ -113,6 +113,7 @@ enum {
|
||||||
|
|
||||||
#ifdef USE_CLOUD
|
#ifdef USE_CLOUD
|
||||||
enum {
|
enum {
|
||||||
|
kStoragePopUpCmd = 'sPup',
|
||||||
kSyncSavesStorageCmd = 'ssst',
|
kSyncSavesStorageCmd = 'ssst',
|
||||||
kDownloadStorageCmd = 'dlst',
|
kDownloadStorageCmd = 'dlst',
|
||||||
kRunServerCmd = 'rnsv',
|
kRunServerCmd = 'rnsv',
|
||||||
|
@ -2194,7 +2195,7 @@ void GlobalOptionsDialog::addMiscControls(GuiObject *boss, const Common::String
|
||||||
#ifdef USE_LIBCURL
|
#ifdef USE_LIBCURL
|
||||||
void GlobalOptionsDialog::addCloudControls(GuiObject *boss, const Common::String &prefix, bool lowres) {
|
void GlobalOptionsDialog::addCloudControls(GuiObject *boss, const Common::String &prefix, bool lowres) {
|
||||||
_storagePopUpDesc = new StaticTextWidget(boss, prefix + "StoragePopupDesc", _("Active storage:"), _("Active cloud storage"));
|
_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();
|
Common::StringArray list = CloudMan.listStorages();
|
||||||
for (uint32 i = 0; i < list.size(); ++i) {
|
for (uint32 i = 0; i < list.size(); ++i) {
|
||||||
_storagePopUp->appendEntry(_(list[i]), i);
|
_storagePopUp->appendEntry(_(list[i]), i);
|
||||||
|
@ -2643,7 +2644,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
|
||||||
setupCloudTab();
|
setupCloudTab();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kPopUpItemSelectedCmd: {
|
case kStoragePopUpCmd: {
|
||||||
if (_storageWizardCodeBox)
|
if (_storageWizardCodeBox)
|
||||||
_storageWizardCodeBox->setEditString(Common::U32String());
|
_storageWizardCodeBox->setEditString(Common::U32String());
|
||||||
// update container's scrollbar
|
// update container's scrollbar
|
||||||
|
|
|
@ -428,19 +428,21 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) {
|
||||||
// PopUpWidget
|
// 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) {
|
: Widget(boss, name, tooltip), CommandSender(boss) {
|
||||||
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_IGNORE_DRAG);
|
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_IGNORE_DRAG);
|
||||||
_type = kPopUpWidget;
|
_type = kPopUpWidget;
|
||||||
|
_cmd = cmd;
|
||||||
|
|
||||||
_selectedItem = -1;
|
_selectedItem = -1;
|
||||||
_leftPadding = _rightPadding = 0;
|
_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) {
|
: Widget(boss, x, y, w, h, tooltip), CommandSender(boss) {
|
||||||
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_IGNORE_DRAG);
|
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_IGNORE_DRAG);
|
||||||
_type = kPopUpWidget;
|
_type = kPopUpWidget;
|
||||||
|
_cmd = cmd;
|
||||||
|
|
||||||
_selectedItem = -1;
|
_selectedItem = -1;
|
||||||
|
|
||||||
|
@ -463,7 +465,7 @@ void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount) {
|
||||||
int newSel = popupDialog.runModal();
|
int newSel = popupDialog.runModal();
|
||||||
if (newSel != -1 && _selectedItem != newSel) {
|
if (newSel != -1 && _selectedItem != newSel) {
|
||||||
_selectedItem = newSel;
|
_selectedItem = newSel;
|
||||||
sendCommand(kPopUpItemSelectedCmd, _entries[_selectedItem].tag);
|
sendCommand(_cmd, _entries[_selectedItem].tag);
|
||||||
markAsDirty();
|
markAsDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -483,7 +485,7 @@ void PopUpWidget::handleMouseWheel(int x, int y, int direction) {
|
||||||
if ((newSelection >= 0) && (newSelection < (int)_entries.size()) &&
|
if ((newSelection >= 0) && (newSelection < (int)_entries.size()) &&
|
||||||
(newSelection != _selectedItem)) {
|
(newSelection != _selectedItem)) {
|
||||||
_selectedItem = newSelection;
|
_selectedItem = newSelection;
|
||||||
sendCommand(kPopUpItemSelectedCmd, _entries[_selectedItem].tag);
|
sendCommand(_cmd, _entries[_selectedItem].tag);
|
||||||
markAsDirty();
|
markAsDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,15 +30,11 @@
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
enum {
|
|
||||||
kPopUpItemSelectedCmd = 'POPs'
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Popup or dropdown widget which, when clicked, "pop up" a list of items and
|
* Popup or dropdown widget which, when clicked, "pop up" a list of items and
|
||||||
* lets the user pick on of them.
|
* 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.
|
* is broadcast, with data being equal to the tag value of the selected entry.
|
||||||
*/
|
*/
|
||||||
class PopUpWidget : public Widget, public CommandSender {
|
class PopUpWidget : public Widget, public CommandSender {
|
||||||
|
@ -56,10 +52,11 @@ protected:
|
||||||
|
|
||||||
int _leftPadding;
|
int _leftPadding;
|
||||||
int _rightPadding;
|
int _rightPadding;
|
||||||
|
uint32 _cmd;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PopUpWidget(GuiObject *boss, const String &name, 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());
|
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 handleMouseDown(int x, int y, int button, int clickCount) override;
|
||||||
void handleMouseWheel(int x, int y, int direction) override;
|
void handleMouseWheel(int x, int y, int direction) override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue