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:
authorJoshua Leung <aligorith@gmail.com>2016-03-24 05:15:04 +0300
committerJoshua Leung <aligorith@gmail.com>2016-03-24 05:15:04 +0300
commitc4956faf993c6fcd8e8726ed9d05d07682798454 (patch)
treea5b27a425c934f03c130328195c657e73f30c94f /source/blender/makesrna/intern/rna_fcurve.c
parent322f86d6b330ebeb1da5c1f527714745dc901460 (diff)
Drivers UI: Added name validation/linting for Driver Variables
When attempting to change a driver variable name to an "invalid" name, an indicator will now be shown beside the offending variable name. Clicking on this icon will show a popup which provides more information about why the variable name cannot be used. Reasons that it knows about are: 1) Starts with number 2) Has a dot 3) Has a space 4) Starts with or contains a special character 5) Starts with an underscore (Python does allow this, but it's bad practice, and makes checking security of drivers harder) 6) Is a reserved Python keyword
Diffstat (limited to 'source/blender/makesrna/intern/rna_fcurve.c')
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index fbc332f5658..c34d8125367 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -275,6 +275,15 @@ static void rna_DriverVariable_type_set(PointerRNA *ptr, int value)
driver_change_variable_type(dvar, value);
}
+void rna_DriverVariable_name_set(PointerRNA *ptr, const char *value)
+{
+ DriverVar *data = (DriverVar *)(ptr->data);
+
+ BLI_strncpy_utf8(data->name, value, 64);
+ driver_variable_name_validate(data);
+}
+
+
/* ----------- */
static DriverVar *rna_Driver_new_variable(ChannelDriver *driver)
@@ -1474,6 +1483,7 @@ static void rna_def_drivervar(BlenderRNA *brna)
/* Variable Name */
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_struct_name_property(srna, prop);
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_DriverVariable_name_set");
RNA_def_property_ui_text(prop, "Name",
"Name to use in scripted expressions/functions (no spaces or dots are allowed, "
"and must start with a letter)");
@@ -1493,6 +1503,12 @@ static void rna_def_drivervar(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "targets", "num_targets");
RNA_def_property_struct_type(prop, "DriverTarget");
RNA_def_property_ui_text(prop, "Targets", "Sources of input data for evaluating this variable");
+
+ /* Name Validity Flags */
+ prop = RNA_def_property(srna, "is_name_valid", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", DVAR_FLAG_INVALID_NAME);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Is Name Valid", "Is this a valid name for a driver variable");
}