mirror of https://gitlab.com/nakst/essence
prevent nesting save dialogs
This commit is contained in:
parent
b95807281d
commit
9344e3a27a
|
@ -666,6 +666,8 @@ void InstanceClose(EsInstance *instance) {
|
||||||
|
|
||||||
// TODO Handling shutdown.
|
// TODO Handling shutdown.
|
||||||
|
|
||||||
|
DialogDismissAll(instance->window); // Dismiss any dialogs that are already open, if they have cancel buttons.
|
||||||
|
|
||||||
APIInstance *apiInstance = (APIInstance *) instance->_private;
|
APIInstance *apiInstance = (APIInstance *) instance->_private;
|
||||||
char content[512];
|
char content[512];
|
||||||
size_t contentBytes;
|
size_t contentBytes;
|
||||||
|
|
|
@ -3556,9 +3556,20 @@ struct EsDialog {
|
||||||
EsElement *mainPanel;
|
EsElement *mainPanel;
|
||||||
EsElement *buttonArea;
|
EsElement *buttonArea;
|
||||||
EsElement *contentArea;
|
EsElement *contentArea;
|
||||||
|
EsButton *cancelButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
int ProcessDialogClosingMessage(EsElement *element, EsMessage *message) {
|
void DialogDismissAll(EsWindow *window) {
|
||||||
|
for (intptr_t i = window->dialogs.Length() - 1; i >= 0; i--) {
|
||||||
|
EsButton *button = window->dialogs[i]->cancelButton;
|
||||||
|
|
||||||
|
if (button && button->onCommand) {
|
||||||
|
button->onCommand(button->instance, button, button->command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int DialogClosingMessage(EsElement *element, EsMessage *message) {
|
||||||
if (message->type == ES_MSG_TRANSITION_COMPLETE) {
|
if (message->type == ES_MSG_TRANSITION_COMPLETE) {
|
||||||
// Destroy the dialog and its wrapper.
|
// Destroy the dialog and its wrapper.
|
||||||
EsElementDestroy(EsElementGetLayoutParent(element));
|
EsElementDestroy(EsElementGetLayoutParent(element));
|
||||||
|
@ -3575,7 +3586,7 @@ void EsDialogClose(EsDialog *dialog) {
|
||||||
window->dialogs.FindAndDelete(dialog, true);
|
window->dialogs.FindAndDelete(dialog, true);
|
||||||
|
|
||||||
EsAssert(dialog->mainPanel->messageClass == ProcessPanelMessage);
|
EsAssert(dialog->mainPanel->messageClass == ProcessPanelMessage);
|
||||||
dialog->mainPanel->messageClass = ProcessDialogClosingMessage;
|
dialog->mainPanel->messageClass = DialogClosingMessage;
|
||||||
EsElementStartTransition(dialog->mainPanel, ES_TRANSITION_ZOOM_OUT_LIGHT, ES_ELEMENT_TRANSITION_EXIT, 1.0f);
|
EsElementStartTransition(dialog->mainPanel, ES_TRANSITION_ZOOM_OUT_LIGHT, ES_ELEMENT_TRANSITION_EXIT, 1.0f);
|
||||||
|
|
||||||
if (!isTop) {
|
if (!isTop) {
|
||||||
|
@ -3655,7 +3666,15 @@ EsDialog *EsDialogShow(EsWindow *window, const char *title, ptrdiff_t titleBytes
|
||||||
|
|
||||||
EsButton *EsDialogAddButton(EsDialog *dialog, uint64_t flags, EsStyle *style, const char *label, ptrdiff_t labelBytes, EsCommandCallback callback) {
|
EsButton *EsDialogAddButton(EsDialog *dialog, uint64_t flags, EsStyle *style, const char *label, ptrdiff_t labelBytes, EsCommandCallback callback) {
|
||||||
EsButton *button = EsButtonCreate(dialog->buttonArea, flags, style, label, labelBytes);
|
EsButton *button = EsButtonCreate(dialog->buttonArea, flags, style, label, labelBytes);
|
||||||
if (button) EsButtonOnCommand(button, callback);
|
|
||||||
|
if (button) {
|
||||||
|
if (flags & ES_BUTTON_CANCEL) {
|
||||||
|
dialog->cancelButton = button;
|
||||||
|
}
|
||||||
|
|
||||||
|
EsButtonOnCommand(button, callback);
|
||||||
|
}
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue