diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-04-01 18:02:06 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-04-01 18:02:06 +0400 |
commit | f3b84c9d52a6c0330f82f22cecba84e6a1647320 (patch) | |
tree | 4f2afa3585564e52461049e6a453162982de33ad /source/blender/windowmanager/intern | |
parent | 3224efc38419201b44503982541aca8eaeb29486 (diff) |
2.5: added generic WM_operator_redo for use as invoke callback, similar
to WM_operator_menu for example, but popping up the redo menu. This is
useful for operators like particles rekey, which makes no sense without
specifying the number of keys.
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index b310fb81216..e17d98fcfc6 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -54,6 +54,7 @@ #include "IMB_imbuf_types.h" #include "ED_screen.h" +#include "ED_util.h" #include "RNA_access.h" #include "RNA_define.h" @@ -248,6 +249,64 @@ int WM_operator_winactive(bContext *C) return 1; } +/* op->invoke */ +static void redo_cb(bContext *C, void *arg_op, void *arg2) +{ + wmOperator *lastop= arg_op; + + if(lastop) { + ED_undo_pop(C); + WM_operator_repeat(C, lastop); + } +} + +static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) +{ + wmWindowManager *wm= CTX_wm_manager(C); + wmOperator *op= arg_op; + PointerRNA ptr; + uiBlock *block; + int height; + + block= uiBeginBlock(C, ar, "redo_popup", UI_EMBOSS, UI_HELV); + uiBlockClearFlag(block, UI_BLOCK_LOOP); + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1); + uiBlockSetFunc(block, redo_cb, arg_op, NULL); + + 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); + height= uiDefAutoButsRNA(C, block, &ptr); + + uiPopupBoundsBlock(block, 4.0f, 0, 0); + uiEndBlock(C, block); + + return block; +} + +int WM_operator_redo(bContext *C, wmOperator *op, wmEvent *event) +{ + int retval= OPERATOR_CANCELLED; + + if(op->type->exec) + retval= op->type->exec(C, op); + + if(retval != OPERATOR_CANCELLED) + uiPupBlock(C, wm_block_create_redo, op); + + return retval; +} + +int WM_operator_redo_popup(bContext *C, wmOperator *op) +{ + uiPupBlock(C, wm_block_create_redo, op); + + return OPERATOR_CANCELLED; +} + /* ************ window / screen operator definitions ************** */ static void WM_OT_window_duplicate(wmOperatorType *ot) |