diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-12-06 07:35:00 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-12-06 07:35:00 +0300 |
commit | f08e8af0b9568798bd2f59daf1b83dd0f7204ced (patch) | |
tree | cdc7416d12c9ec57d602081dc421aff464fa5b00 /source | |
parent | 062cf438ce065b477b52f72871b95bc5ee12c619 (diff) |
wm.invoke_popup(op, width, height) similar to wm.invoke_props_popup(op, event) except it doesnt use undo/redo (UI's need to execute operators themselves)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesrna/intern/rna_wm_api.c | 9 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 41 |
3 files changed, 51 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index 62c4fe642a1..50b0e37b7cd 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -147,6 +147,15 @@ void RNA_api_wm(StructRNA *srna) parm= RNA_def_pointer(func, "event", "Event", "", "Event."); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_function_return(func, RNA_def_int(func, "mode", 0, 0, INT_MAX, "Mode", "", 0, INT_MAX)); // XXX, should be an enum/flag thingo + + /* invoke functions, for use with python */ + func= RNA_def_function(srna, "invoke_popup", "WM_operator_ui_popup"); + RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Operator popup invoke."); + parm= RNA_def_pointer(func, "operator", "Operator", "", "Operator to call."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_int(func, "width", 300, 0, INT_MAX, "", "Width of the popup.", 0, INT_MAX); + parm= RNA_def_int(func, "height", 20, 0, INT_MAX, "", "Height of the popup.", 0, INT_MAX); } void RNA_api_keyconfig(StructRNA *srna) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 549ef11c14e..1fab234dbf7 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -168,6 +168,7 @@ int WM_operator_winactive (struct bContext *C); /* invoke callback, exec + redo popup */ int WM_operator_props_popup (struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_operator_redo_popup (struct bContext *C, struct wmOperator *op); +void WM_operator_ui_popup (struct bContext *C, struct wmOperator *op, int width, int height); int WM_operator_confirm_message(struct bContext *C, struct wmOperator *op, char *message); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 582410c4368..f2ba9bb8eb6 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -774,6 +774,38 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) return block; } + +static uiBlock *wm_operator_create_ui(bContext *C, ARegion *ar, void *userData) +{ + struct { wmOperator *op; int width; int height; } * data = userData; + wmWindowManager *wm= CTX_wm_manager(C); + wmOperator *op= data->op; + PointerRNA ptr; + uiBlock *block; + uiLayout *layout; + uiStyle *style= U.uistyles.first; + + block= uiBeginBlock(C, ar, "opui_popup", UI_EMBOSS); + uiBlockClearFlag(block, UI_BLOCK_LOOP); + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); + + if(!op->properties) { + IDPropertyTemplate val = {0}; + op->properties= IDP_New(IDP_GROUP, val, "wmOperatorProperties"); + } + + RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); + layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style); + + if(op->type->ui) + op->type->ui((bContext*)C, op, layout); + + uiPopupBoundsBlock(block, 4.0f, 0, 0); + uiEndBlock(C, block); + + return block; +} + int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *event) { int retval= OPERATOR_CANCELLED; @@ -787,6 +819,15 @@ int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *event) return retval; } +void WM_operator_ui_popup(bContext *C, wmOperator *op, int width, int height) +{ + struct { wmOperator *op; int width; int height; } data; + data.op = op; + data.width = width; + data.height = height; + uiPupBlock(C, wm_operator_create_ui, &data); +} + int WM_operator_redo_popup(bContext *C, wmOperator *op) { uiPupBlock(C, wm_block_create_redo, op); |