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
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-04-01 18:02:06 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-04-01 18:02:06 +0400
commitf3b84c9d52a6c0330f82f22cecba84e6a1647320 (patch)
tree4f2afa3585564e52461049e6a453162982de33ad /source
parent3224efc38419201b44503982541aca8eaeb29486 (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')
-rw-r--r--source/blender/editors/curve/editcurve.c12
-rw-r--r--source/blender/editors/physics/editparticle.c2
-rw-r--r--source/blender/editors/screen/screen_ops.c44
-rw-r--r--source/blender/windowmanager/WM_api.h3
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c59
5 files changed, 69 insertions, 51 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index ce639e4bfc1..cbc282fa376 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -1069,10 +1069,9 @@ void CURVE_OT_spline_weight_set(wmOperatorType *ot)
/* api callbacks */
ot->exec= set_weight_exec;
+ ot->invoke= WM_operator_redo;
ot->poll= ED_operator_editsurfcurve;
- // XXX invoke popup?
-
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1121,10 +1120,9 @@ void CURVE_OT_radius_set(wmOperatorType *ot)
/* api callbacks */
ot->exec= set_radius_exec;
+ ot->invoke= WM_operator_redo;
ot->poll= ED_operator_editsurfcurve;
- // XXX invoke popup?
-
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -4147,9 +4145,8 @@ void CURVE_OT_select_random(wmOperatorType *ot)
/* api callbacks */
ot->exec= select_random_exec;
+ ot->invoke= WM_operator_redo;
ot->poll= ED_operator_editsurfcurve;
-
- // XXX invoke popup?
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -4182,9 +4179,8 @@ void CURVE_OT_select_every_nth(wmOperatorType *ot)
/* api callbacks */
ot->exec= select_every_nth_exec;
+ ot->invoke= WM_operator_redo;
ot->poll= ED_operator_editsurfcurve;
-
- // XXX invoke popup?
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
diff --git a/source/blender/editors/physics/editparticle.c b/source/blender/editors/physics/editparticle.c
index 33d1bd66676..3212494234b 100644
--- a/source/blender/editors/physics/editparticle.c
+++ b/source/blender/editors/physics/editparticle.c
@@ -1821,7 +1821,7 @@ void PARTICLE_OT_rekey(wmOperatorType *ot)
/* api callbacks */
ot->exec= rekey_exec;
- // XXX show buttons ot->invoke= rekey_invoke;
+ ot->invoke= WM_operator_redo;
ot->poll= PE_poll;
/* flags */
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index d06259d1487..9a655f1cf9a 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -1622,44 +1622,6 @@ void SCREEN_OT_repeat_history(wmOperatorType *ot)
/* ********************** redo operator ***************************** */
-static void redo_last_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 *ui_block_create_redo_last(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_last_popup", UI_EMBOSS, UI_HELV);
- uiBlockClearFlag(block, UI_BLOCK_LOOP);
- uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1);
- uiBlockSetFunc(block, redo_last_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;
-}
-
static int redo_last_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
wmWindowManager *wm= CTX_wm_manager(C);
@@ -1670,10 +1632,8 @@ static int redo_last_invoke(bContext *C, wmOperator *op, wmEvent *event)
if((lastop->type->flag & OPTYPE_REGISTER) && (lastop->type->flag & OPTYPE_UNDO))
break;
- if(!lastop)
- return OPERATOR_CANCELLED;
-
- uiPupBlock(C, ui_block_create_redo_last, lastop);
+ if(lastop)
+ WM_operator_redo_popup(C, lastop);
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 5a059b72e27..31bebc70dd0 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -123,6 +123,9 @@ int WM_operator_confirm (struct bContext *C, struct wmOperator *op, struct wm
int WM_operator_filesel (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
/* poll callback, context checks */
int WM_operator_winactive (struct bContext *C);
+ /* invoke callback, exec + redo popup */
+int WM_operator_redo (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
+int WM_operator_redo_popup (struct bContext *C, struct wmOperator *op);
/* operator api */
void WM_operator_free (struct wmOperator *op);
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)