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
This commit is contained in:
2019-09-06 16:26:10 +03:00
parent b0b24b77ff
commit 9ecbd67dfb
8 changed files with 114 additions and 14 deletions

View File

@@ -1768,7 +1768,12 @@ static int pyrna_py_to_prop(
if (value == Py_None) {
if ((RNA_property_flag(prop) & PROP_NEVER_NULL) == 0) {
if (data) {
*((char **)data) = (char *)NULL;
if (RNA_property_flag(prop) & PROP_THICK_WRAP) {
*(char *)data = 0;
}
else {
*((char **)data) = (char *)NULL;
}
}
else {
RNA_property_string_set(ptr, prop, NULL);
@@ -1813,7 +1818,12 @@ static int pyrna_py_to_prop(
}
else {
if (data) {
*((char **)data) = (char *)param;
if (RNA_property_flag(prop) & PROP_THICK_WRAP) {
BLI_strncpy((char *)data, (char *)param, RNA_property_string_maxlength(prop));
}
else {
*((char **)data) = (char *)param;
}
}
else {
RNA_property_string_set_bytes(ptr, prop, param, PyBytes_Size(value));
@@ -1862,7 +1872,12 @@ static int pyrna_py_to_prop(
/* XXX, this is suspect, but needed for function calls,
* need to see if there's a better way. */
if (data) {
*((char **)data) = (char *)param;
if (RNA_property_flag(prop) & PROP_THICK_WRAP) {
BLI_strncpy((char *)data, (char *)param, RNA_property_string_maxlength(prop));
}
else {
*((char **)data) = (char *)param;
}
}
else {
RNA_property_string_set(ptr, prop, param);