diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-09-06 16:26:10 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-09-06 22:05:20 +0300 |
commit | 9ecbd67dfb672cd13f021c82d83aeb7ae8a8cf10 (patch) | |
tree | 9edad541160077d63cd77fe9c0210d29bebad6f3 /source/blender/makesrna/intern/rna_wm_api.c | |
parent | b0b24b77ffc3e34b3aef24ff658826a8aeca7782 (diff) |
Python API: implement an Operator callback for dynamic description.
Blender UI Layout API allows supplying parameters to operators via
button definitions. If an operator behavior strongly depends on its
parameters, it may be difficult to write a tooltip that covers all
of its operation modes. Thus it is useful to provide a way for the
operator to produce different descriptions based on the input info.
Reviewers: campbellbarton
Differential Revision: https://developer.blender.org/D5709
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_wm_api.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index d9306ba7a65..650d410091e 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -957,6 +957,18 @@ void RNA_api_operator(StructRNA *srna) RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + /* description */ + func = RNA_def_function(srna, "description", NULL); + RNA_def_function_ui_description(func, "Compute a description string that depends on parameters"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL); + parm = RNA_def_string(func, "result", NULL, 4096, "result", ""); + RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); + RNA_def_function_output(func, parm); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); } void RNA_api_macro(StructRNA *srna) |