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:
authorCampbell Barton <ideasman42@gmail.com>2010-02-21 14:56:00 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-02-21 14:56:00 +0300
commit4cd088c19e95e3bcae2c43a2757317c3f40526be (patch)
tree04e1f65a9d47e3712efbd58c78d1ca93d5b98900 /source/blender/makesrna/intern/rna_wm_api.c
parentddc0c68a5c7187f33ec1fe0136e6509afd25cb29 (diff)
modal python operator support.
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index de37e01ba1b..6817f7a0fc6 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -151,6 +151,11 @@ static void rna_Operator_enum_search_invoke(bContext *C, wmOperator *op)
}
+static int rna_event_add_modal_handler(struct bContext *C, struct wmOperator *operator)
+{
+ return WM_event_add_modal_handler(C, operator) != NULL;
+}
+
#else
static void rna_generic_op_invoke(FunctionRNA *func, int use_event, int use_ret)
@@ -192,6 +197,12 @@ void RNA_api_wm(StructRNA *srna)
parm= RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Removed key configuration.");
RNA_def_property_flag(parm, PROP_REQUIRED);
+ func= RNA_def_function(srna, "add_modal_handler", "rna_event_add_modal_handler");
+ RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT);
+ parm= RNA_def_pointer(func, "operator", "Operator", "", "Operator to call.");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_function_return(func, RNA_def_boolean(func, "handle", 1, "", ""));
+
/* invoke functions, for use with python */
func= RNA_def_function(srna, "invoke_props_popup", "WM_operator_props_popup");
RNA_def_function_ui_description(func, "Operator popup invoke.");
@@ -252,6 +263,16 @@ void RNA_api_operator(StructRNA *srna)
RNA_def_property_flag(parm, PROP_ENUM_FLAG);
RNA_def_function_return(func, parm);
+ func= RNA_def_function(srna, "modal", NULL); /* same as invoke */
+ RNA_def_function_ui_description(func, "Modal operator function.");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_pointer(func, "event", "Event", "", "");
+
+ parm= RNA_def_enum(func, "result", operator_return_items, 0, "result", ""); // better name?
+ RNA_def_property_flag(parm, PROP_ENUM_FLAG);
+ RNA_def_function_return(func, parm);
+
/* draw */
func= RNA_def_function(srna, "draw", NULL);
RNA_def_function_ui_description(func, "Draw function for the operator.");