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-01-16 01:40:33 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-01-16 01:40:33 +0300
commit5272991e8b91c527fbe3923d75ae2c5148dd7177 (patch)
tree84c871abe7d084a775ff7ffab5033c08d085ed32 /source/blender/makesrna/intern/rna_wm_api.c
parent2b3a6b38b764717878de39a97feeee186e3694ad (diff)
generic operator menu was searching for "type" and using the first enum property if it wasnt found.
this is too arbitrary and could break if roperty order is changed. store the property in the operator type that is to be used for menu and enum search func's. python function for searching operator enums on invoke. (just need dynamic python enums now) wm.invoke_search_popup(self)
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 9ed6046ecd0..c69e706e28d 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -144,18 +144,42 @@ static void rna_Operator_report(wmOperator *op, int type, char *msg)
BKE_report(op->reports, type, msg);
}
+/* since event isnt needed... */
+static int rna_Operator_enum_search_invoke(bContext *C, wmOperator *op)
+{
+ WM_enum_search_invoke(C, op, NULL);
+}
+
#else
+static void rna_generic_op_invoke(FunctionRNA *func, int use_event, int use_ret)
+{
+ PropertyRNA *parm;
+
+ 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);
+
+ if(use_event) {
+ parm= RNA_def_pointer(func, "event", "Event", "", "Event.");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ }
+
+ if(use_ret) {
+ parm= RNA_def_enum(func, "result", operator_return_items, 0, "result", "");
+ RNA_def_property_flag(parm, PROP_ENUM_FLAG);
+ RNA_def_function_return(func, parm);
+ }
+}
+
void RNA_api_wm(StructRNA *srna)
{
FunctionRNA *func;
PropertyRNA *parm;
func= RNA_def_function(srna, "add_fileselect", "WM_event_add_fileselect");
- RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Show up the file selector.");
- parm= RNA_def_pointer(func, "operator", "Operator", "", "Operator to call.");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ rna_generic_op_invoke(func, 0, 0);
func= RNA_def_function(srna, "add_keyconfig", "WM_keyconfig_add");
parm= RNA_def_string(func, "name", "", 0, "Name", "");
@@ -165,24 +189,17 @@ void RNA_api_wm(StructRNA *srna)
/* invoke functions, for use with python */
func= RNA_def_function(srna, "invoke_props_popup", "WM_operator_props_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_pointer(func, "event", "Event", "", "Event.");
- RNA_def_property_flag(parm, PROP_REQUIRED);
-
- 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);
+ rna_generic_op_invoke(func, 1, 1);
+ /* invoke enum */
+ func= RNA_def_function(srna, "invoke_search_popup", "rna_Operator_enum_search_invoke");
+ rna_generic_op_invoke(func, 0, 1);
/* 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);
+ rna_generic_op_invoke(func, 0, 0);
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);
}