Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_operators.c
| Show First 20 Lines • Show All 1,391 Lines • ▼ Show 20 Lines | static void wm_operator_ui_popup_ok(struct bContext *C, void *arg, int retval) | ||||
| if (op && retval > 0) { | if (op && retval > 0) { | ||||
| WM_operator_call_ex(C, op, true); | WM_operator_call_ex(C, op, true); | ||||
| } | } | ||||
| MEM_freeN(data); | MEM_freeN(data); | ||||
| } | } | ||||
| int WM_operator_ui_popup(bContext *C, wmOperator *op, int width, int height) | int WM_operator_ui_popup(bContext *C, wmOperator *op, int width) | ||||
| { | { | ||||
| wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_ui_popup"); | wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_ui_popup"); | ||||
| data->op = op; | data->op = op; | ||||
| data->width = width * U.dpi_fac; | data->width = width * U.dpi_fac; | ||||
| data->height = height * U.dpi_fac; | /* Actual used height depends on the content. */ | ||||
| data->height = 0; | |||||
| data->free_op = true; /* if this runs and gets registered we may want not to free it */ | data->free_op = true; /* if this runs and gets registered we may want not to free it */ | ||||
| UI_popup_block_ex(C, wm_operator_ui_create, NULL, wm_operator_ui_popup_cancel, data, op); | UI_popup_block_ex(C, wm_operator_ui_create, NULL, wm_operator_ui_popup_cancel, data, op); | ||||
| return OPERATOR_RUNNING_MODAL; | return OPERATOR_RUNNING_MODAL; | ||||
| } | } | ||||
| /** | /** | ||||
| * For use by #WM_operator_props_popup_call, #WM_operator_props_popup only. | * For use by #WM_operator_props_popup_call, #WM_operator_props_popup only. | ||||
| * | * | ||||
| Show All 19 Lines | if ((op->type->flag & OPTYPE_UNDO) == 0) { | ||||
| op->type->idname); | op->type->idname); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| } | } | ||||
| /* if we don't have global undo, we can't do undo push for automatic redo, | /* if we don't have global undo, we can't do undo push for automatic redo, | ||||
| * so we require manual OK clicking in this popup */ | * so we require manual OK clicking in this popup */ | ||||
| if (!do_redo || !(U.uiflag & USER_GLOBALUNDO)) { | if (!do_redo || !(U.uiflag & USER_GLOBALUNDO)) { | ||||
| return WM_operator_props_dialog_popup(C, op, 300, 20); | return WM_operator_props_dialog_popup(C, op, 300); | ||||
| } | } | ||||
| UI_popup_block_ex(C, wm_block_create_redo, NULL, wm_block_redo_cancel_cb, op, op); | UI_popup_block_ex(C, wm_block_create_redo, NULL, wm_block_redo_cancel_cb, op, op); | ||||
| if (do_call) { | if (do_call) { | ||||
| wm_block_redo_cb(C, op, 0); | wm_block_redo_cb(C, op, 0); | ||||
| } | } | ||||
| Show All 19 Lines | int WM_operator_props_popup_call(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| return wm_operator_props_popup_ex(C, op, true, true); | return wm_operator_props_popup_ex(C, op, true, true); | ||||
| } | } | ||||
| int WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | int WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| return wm_operator_props_popup_ex(C, op, false, true); | return wm_operator_props_popup_ex(C, op, false, true); | ||||
| } | } | ||||
| int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, int height) | int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width) | ||||
| { | { | ||||
| wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup"); | wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup"); | ||||
| data->op = op; | data->op = op; | ||||
| data->width = width * U.dpi_fac; | data->width = width * U.dpi_fac; | ||||
| data->height = height * U.dpi_fac; | /* Actual height depends on the content. */ | ||||
| data->height = 0; | |||||
| data->free_op = true; /* if this runs and gets registered we may want not to free it */ | data->free_op = true; /* if this runs and gets registered we may want not to free it */ | ||||
| /* op is not executed until popup OK but is clicked */ | /* op is not executed until popup OK but is clicked */ | ||||
| UI_popup_block_ex( | UI_popup_block_ex( | ||||
| C, wm_block_dialog_create, wm_operator_ui_popup_ok, wm_operator_ui_popup_cancel, data, op); | C, wm_block_dialog_create, wm_operator_ui_popup_ok, wm_operator_ui_popup_cancel, data, op); | ||||
| return OPERATOR_RUNNING_MODAL; | return OPERATOR_RUNNING_MODAL; | ||||
| } | } | ||||
| Show All 34 Lines | static int wm_debug_menu_exec(bContext *C, wmOperator *op) | ||||
| WM_event_add_notifier(C, NC_WINDOW, NULL); | WM_event_add_notifier(C, NC_WINDOW, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int wm_debug_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | static int wm_debug_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| RNA_int_set(op->ptr, "debug_value", G.debug_value); | RNA_int_set(op->ptr, "debug_value", G.debug_value); | ||||
| return WM_operator_props_dialog_popup(C, op, 180, 20); | return WM_operator_props_dialog_popup(C, op, 180); | ||||
| } | } | ||||
| static void WM_OT_debug_menu(wmOperatorType *ot) | static void WM_OT_debug_menu(wmOperatorType *ot) | ||||
| { | { | ||||
| ot->name = "Debug Menu"; | ot->name = "Debug Menu"; | ||||
| ot->idname = "WM_OT_debug_menu"; | ot->idname = "WM_OT_debug_menu"; | ||||
| ot->description = "Open a popup to set the debug level"; | ot->description = "Open a popup to set the debug level"; | ||||
| ▲ Show 20 Lines • Show All 2,333 Lines • Show Last 20 Lines | |||||