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>2017-08-24 10:04:28 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-08-24 10:04:28 +0300
commite20c825b05e00954995fe2ed74e7fb409d09abe8 (patch)
tree4491775682a618cb6e2e902bfe4ec61d72966d7b /source/blender/makesrna/intern/rna_wm_manipulator.c
parent134e927965c9871df8a9e13806f1cd48f4d43f16 (diff)
Manipulator: modal callback can now cancel & pass events
Re-use operator return flags for manipulator modal & invoke, this means manipulators can allow navigation or other events to be handled as they run - see T52499
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm_manipulator.c')
-rw-r--r--source/blender/makesrna/intern/rna_wm_manipulator.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c
index e6bf68c4f3e..4f94b996046 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator.c
+++ b/source/blender/makesrna/intern/rna_wm_manipulator.c
@@ -136,7 +136,7 @@ static int rna_manipulator_test_select_cb(
return intersect_id;
}
-static void rna_manipulator_modal_cb(
+static int rna_manipulator_modal_cb(
struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event,
eWM_ManipulatorTweak tweak_flag)
{
@@ -154,7 +154,13 @@ static void rna_manipulator_modal_cb(
RNA_parameter_set_lookup(&list, "event", &event);
RNA_parameter_set_lookup(&list, "tweak", &tweak_flag_int);
mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
+
+ void *ret;
+ RNA_parameter_get_lookup(&list, "result", &ret);
+ int ret_enum = *(int *)ret;
+
RNA_parameter_list_free(&list);
+ return ret_enum;
}
static void rna_manipulator_setup_cb(
@@ -174,7 +180,7 @@ static void rna_manipulator_setup_cb(
}
-static void rna_manipulator_invoke_cb(
+static int rna_manipulator_invoke_cb(
struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event)
{
extern FunctionRNA rna_Manipulator_invoke_func;
@@ -189,7 +195,13 @@ static void rna_manipulator_invoke_cb(
RNA_parameter_set_lookup(&list, "context", &C);
RNA_parameter_set_lookup(&list, "event", &event);
mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
+
+ void *ret;
+ RNA_parameter_get_lookup(&list, "result", &ret);
+ int ret_enum = *(int *)ret;
+
RNA_parameter_list_free(&list);
+ return ret_enum;
}
static void rna_manipulator_exit_cb(
@@ -949,10 +961,10 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
parm = RNA_def_pointer(func, "event", "Event", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
/* TODO, shuold be a enum-flag */
- parm = RNA_def_enum(func, "tweak", tweak_actions, 0, "Tweak", "");
+ parm = RNA_def_enum_flag(func, "tweak", tweak_actions, 0, "Tweak", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- RNA_def_property_flag(parm, PROP_ENUM_FLAG);
-
+ parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", "");
+ RNA_def_function_return(func, parm);
/* wmManipulator.property_update */
/* TODO */
@@ -969,6 +981,8 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
parm = RNA_def_pointer(func, "event", "Event", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", "");
+ RNA_def_function_return(func, parm);
/* wmManipulator.exit */
func = RNA_def_function(srna, "exit", NULL);