Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-05-14 15:13:02 +0300
committerJacques Lucke <mail@jlucke.com>2019-05-14 15:21:17 +0300
commit687385b963f4389b3d714fed264bb0ff24bc43f5 (patch)
treeb45b5c6492361425533230e4267e848d7c383715 /source/blender/windowmanager/intern/wm_operators.c
parent37f87ae81bc31134cf985277d877afb7b922dbbc (diff)
UI: Confirm dialog when closing an unsaved file
The complexity in this patch comes from the fact that the current operator system does not support multi-step user interactions well. More specifically, for this to work, we need to show a confirm dialog and a file browser afterwards. We decided that it is easier to keep everything in a single operator, instead of creating separate operators that invoke each other. So, now the `WM_OT_open_mainfile` operator invokes itself in different states. It implements a simple finite state machine to manage the states. The dialog itself is expected to be improved in a future commit. See D4829 for more details. Reviewers: brecht Differential Revision: https://developer.blender.org/D4829
Diffstat (limited to 'source/blender/windowmanager/intern/wm_operators.c')
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 98b79fc75ce..6817a9c8719 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -884,8 +884,12 @@ int WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(eve
}
/* Can't be used as an invoke directly, needs message arg (can be NULL) */
-int WM_operator_confirm_message_ex(
- bContext *C, wmOperator *op, const char *title, const int icon, const char *message)
+int WM_operator_confirm_message_ex(bContext *C,
+ wmOperator *op,
+ const char *title,
+ const int icon,
+ const char *message,
+ const short opcontext)
{
uiPopupMenu *pup;
uiLayout *layout;
@@ -900,8 +904,7 @@ int WM_operator_confirm_message_ex(
pup = UI_popup_menu_begin(C, title, icon);
layout = UI_popup_menu_layout(pup);
- uiItemFullO_ptr(
- layout, op->type, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0, NULL);
+ uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, opcontext, 0, NULL);
UI_popup_menu_end(C, pup);
return OPERATOR_INTERFACE;
@@ -909,7 +912,8 @@ int WM_operator_confirm_message_ex(
int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message)
{
- return WM_operator_confirm_message_ex(C, op, IFACE_("OK?"), ICON_QUESTION, message);
+ return WM_operator_confirm_message_ex(
+ C, op, IFACE_("OK?"), ICON_QUESTION, message, WM_OP_EXEC_REGION_WIN);
}
int WM_operator_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))