2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-11-14 14:34:19 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-11-14 14:34:19 +00:00
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup RNA
|
2011-02-27 20:20:01 +00:00
|
|
|
*/
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2009-01-08 13:57:29 +00:00
|
|
|
#include "DNA_ID.h"
|
|
|
|
|
2013-03-07 02:44:55 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
2009-01-08 13:57:29 +00:00
|
|
|
#include "RNA_access.h"
|
2008-11-14 14:34:19 +00:00
|
|
|
#include "RNA_define.h"
|
2013-01-13 16:18:35 +00:00
|
|
|
#include "RNA_enum_types.h"
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2009-06-03 23:16:51 +00:00
|
|
|
#include "rna_internal.h"
|
|
|
|
|
2018-05-17 19:10:45 +02:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Generic Enum's
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
/* Reuse for dynamic types */
|
|
|
|
const EnumPropertyItem DummyRNA_NULL_items[] = {
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2018-05-17 19:10:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Reuse for dynamic types with default value */
|
|
|
|
const EnumPropertyItem DummyRNA_DEFAULT_items[] = {
|
|
|
|
{0, "DEFAULT", 0, "Default", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2018-05-17 19:10:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name RNA Enum's
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem rna_enum_property_type_items[] = {
|
2010-02-15 23:43:51 +00:00
|
|
|
{PROP_BOOLEAN, "BOOLEAN", 0, "Boolean", ""},
|
|
|
|
{PROP_INT, "INT", 0, "Integer", ""},
|
|
|
|
{PROP_FLOAT, "FLOAT", 0, "Float", ""},
|
|
|
|
{PROP_STRING, "STRING", 0, "String", ""},
|
|
|
|
{PROP_ENUM, "ENUM", 0, "Enumeration", ""},
|
|
|
|
{PROP_POINTER, "POINTER", 0, "Pointer", ""},
|
|
|
|
{PROP_COLLECTION, "COLLECTION", 0, "Collection", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2010-02-15 23:43:51 +00:00
|
|
|
|
Python i18n API. Many thanks to Campbell and Brecht for the reviews and suggestions!
This commit adds:
* A new bpy.app.translations module giving some info about locales/translation stuff (current active locale, all locales currently known by blender, all translation contexts currently defined, etc.).
* The ability for addons to feature translations, using the (un)register functions of above module.
* Also cleans up "translate py string when storing into RNA prop" by removing "PROP_TRANSLATE" string's subtype, and adding a PROP_STRING_PY_TRANSLATE flag instead (this way it is no more exposed to python...).
Addon translations work with py dictionaries: each addon features a dict {lang: {(context, message): translation, ...}, ...}, which is registered when the addon is enabled (and unregistered when disabled).
Then, when a key (context, message) is not found in regular mo catalog, a cache dict for current locale is built from all registered addon translations, and key is searched in it.
Note: currently addons writers have to do all the work by hand, will add something (probably extend "edit translation" addon) to automate messages extraction from addons soon(ish)! To get a look to expected behavior from addons, have a look at render_copy_settings/__init__.py and render_copy_settings/translations.py (rather stupid example currently, but...). Once we have a complete process, I'll also update relevant wiki pages.
2013-01-20 17:29:07 +00:00
|
|
|
/* XXX Keep in sync with bpy_props.c's property_subtype_xxx_items ???
|
|
|
|
* Currently it is not...
|
|
|
|
*/
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem rna_enum_property_subtype_items[] = {
|
2011-09-05 21:01:50 +00:00
|
|
|
{PROP_NONE, "NONE", 0, "None", ""},
|
|
|
|
|
|
|
|
/* strings */
|
|
|
|
{PROP_FILEPATH, "FILEPATH", 0, "File Path", ""},
|
|
|
|
{PROP_DIRPATH, "DIRPATH", 0, "Directory Path", ""},
|
|
|
|
{PROP_FILENAME, "FILENAME", 0, "File Name", ""},
|
Python i18n API. Many thanks to Campbell and Brecht for the reviews and suggestions!
This commit adds:
* A new bpy.app.translations module giving some info about locales/translation stuff (current active locale, all locales currently known by blender, all translation contexts currently defined, etc.).
* The ability for addons to feature translations, using the (un)register functions of above module.
* Also cleans up "translate py string when storing into RNA prop" by removing "PROP_TRANSLATE" string's subtype, and adding a PROP_STRING_PY_TRANSLATE flag instead (this way it is no more exposed to python...).
Addon translations work with py dictionaries: each addon features a dict {lang: {(context, message): translation, ...}, ...}, which is registered when the addon is enabled (and unregistered when disabled).
Then, when a key (context, message) is not found in regular mo catalog, a cache dict for current locale is built from all registered addon translations, and key is searched in it.
Note: currently addons writers have to do all the work by hand, will add something (probably extend "edit translation" addon) to automate messages extraction from addons soon(ish)! To get a look to expected behavior from addons, have a look at render_copy_settings/__init__.py and render_copy_settings/translations.py (rather stupid example currently, but...). Once we have a complete process, I'll also update relevant wiki pages.
2013-01-20 17:29:07 +00:00
|
|
|
{PROP_PASSWORD, "PASSWORD", 0, "Password", "A string that is displayed hidden ('********')"},
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
/* numbers */
|
2013-12-13 04:39:15 +11:00
|
|
|
{PROP_PIXEL, "PIXEL", 0, "Pixel", ""},
|
2011-09-05 21:01:50 +00:00
|
|
|
{PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned", ""},
|
|
|
|
{PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""},
|
|
|
|
{PROP_FACTOR, "FACTOR", 0, "Factor", ""},
|
|
|
|
{PROP_ANGLE, "ANGLE", 0, "Angle", ""},
|
|
|
|
{PROP_TIME, "TIME", 0, "Time", ""},
|
|
|
|
{PROP_DISTANCE, "DISTANCE", 0, "Distance", ""},
|
2013-03-13 17:16:49 +00:00
|
|
|
{PROP_DISTANCE_CAMERA, "DISTANCE_CAMERA", 0, "Camera Distance", ""},
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
/* number arrays */
|
|
|
|
{PROP_COLOR, "COLOR", 0, "Color", ""},
|
|
|
|
{PROP_TRANSLATION, "TRANSLATION", 0, "Translation", ""},
|
|
|
|
{PROP_DIRECTION, "DIRECTION", 0, "Direction", ""},
|
|
|
|
{PROP_VELOCITY, "VELOCITY", 0, "Velocity", ""},
|
|
|
|
{PROP_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""},
|
|
|
|
{PROP_MATRIX, "MATRIX", 0, "Matrix", ""},
|
|
|
|
{PROP_EULER, "EULER", 0, "Euler Angles", ""},
|
|
|
|
{PROP_QUATERNION, "QUATERNION", 0, "Quaternion", ""},
|
|
|
|
{PROP_AXISANGLE, "AXISANGLE", 0, "Axis-Angle", ""},
|
|
|
|
{PROP_XYZ, "XYZ", 0, "XYZ", ""},
|
|
|
|
{PROP_XYZ_LENGTH, "XYZ_LENGTH", 0, "XYZ Length", ""},
|
|
|
|
{PROP_COLOR_GAMMA, "COLOR_GAMMA", 0, "Color", ""},
|
|
|
|
{PROP_COORDS, "COORDS", 0, "Coordinates", ""},
|
|
|
|
|
|
|
|
/* booleans */
|
|
|
|
{PROP_LAYER, "LAYER", 0, "Layer", ""},
|
|
|
|
{PROP_LAYER_MEMBER, "LAYER_MEMBER", 0, "Layer Member", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem rna_enum_property_unit_items[] = {
|
2010-02-02 23:03:56 +00:00
|
|
|
{PROP_UNIT_NONE, "NONE", 0, "None", ""},
|
|
|
|
{PROP_UNIT_LENGTH, "LENGTH", 0, "Length", ""},
|
|
|
|
{PROP_UNIT_AREA, "AREA", 0, "Area", ""},
|
|
|
|
{PROP_UNIT_VOLUME, "VOLUME", 0, "Volume", ""},
|
|
|
|
{PROP_UNIT_ROTATION, "ROTATION", 0, "Rotation", ""},
|
|
|
|
{PROP_UNIT_TIME, "TIME", 0, "Time", ""},
|
|
|
|
{PROP_UNIT_VELOCITY, "VELOCITY", 0, "Velocity", ""},
|
|
|
|
{PROP_UNIT_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""},
|
2018-08-31 15:00:38 +02:00
|
|
|
{PROP_UNIT_MASS, "MASS", 0, "Mass", ""},
|
2013-03-13 17:16:49 +00:00
|
|
|
{PROP_UNIT_CAMERA, "CAMERA", 0, "Camera", ""},
|
2019-02-08 12:31:28 +01:00
|
|
|
{PROP_UNIT_POWER, "POWER", 0, "Power", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2010-02-02 23:03:56 +00:00
|
|
|
|
2018-05-17 19:10:45 +02:00
|
|
|
/** \} */
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
2010-08-16 05:46:10 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
2009-06-19 23:05:21 +00:00
|
|
|
#include "BLI_ghash.h"
|
2018-05-01 15:24:17 +02:00
|
|
|
#include "BLI_string.h"
|
2009-06-19 23:05:21 +00:00
|
|
|
|
2017-11-29 15:31:31 +01:00
|
|
|
#include "BKE_library_override.h"
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
/* Struct */
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_Struct_identifier_get(PointerRNA *ptr, char *value)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
strcpy(value, ((StructRNA *)ptr->data)->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Struct_identifier_length(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
return strlen(((StructRNA *)ptr->data)->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-12-19 04:06:24 +00:00
|
|
|
static void rna_Struct_description_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
strcpy(value, ((StructRNA *)ptr->data)->description);
|
2008-12-19 04:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_Struct_description_length(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
return strlen(((StructRNA *)ptr->data)->description);
|
2008-12-19 04:06:24 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_Struct_name_get(PointerRNA *ptr, char *value)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
strcpy(value, ((StructRNA *)ptr->data)->name);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Struct_name_length(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
return strlen(((StructRNA *)ptr->data)->name);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2012-03-16 15:39:25 +00:00
|
|
|
static void rna_Struct_translation_context_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
2013-03-19 19:37:22 +00:00
|
|
|
strcpy(value, ((StructRNA *)ptr->data)->translation_context);
|
2012-03-16 15:39:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_Struct_translation_context_length(PointerRNA *ptr)
|
|
|
|
{
|
2013-03-19 19:37:22 +00:00
|
|
|
return strlen(((StructRNA *)ptr->data)->translation_context);
|
2012-03-16 15:39:25 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_Struct_base_get(PointerRNA *ptr)
|
2008-12-15 13:46:50 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((StructRNA *)ptr->data)->base);
|
2008-12-15 13:46:50 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_Struct_nested_get(PointerRNA *ptr)
|
2009-01-09 16:08:47 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((StructRNA *)ptr->data)->nested);
|
2009-01-09 16:08:47 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_Struct_name_property_get(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_Property, ((StructRNA *)ptr->data)->nameproperty);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
/* Struct property iteration. This is quite complicated, the purpose is to
|
|
|
|
* iterate over properties of all inheritance levels, and for each struct to
|
|
|
|
* also iterator over id properties not known by RNA. */
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
static int rna_idproperty_known(CollectionPropertyIterator *iter, void *data)
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
IDProperty *idprop = (IDProperty *)data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
PropertyRNA *prop;
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *ptype = iter->builtin_parent.type;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
/* function to skip any id properties that are already known by RNA,
|
|
|
|
* for the second loop where we go over unknown id properties */
|
2010-11-22 20:44:59 +00:00
|
|
|
do {
|
2012-03-05 23:30:41 +00:00
|
|
|
for (prop = ptype->cont.properties.first; prop; prop = prop->next)
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
if ((prop->flag_internal & PROP_INTERN_BUILTIN) == 0 && STREQ(prop->identifier, idprop->name))
|
2010-11-22 20:44:59 +00:00
|
|
|
return 1;
|
2012-03-05 23:30:41 +00:00
|
|
|
} while ((ptype = ptype->base));
|
2009-02-02 19:57:57 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-20 00:19:21 +00:00
|
|
|
static int rna_property_builtin(CollectionPropertyIterator *UNUSED(iter), void *data)
|
2008-11-24 12:12:24 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)data;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
/* function to skip builtin rna properties */
|
|
|
|
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
return (prop->flag_internal & PROP_INTERN_BUILTIN);
|
2008-11-24 12:12:24 +00:00
|
|
|
}
|
|
|
|
|
2011-10-20 00:19:21 +00:00
|
|
|
static int rna_function_builtin(CollectionPropertyIterator *UNUSED(iter), void *data)
|
2009-04-07 00:49:39 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
FunctionRNA *func = (FunctionRNA *)data;
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
/* function to skip builtin rna functions */
|
|
|
|
|
|
|
|
return (func->flag & FUNC_BUILTIN);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_inheritance_next_level_restart(CollectionPropertyIterator *iter, IteratorSkipFunc skip, int funcs)
|
2009-02-02 19:57:57 +00:00
|
|
|
{
|
|
|
|
/* RNA struct inheritance */
|
2012-03-05 23:30:41 +00:00
|
|
|
while (!iter->valid && iter->level > 0) {
|
2009-02-02 19:57:57 +00:00
|
|
|
StructRNA *srna;
|
|
|
|
int i;
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
srna = (StructRNA *)iter->parent.data;
|
2009-02-02 19:57:57 +00:00
|
|
|
iter->level--;
|
2012-05-12 11:01:29 +00:00
|
|
|
for (i = iter->level; i > 0; i--)
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = srna->base;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
rna_iterator_listbase_end(iter);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
if (funcs)
|
|
|
|
rna_iterator_listbase_begin(iter, &srna->functions, skip);
|
|
|
|
else
|
|
|
|
rna_iterator_listbase_begin(iter, &srna->cont.properties, skip);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
static void rna_inheritance_properties_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb,
|
|
|
|
IteratorSkipFunc skip)
|
2009-04-07 00:49:39 +00:00
|
|
|
{
|
|
|
|
rna_iterator_listbase_begin(iter, lb, skip);
|
|
|
|
rna_inheritance_next_level_restart(iter, skip, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_inheritance_properties_listbase_next(CollectionPropertyIterator *iter, IteratorSkipFunc skip)
|
|
|
|
{
|
|
|
|
rna_iterator_listbase_next(iter);
|
|
|
|
rna_inheritance_next_level_restart(iter, skip, 0);
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
static void rna_inheritance_functions_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb,
|
|
|
|
IteratorSkipFunc skip)
|
2009-02-02 19:57:57 +00:00
|
|
|
{
|
|
|
|
rna_iterator_listbase_begin(iter, lb, skip);
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_inheritance_next_level_restart(iter, skip, 1);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
static void rna_inheritance_functions_listbase_next(CollectionPropertyIterator *iter, IteratorSkipFunc skip)
|
2009-02-02 19:57:57 +00:00
|
|
|
{
|
|
|
|
rna_iterator_listbase_next(iter);
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_inheritance_next_level_restart(iter, skip, 1);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_Struct_properties_next(CollectionPropertyIterator *iter)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2014-04-05 14:36:18 +02:00
|
|
|
ListBaseIterator *internal = &iter->internal.listbase;
|
2008-11-17 18:44:06 +00:00
|
|
|
IDProperty *group;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (internal->flag) {
|
2008-11-17 18:44:06 +00:00
|
|
|
/* id properties */
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_next(iter);
|
2008-11-17 18:44:06 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* regular properties */
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_inheritance_properties_listbase_next(iter, rna_property_builtin);
|
2008-11-17 18:44:06 +00:00
|
|
|
|
|
|
|
/* try id properties */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!iter->valid) {
|
|
|
|
group = RNA_struct_idprops(&iter->builtin_parent, 0);
|
2008-11-17 18:44:06 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (group) {
|
2008-11-17 18:44:06 +00:00
|
|
|
rna_iterator_listbase_end(iter);
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &group->data.group, rna_idproperty_known);
|
2014-04-05 14:36:18 +02:00
|
|
|
internal = &iter->internal.listbase;
|
2012-03-05 23:30:41 +00:00
|
|
|
internal->flag = 1;
|
2008-11-17 18:44:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_Struct_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2009-02-02 19:57:57 +00:00
|
|
|
StructRNA *srna;
|
|
|
|
|
|
|
|
/* here ptr->data should always be the same as iter->parent.type */
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = (StructRNA *)ptr->data;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
while (srna->base) {
|
2009-02-02 19:57:57 +00:00
|
|
|
iter->level++;
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = srna->base;
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_inheritance_properties_listbase_begin(iter, &srna->cont.properties, rna_property_builtin);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_Struct_properties_get(CollectionPropertyIterator *iter)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2014-04-05 14:36:18 +02:00
|
|
|
ListBaseIterator *internal = &iter->internal.listbase;
|
2008-11-17 18:44:06 +00:00
|
|
|
|
|
|
|
/* we return either PropertyRNA* or IDProperty*, the rna_access.c
|
|
|
|
* functions can handle both as PropertyRNA* with some tricks */
|
2009-02-02 19:57:57 +00:00
|
|
|
return rna_pointer_inherit_refine(&iter->parent, &RNA_Property, internal->link);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
static void rna_Struct_functions_next(CollectionPropertyIterator *iter)
|
|
|
|
{
|
|
|
|
rna_inheritance_functions_listbase_next(iter, rna_function_builtin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Struct_functions_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
|
|
|
|
|
|
|
/* here ptr->data should always be the same as iter->parent.type */
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = (StructRNA *)ptr->data;
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
while (srna->base) {
|
2009-04-07 00:49:39 +00:00
|
|
|
iter->level++;
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = srna->base;
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rna_inheritance_functions_listbase_begin(iter, &srna->functions, rna_function_builtin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PointerRNA rna_Struct_functions_get(CollectionPropertyIterator *iter)
|
|
|
|
{
|
2014-04-05 14:36:18 +02:00
|
|
|
ListBaseIterator *internal = &iter->internal.listbase;
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
/* we return either PropertyRNA* or IDProperty*, the rna_access.c
|
|
|
|
* functions can handle both as PropertyRNA* with some tricks */
|
|
|
|
return rna_pointer_inherit_refine(&iter->parent, &RNA_Function, internal->link);
|
|
|
|
}
|
|
|
|
|
2017-11-23 13:41:07 +01:00
|
|
|
static void rna_Struct_property_tags_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
/* here ptr->data should always be the same as iter->parent.type */
|
|
|
|
StructRNA *srna = (StructRNA *)ptr->data;
|
|
|
|
const EnumPropertyItem *tag_defines = RNA_struct_property_tag_defines(srna);
|
2017-12-19 20:53:19 +01:00
|
|
|
unsigned int tag_count = tag_defines ? RNA_enum_items_count(tag_defines) : 0;
|
2017-11-23 13:41:07 +01:00
|
|
|
|
|
|
|
rna_iterator_array_begin(iter, (void *)tag_defines, sizeof(EnumPropertyItem), tag_count, 0, NULL);
|
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
/* Builtin properties iterator re-uses the Struct properties iterator, only
|
2009-05-20 09:17:21 +00:00
|
|
|
* difference is that we need to set the ptr data to the type of the struct
|
2009-02-02 19:57:57 +00:00
|
|
|
* whose properties we want to iterate over. */
|
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
void rna_builtin_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
|
|
|
PointerRNA newptr;
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
/* we create a new pointer with the type as the data */
|
2012-03-05 23:30:41 +00:00
|
|
|
newptr.type = &RNA_Struct;
|
|
|
|
newptr.data = ptr->type;
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ptr->type->flag & STRUCT_ID)
|
|
|
|
newptr.id.data = ptr->data;
|
2009-03-19 19:03:38 +00:00
|
|
|
else
|
2012-03-05 23:30:41 +00:00
|
|
|
newptr.id.data = NULL;
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
iter->parent = newptr;
|
2009-05-20 09:17:21 +00:00
|
|
|
iter->builtin_parent = *ptr;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_Struct_properties_begin(iter, &newptr);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
void rna_builtin_properties_next(CollectionPropertyIterator *iter)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_Struct_properties_next(iter);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
PointerRNA rna_builtin_properties_get(CollectionPropertyIterator *iter)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-14 18:46:57 +00:00
|
|
|
return rna_Struct_properties_get(iter);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2011-01-05 14:49:08 +00:00
|
|
|
int rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
|
2009-06-19 23:05:21 +00:00
|
|
|
{
|
|
|
|
StructRNA *srna;
|
|
|
|
PropertyRNA *prop;
|
2012-03-05 23:30:41 +00:00
|
|
|
PointerRNA propptr = {{NULL}};
|
2009-06-19 23:05:21 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = ptr->type;
|
2009-06-19 23:05:21 +00:00
|
|
|
|
|
|
|
do {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (srna->cont.prophash) {
|
2012-05-12 11:01:29 +00:00
|
|
|
prop = BLI_ghash_lookup(srna->cont.prophash, (void *)key);
|
2009-06-19 23:05:21 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop) {
|
|
|
|
propptr.type = &RNA_Property;
|
|
|
|
propptr.data = prop;
|
2011-01-05 14:49:08 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
*r_ptr = propptr;
|
2014-04-01 11:34:00 +11:00
|
|
|
return true;
|
2009-06-19 23:05:21 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-25 05:45:21 +00:00
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
for (prop = srna->cont.properties.first; prop; prop = prop->next) {
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
if (!(prop->flag_internal & PROP_INTERN_BUILTIN) && STREQ(prop->identifier, key)) {
|
2012-03-05 23:30:41 +00:00
|
|
|
propptr.type = &RNA_Property;
|
|
|
|
propptr.data = prop;
|
2009-06-19 23:05:21 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
*r_ptr = propptr;
|
2014-04-01 11:34:00 +11:00
|
|
|
return true;
|
2011-01-25 05:45:21 +00:00
|
|
|
}
|
2009-06-19 23:05:21 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
} while ((srna = srna->base));
|
2009-06-19 23:05:21 +00:00
|
|
|
|
2009-11-18 10:59:17 +00:00
|
|
|
/* this was used pre 2.5beta0, now ID property access uses python's
|
|
|
|
* getitem style access
|
2011-05-28 13:11:24 +00:00
|
|
|
* - ob["foo"] rather than ob.foo */
|
2009-11-18 10:59:17 +00:00
|
|
|
#if 0
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ptr->data) {
|
2009-11-18 10:59:17 +00:00
|
|
|
IDProperty *group, *idp;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
group = RNA_struct_idprops(ptr, 0);
|
RNA
Implementation of RNA side of foreach_get/foreach_set,
Campbell will do python code.
Three functions for efficiently setting some property for all
items in a collection. RNA_property_collection_raw_array gives
access to the properties as an array with length, stride, and
type specified, if this is possible, i.e. not when it uses a
ListBase, or if a manual get/set function is implemented.
Two other functions take a C array pointer and get/set it
using the a collection + property name, using efficient array
access if possible, and otherwise using slower RNA iterator.
RNA_property_collection_raw_get
RNA_property_collection_raw_set
The number of type conversion required here got a bit out of
hand, it could be more efficient still if checking for more
cases, but function is already long enough.
Example: http://www.pasteall.org/6362/c
2009-06-29 19:15:51 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (group) {
|
|
|
|
for (idp = group->data.group.first; idp; idp = idp->next) {
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(idp->name, key)) {
|
2012-03-05 23:30:41 +00:00
|
|
|
propptr.type = &RNA_Property;
|
|
|
|
propptr.data = idp;
|
2011-01-05 14:49:08 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
*r_ptr = propptr;
|
2014-04-01 11:34:00 +11:00
|
|
|
return true;
|
RNA
Implementation of RNA side of foreach_get/foreach_set,
Campbell will do python code.
Three functions for efficiently setting some property for all
items in a collection. RNA_property_collection_raw_array gives
access to the properties as an array with length, stride, and
type specified, if this is possible, i.e. not when it uses a
ListBase, or if a manual get/set function is implemented.
Two other functions take a C array pointer and get/set it
using the a collection + property name, using efficient array
access if possible, and otherwise using slower RNA iterator.
RNA_property_collection_raw_get
RNA_property_collection_raw_set
The number of type conversion required here got a bit out of
hand, it could be more efficient still if checking for more
cases, but function is already long enough.
Example: http://www.pasteall.org/6362/c
2009-06-29 19:15:51 +00:00
|
|
|
}
|
2009-06-19 23:05:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-11-18 10:59:17 +00:00
|
|
|
#endif
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2009-06-19 23:05:21 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
PointerRNA rna_builtin_type_get(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2009-02-02 19:57:57 +00:00
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ptr->type);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Property */
|
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
static StructRNA *rna_Property_refine(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
|
|
|
rna_idproperty_check(&prop, ptr); /* XXX ptr? */
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2011-12-01 22:08:42 +00:00
|
|
|
case PROP_BOOLEAN: return &RNA_BoolProperty;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
case PROP_INT: return &RNA_IntProperty;
|
|
|
|
case PROP_FLOAT: return &RNA_FloatProperty;
|
|
|
|
case PROP_STRING: return &RNA_StringProperty;
|
|
|
|
case PROP_ENUM: return &RNA_EnumProperty;
|
|
|
|
case PROP_POINTER: return &RNA_PointerProperty;
|
|
|
|
case PROP_COLLECTION: return &RNA_CollectionProperty;
|
|
|
|
default: return &RNA_Property;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_Property_identifier_get(PointerRNA *ptr, char *value)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
strcpy(value, ((PropertyRNA *)prop)->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Property_identifier_length(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return strlen(prop->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_Property_name_get(PointerRNA *ptr, char *value)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2014-01-24 00:25:11 +11:00
|
|
|
strcpy(value, prop->name ? prop->name : "");
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Property_name_length(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2014-01-24 00:25:11 +11:00
|
|
|
return prop->name ? strlen(prop->name) : 0;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_Property_description_get(PointerRNA *ptr, char *value)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
strcpy(value, prop->description ? prop->description : "");
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Property_description_length(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2009-10-14 18:48:19 +00:00
|
|
|
return prop->description ? strlen(prop->description) : 0;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2011-12-22 18:25:59 +00:00
|
|
|
static void rna_Property_translation_context_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2011-12-22 18:25:59 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2013-03-19 19:37:22 +00:00
|
|
|
strcpy(value, prop->translation_context);
|
2011-12-22 18:25:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_Property_translation_context_length(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2011-12-22 18:25:59 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2013-03-19 19:37:22 +00:00
|
|
|
return strlen(prop->translation_context);
|
2011-12-22 18:25:59 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Property_type_get(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return prop->type;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Property_subtype_get(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return prop->subtype;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2009-11-13 17:42:44 +00:00
|
|
|
static PointerRNA rna_Property_srna_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2009-11-13 17:42:44 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_Struct, prop->srna);
|
|
|
|
}
|
|
|
|
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
static int rna_Property_unit_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
return RNA_SUBTYPE_UNIT(prop->subtype);
|
|
|
|
}
|
|
|
|
|
2013-01-17 00:29:39 +00:00
|
|
|
static int rna_Property_icon_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
return prop->icon;
|
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Property_readonly_get(PointerRNA *ptr)
|
2008-12-19 04:06:24 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2009-11-23 23:17:23 +00:00
|
|
|
|
2012-07-26 17:41:09 +00:00
|
|
|
/* don't use this because it will call functions that check the internal
|
2009-11-23 23:17:23 +00:00
|
|
|
* data for introspection we only need to know if it can be edited so the
|
|
|
|
* flag is better for this */
|
2012-03-05 23:30:41 +00:00
|
|
|
/* return RNA_property_editable(ptr, prop); */
|
2015-02-20 19:54:28 +11:00
|
|
|
return (prop->flag & PROP_EDITABLE) == 0;
|
2008-12-19 04:06:24 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Property_animatable_get(PointerRNA *ptr)
|
2011-10-08 12:27:52 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2011-10-08 12:27:52 +00:00
|
|
|
|
|
|
|
return (prop->flag & PROP_ANIMATABLE) != 0;
|
|
|
|
}
|
|
|
|
|
2018-07-05 22:46:04 +02:00
|
|
|
static bool rna_Property_overridable_get(PointerRNA *ptr)
|
2017-11-29 15:31:31 +01:00
|
|
|
{
|
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
|
|
|
|
2018-06-05 11:10:05 +02:00
|
|
|
return (prop->flag_override & PROPOVERRIDE_OVERRIDABLE_STATIC) != 0;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Property_use_output_get(PointerRNA *ptr)
|
2009-08-16 15:46:09 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
return (prop->flag_parameter & PARM_OUTPUT) != 0;
|
2009-08-16 15:46:09 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Property_is_required_get(PointerRNA *ptr)
|
2009-12-25 14:42:00 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
return (prop->flag_parameter & PARM_REQUIRED) != 0;
|
2009-12-25 14:42:00 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Property_is_argument_optional_get(PointerRNA *ptr)
|
2013-08-26 21:39:06 +00:00
|
|
|
{
|
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
return (prop->flag_parameter & PARM_PYFUNC_OPTIONAL) != 0;
|
2013-08-26 21:39:06 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Property_is_never_none_get(PointerRNA *ptr)
|
2009-12-25 14:42:00 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2015-02-20 19:54:28 +11:00
|
|
|
return (prop->flag & PROP_NEVER_NULL) != 0;
|
2009-12-25 14:42:00 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Property_is_hidden_get(PointerRNA *ptr)
|
2010-12-24 07:30:15 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2015-02-20 19:54:28 +11:00
|
|
|
return (prop->flag & PROP_HIDDEN) != 0;
|
2010-12-24 07:30:15 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Property_is_skip_save_get(PointerRNA *ptr)
|
2011-06-07 10:54:57 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2015-02-20 19:54:28 +11:00
|
|
|
return (prop->flag & PROP_SKIP_SAVE) != 0;
|
2011-06-07 10:54:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Property_is_enum_flag_get(PointerRNA *ptr)
|
2011-02-16 10:19:14 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2015-02-20 19:54:28 +11:00
|
|
|
return (prop->flag & PROP_ENUM_FLAG) != 0;
|
2011-02-16 10:19:14 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Property_is_library_editable_flag_get(PointerRNA *ptr)
|
2012-05-19 21:22:01 +00:00
|
|
|
{
|
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2015-02-20 19:54:28 +11:00
|
|
|
return (prop->flag & PROP_LIB_EXCEPTION) != 0;
|
2012-05-19 21:22:01 +00:00
|
|
|
}
|
|
|
|
|
2017-11-23 13:41:07 +01:00
|
|
|
static int rna_Property_tags_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return RNA_property_tags(ptr->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const EnumPropertyItem *rna_Property_tags_itemf(
|
|
|
|
bContext *UNUSED(C), PointerRNA *ptr,
|
|
|
|
PropertyRNA *UNUSED(prop), bool *r_free)
|
|
|
|
{
|
|
|
|
PropertyRNA *this_prop = (PropertyRNA *)ptr->data;
|
|
|
|
const StructRNA *srna = RNA_property_pointer_type(ptr, this_prop);
|
|
|
|
EnumPropertyItem *prop_tags;
|
|
|
|
EnumPropertyItem tmp = {0, "", 0, "", ""};
|
|
|
|
int totitem = 0;
|
|
|
|
|
|
|
|
for (const EnumPropertyItem *struct_tags = RNA_struct_property_tag_defines(srna);
|
2018-04-03 14:30:36 +02:00
|
|
|
struct_tags != NULL && struct_tags->identifier != NULL;
|
2017-11-23 13:41:07 +01:00
|
|
|
struct_tags++)
|
|
|
|
{
|
|
|
|
memcpy(&tmp, struct_tags, sizeof(tmp));
|
|
|
|
RNA_enum_item_add(&prop_tags, &totitem, &tmp);
|
|
|
|
}
|
|
|
|
RNA_enum_item_end(&prop_tags, &totitem);
|
|
|
|
*r_free = true;
|
|
|
|
|
|
|
|
return prop_tags;
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Property_array_length_get(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2009-09-09 19:40:46 +00:00
|
|
|
return prop->totarraylength;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2017-09-20 16:37:01 +02:00
|
|
|
static void rna_Property_array_dimensions_get(PointerRNA *ptr, int dimensions[RNA_MAX_ARRAY_DIMENSION])
|
|
|
|
{
|
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
|
|
|
|
if (prop->arraydimension > 1) {
|
|
|
|
for (int i = RNA_MAX_ARRAY_DIMENSION; i--; ) {
|
|
|
|
dimensions[i] = (i >= prop->arraydimension) ? 0 : prop->arraylength[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
memset(dimensions, 0, sizeof(*dimensions) * RNA_MAX_ARRAY_DIMENSION);
|
|
|
|
dimensions[0] = prop->totarraylength;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Property_is_registered_get(PointerRNA *ptr)
|
2009-04-19 13:37:59 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2015-02-20 19:54:28 +11:00
|
|
|
return (prop->flag & PROP_REGISTER) != 0;
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Property_is_registered_optional_get(PointerRNA *ptr)
|
2009-04-19 13:37:59 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2015-02-20 19:54:28 +11:00
|
|
|
return (prop->flag & PROP_REGISTER_OPTIONAL) != 0;
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Property_is_runtime_get(PointerRNA *ptr)
|
2010-09-02 14:43:22 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
return (prop->flag_internal & PROP_INTERN_RUNTIME) != 0;
|
2010-09-02 14:43:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_BoolProperty_default_get(PointerRNA *ptr)
|
2009-07-26 18:18:14 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2009-07-26 18:18:14 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((BoolPropertyRNA *)prop)->defaultvalue;
|
2009-07-26 18:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_IntProperty_default_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2009-07-26 18:18:14 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((IntPropertyRNA *)prop)->defaultvalue;
|
2009-07-26 18:18:14 +00:00
|
|
|
}
|
2009-09-15 10:01:20 +00:00
|
|
|
/* int/float/bool */
|
|
|
|
static int rna_NumberProperty_default_array_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2009-09-15 10:01:20 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
length[0] = prop->totarraylength;
|
2009-09-15 10:01:20 +00:00
|
|
|
|
|
|
|
return length[0];
|
|
|
|
}
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_NumberProperty_is_array_get(PointerRNA *ptr)
|
2016-02-29 11:02:08 +11:00
|
|
|
{
|
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
|
|
|
|
|
|
|
return RNA_property_array_check(prop);
|
|
|
|
}
|
|
|
|
|
2009-09-15 10:01:20 +00:00
|
|
|
static void rna_IntProperty_default_array_get(PointerRNA *ptr, int *values)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2009-09-15 10:01:20 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2018-11-11 20:56:42 +03:00
|
|
|
if (prop->totarraylength > 0) {
|
|
|
|
RNA_property_int_get_default_array(ptr, prop, values);
|
2009-09-15 10:01:20 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-11 20:56:42 +03:00
|
|
|
|
2018-07-01 15:47:09 +02:00
|
|
|
static void rna_BoolProperty_default_array_get(PointerRNA *ptr, bool *values)
|
2009-09-15 10:01:20 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2009-09-15 10:01:20 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2018-11-11 20:56:42 +03:00
|
|
|
if (prop->totarraylength > 0) {
|
|
|
|
RNA_property_boolean_get_default_array(ptr, prop, values);
|
2009-09-15 10:01:20 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-11 20:56:42 +03:00
|
|
|
|
2009-09-15 10:01:20 +00:00
|
|
|
static void rna_FloatProperty_default_array_get(PointerRNA *ptr, float *values)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2009-09-15 10:01:20 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2018-11-11 20:56:42 +03:00
|
|
|
if (prop->totarraylength > 0) {
|
|
|
|
RNA_property_float_get_default_array(ptr, prop, values);
|
2009-09-15 10:01:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_IntProperty_hard_min_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((IntPropertyRNA *)prop)->hardmin;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_IntProperty_hard_max_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((IntPropertyRNA *)prop)->hardmax;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_IntProperty_soft_min_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((IntPropertyRNA *)prop)->softmin;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_IntProperty_soft_max_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((IntPropertyRNA *)prop)->softmax;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_IntProperty_step_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((IntPropertyRNA *)prop)->step;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
2009-07-26 18:18:14 +00:00
|
|
|
static float rna_FloatProperty_default_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2009-07-26 18:18:14 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((FloatPropertyRNA *)prop)->defaultvalue;
|
2009-07-26 18:18:14 +00:00
|
|
|
}
|
2008-11-14 18:46:57 +00:00
|
|
|
static float rna_FloatProperty_hard_min_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((FloatPropertyRNA *)prop)->hardmin;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static float rna_FloatProperty_hard_max_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((FloatPropertyRNA *)prop)->hardmax;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static float rna_FloatProperty_soft_min_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((FloatPropertyRNA *)prop)->softmin;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static float rna_FloatProperty_soft_max_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((FloatPropertyRNA *)prop)->softmax;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static float rna_FloatProperty_step_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((FloatPropertyRNA *)prop)->step;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_FloatProperty_precision_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((FloatPropertyRNA *)prop)->precision;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
2009-07-26 18:18:14 +00:00
|
|
|
static void rna_StringProperty_default_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2009-07-26 18:18:14 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
strcpy(value, ((StringPropertyRNA *)prop)->defaultvalue);
|
2009-07-26 18:18:14 +00:00
|
|
|
}
|
|
|
|
static int rna_StringProperty_default_length(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2009-07-26 18:18:14 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return strlen(((StringPropertyRNA *)prop)->defaultvalue);
|
2009-07-26 18:18:14 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_StringProperty_max_length_get(PointerRNA *ptr)
|
2008-11-14 17:05:25 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((StringPropertyRNA *)prop)->maxlength;
|
2008-11-14 17:05:25 +00:00
|
|
|
}
|
|
|
|
|
2019-01-02 17:03:45 +11:00
|
|
|
static const EnumPropertyItem *rna_EnumProperty_default_itemf(
|
|
|
|
bContext *C, PointerRNA *ptr,
|
|
|
|
PropertyRNA *prop_parent, bool *r_free)
|
2009-07-26 18:18:14 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2009-07-26 18:18:14 +00:00
|
|
|
EnumPropertyRNA *eprop;
|
|
|
|
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
eprop = (EnumPropertyRNA *)prop;
|
2009-07-26 18:18:14 +00:00
|
|
|
|
2011-11-27 14:13:10 +00:00
|
|
|
/* incompatible default attributes */
|
|
|
|
if ((prop_parent->flag & PROP_ENUM_FLAG) != (prop->flag & PROP_ENUM_FLAG)) {
|
2015-02-24 19:41:48 +11:00
|
|
|
return DummyRNA_NULL_items;
|
2011-11-27 14:13:10 +00:00
|
|
|
}
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
if ((eprop->itemf == NULL) ||
|
|
|
|
(eprop->itemf == rna_EnumProperty_default_itemf) ||
|
|
|
|
(ptr->type == &RNA_EnumProperty) ||
|
|
|
|
(C == NULL))
|
2009-12-25 09:01:23 +00:00
|
|
|
{
|
2014-03-20 19:17:08 +11:00
|
|
|
if (eprop->item) {
|
|
|
|
return eprop->item;
|
|
|
|
}
|
2009-12-25 09:01:23 +00:00
|
|
|
}
|
2009-07-26 18:18:14 +00:00
|
|
|
|
2014-01-04 18:08:43 +11:00
|
|
|
return eprop->itemf(C, ptr, prop, r_free);
|
2009-07-26 18:18:14 +00:00
|
|
|
}
|
|
|
|
|
2009-12-25 09:01:23 +00:00
|
|
|
/* XXX - not sure this is needed? */
|
2009-07-26 18:18:14 +00:00
|
|
|
static int rna_EnumProperty_default_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2009-07-26 18:18:14 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((EnumPropertyRNA *)prop)->defaultvalue;
|
2009-07-26 18:18:14 +00:00
|
|
|
}
|
|
|
|
|
2011-10-20 00:19:21 +00:00
|
|
|
static int rna_enum_check_separator(CollectionPropertyIterator *UNUSED(iter), void *data)
|
2009-07-10 11:36:02 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
EnumPropertyItem *item = (EnumPropertyItem *)data;
|
2009-07-10 11:36:02 +00:00
|
|
|
|
2009-07-13 19:33:59 +00:00
|
|
|
return (item->identifier[0] == 0);
|
2009-07-10 11:36:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
2012-03-05 23:30:41 +00:00
|
|
|
/* EnumPropertyRNA *eprop; *//* UNUSED */
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem *item = NULL;
|
2014-01-04 18:08:43 +11:00
|
|
|
int totitem;
|
|
|
|
bool free;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-10-26 04:14:10 +00:00
|
|
|
/* eprop = (EnumPropertyRNA *)prop; */
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2016-02-09 12:44:06 +01:00
|
|
|
RNA_property_enum_items_ex(
|
|
|
|
NULL, ptr, prop, STREQ(iter->prop->identifier, "enum_items_static"), &item, &totitem, &free);
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_iterator_array_begin(iter, (void *)item, sizeof(EnumPropertyItem), totitem, free, rna_enum_check_separator);
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_EnumPropertyItem_identifier_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
strcpy(value, ((EnumPropertyItem *)ptr->data)->identifier);
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_EnumPropertyItem_identifier_length(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
return strlen(((EnumPropertyItem *)ptr->data)->identifier);
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_EnumPropertyItem_name_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
strcpy(value, ((EnumPropertyItem *)ptr->data)->name);
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_EnumPropertyItem_name_length(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
return strlen(((EnumPropertyItem *)ptr->data)->name);
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
2009-07-08 15:34:41 +00:00
|
|
|
static void rna_EnumPropertyItem_description_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
EnumPropertyItem *eprop = (EnumPropertyItem *)ptr->data;
|
2009-07-08 15:34:41 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (eprop->description)
|
2009-07-08 15:34:41 +00:00
|
|
|
strcpy(value, eprop->description);
|
|
|
|
else
|
2012-03-05 23:30:41 +00:00
|
|
|
value[0] = '\0';
|
2009-07-08 15:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_EnumPropertyItem_description_length(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
EnumPropertyItem *eprop = (EnumPropertyItem *)ptr->data;
|
2009-07-08 15:34:41 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (eprop->description)
|
2009-07-08 15:34:41 +00:00
|
|
|
return strlen(eprop->description);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_EnumPropertyItem_value_get(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
return ((EnumPropertyItem *)ptr->data)->value;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
2013-01-13 16:18:35 +00:00
|
|
|
static int rna_EnumPropertyItem_icon_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return ((EnumPropertyItem *)ptr->data)->icon;
|
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_PointerProperty_fixed_type_get(PointerRNA *ptr)
|
2008-11-14 18:46:57 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((PointerPropertyRNA *)prop)->type);
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_CollectionProperty_fixed_type_get(PointerRNA *ptr)
|
2008-11-14 18:46:57 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((CollectionPropertyRNA *)prop)->item_type);
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
/* Function */
|
|
|
|
|
|
|
|
static void rna_Function_identifier_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
strcpy(value, ((FunctionRNA *)ptr->data)->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_Function_identifier_length(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
return strlen(((FunctionRNA *)ptr->data)->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Function_description_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
strcpy(value, ((FunctionRNA *)ptr->data)->description);
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_Function_description_length(PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
return strlen(((FunctionRNA *)ptr->data)->description);
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Function_parameters_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &((FunctionRNA *)ptr->data)->cont.properties, rna_property_builtin);
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Function_registered_get(PointerRNA *ptr)
|
2009-04-19 13:37:59 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
FunctionRNA *func = (FunctionRNA *)ptr->data;
|
2016-02-08 10:13:09 +01:00
|
|
|
return 0 != (func->flag & FUNC_REGISTER);
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Function_registered_optional_get(PointerRNA *ptr)
|
2009-04-19 13:37:59 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
FunctionRNA *func = (FunctionRNA *)ptr->data;
|
2016-02-08 10:13:09 +01:00
|
|
|
return 0 != (func->flag & (FUNC_REGISTER_OPTIONAL & ~FUNC_REGISTER));
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Function_no_self_get(PointerRNA *ptr)
|
2010-08-17 14:32:14 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
FunctionRNA *func = (FunctionRNA *)ptr->data;
|
2010-08-18 07:14:10 +00:00
|
|
|
return !(func->flag & FUNC_NO_SELF);
|
2010-08-17 14:32:14 +00:00
|
|
|
}
|
|
|
|
|
2012-12-20 09:33:12 +00:00
|
|
|
static int rna_Function_use_self_type_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
FunctionRNA *func = (FunctionRNA *)ptr->data;
|
2016-02-08 10:13:09 +01:00
|
|
|
return 0 != (func->flag & FUNC_USE_SELF_TYPE);
|
2012-12-20 09:33:12 +00:00
|
|
|
}
|
|
|
|
|
2008-12-15 13:46:50 +00:00
|
|
|
/* Blender RNA */
|
|
|
|
|
2017-08-31 23:32:21 +10:00
|
|
|
static int rna_struct_is_publc(CollectionPropertyIterator *UNUSED(iter), void *data)
|
|
|
|
{
|
|
|
|
StructRNA *srna = data;
|
|
|
|
|
|
|
|
return !(srna->flag & STRUCT_PUBLIC_NAMESPACE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-15 13:46:50 +00:00
|
|
|
static void rna_BlenderRNA_structs_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
2017-08-11 17:51:38 +10:00
|
|
|
BlenderRNA *brna = ptr->data;
|
2017-08-31 23:32:21 +10:00
|
|
|
rna_iterator_listbase_begin(iter, &brna->structs, rna_struct_is_publc);
|
2008-12-15 13:46:50 +00:00
|
|
|
}
|
|
|
|
|
2010-01-22 14:06:42 +00:00
|
|
|
/* optional, for faster lookups */
|
2010-01-22 14:59:01 +00:00
|
|
|
static int rna_BlenderRNA_structs_length(PointerRNA *ptr)
|
2010-01-22 14:06:42 +00:00
|
|
|
{
|
2017-08-11 17:51:38 +10:00
|
|
|
BlenderRNA *brna = ptr->data;
|
|
|
|
BLI_assert(brna->structs_len == BLI_listbase_count(&brna->structs));
|
|
|
|
return brna->structs_len;
|
2010-01-22 14:06:42 +00:00
|
|
|
}
|
2011-01-05 14:49:08 +00:00
|
|
|
static int rna_BlenderRNA_structs_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
|
2010-01-22 14:06:42 +00:00
|
|
|
{
|
2017-08-11 17:51:38 +10:00
|
|
|
BlenderRNA *brna = ptr->data;
|
|
|
|
StructRNA *srna = index < brna->structs_len ? BLI_findlink(&brna->structs, index) : NULL;
|
|
|
|
if (srna != NULL) {
|
2011-01-05 14:49:08 +00:00
|
|
|
RNA_pointer_create(NULL, &RNA_Struct, srna, r_ptr);
|
2014-04-01 11:34:00 +11:00
|
|
|
return true;
|
2010-01-22 14:06:42 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2010-01-22 14:06:42 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-05 14:49:08 +00:00
|
|
|
static int rna_BlenderRNA_structs_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
|
2010-01-22 14:06:42 +00:00
|
|
|
{
|
2017-08-11 17:51:38 +10:00
|
|
|
BlenderRNA *brna = ptr->data;
|
|
|
|
StructRNA *srna = BLI_ghash_lookup(brna->structs_map, (void *)key);
|
|
|
|
if (srna != NULL) {
|
|
|
|
RNA_pointer_create(NULL, &RNA_Struct, srna, r_ptr);
|
|
|
|
return true;
|
2010-01-22 14:06:42 +00:00
|
|
|
}
|
2011-01-05 14:49:08 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2010-01-22 14:06:42 +00:00
|
|
|
}
|
|
|
|
|
2017-11-29 15:31:31 +01:00
|
|
|
/* Default override (and compare) callbacks. */
|
|
|
|
|
2018-05-01 15:24:17 +02:00
|
|
|
/* Ensures it makes sense to go inside the pointers to compare their content
|
|
|
|
* (if they are IDs, or have different names or RNA type, then this would be meaningless). */
|
|
|
|
static bool rna_property_override_diff_propptr_validate_diffing(
|
2018-06-05 11:58:56 +02:00
|
|
|
PointerRNA *propptr_a, PointerRNA *propptr_b, const bool no_prop_name,
|
2018-05-01 15:24:17 +02:00
|
|
|
bool *r_is_id, bool *r_is_null, bool *r_is_type_diff,
|
|
|
|
char **r_propname_a, char *propname_a_buff, size_t propname_a_buff_size,
|
|
|
|
char **r_propname_b, char *propname_b_buff, size_t propname_b_buff_size)
|
2017-11-29 15:31:31 +01:00
|
|
|
{
|
2018-05-01 15:24:17 +02:00
|
|
|
BLI_assert(propptr_a != NULL);
|
2017-12-18 10:13:43 +01:00
|
|
|
|
2018-05-01 15:24:17 +02:00
|
|
|
bool is_valid_for_diffing = true;
|
2018-06-05 11:58:56 +02:00
|
|
|
const bool do_force_name = !no_prop_name && r_propname_a != NULL;
|
2018-05-01 15:24:17 +02:00
|
|
|
|
|
|
|
if (do_force_name) {
|
|
|
|
BLI_assert(r_propname_a != NULL);
|
|
|
|
BLI_assert(r_propname_b != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
*r_is_id = *r_is_null = *r_is_type_diff = false;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
|
|
|
/* Beware, PointerRNA_NULL has no type and is considered a 'blank page'! */
|
|
|
|
if (propptr_a->type == NULL) {
|
2018-05-01 15:24:17 +02:00
|
|
|
if (propptr_b == NULL || propptr_b->type == NULL) {
|
|
|
|
*r_is_null = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*r_is_id = RNA_struct_is_ID(propptr_b->type);
|
|
|
|
*r_is_null = true;
|
|
|
|
*r_is_type_diff = true;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
2018-05-01 15:24:17 +02:00
|
|
|
is_valid_for_diffing = false;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
else {
|
2018-05-01 15:24:17 +02:00
|
|
|
*r_is_id = RNA_struct_is_ID(propptr_a->type);
|
|
|
|
*r_is_null = *r_is_type_diff = (ELEM(NULL, propptr_b, propptr_b->type));
|
|
|
|
is_valid_for_diffing = !(*r_is_id || *r_is_null);
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
|
2018-05-01 15:24:17 +02:00
|
|
|
if (propptr_b == NULL || propptr_a->type != propptr_b->type) {
|
|
|
|
*r_is_type_diff = true;
|
|
|
|
is_valid_for_diffing = false;
|
|
|
|
// printf("%s: different pointer RNA types\n", rna_path ? rna_path : "<UNKNOWN>");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We do a generic quick first comparison checking for "name" and/or "type" properties.
|
|
|
|
* We assume that is any of those are false, then we are not handling the same data.
|
|
|
|
* This helps a lot in static override case, especially to detect inserted items in collections. */
|
2018-06-05 11:58:56 +02:00
|
|
|
if (!no_prop_name && (is_valid_for_diffing || do_force_name)) {
|
2018-05-01 15:24:17 +02:00
|
|
|
PropertyRNA *nameprop_a = RNA_struct_name_property(propptr_a->type);
|
|
|
|
PropertyRNA *nameprop_b = (propptr_b != NULL) ? RNA_struct_name_property(propptr_b->type) : NULL;
|
|
|
|
|
|
|
|
int propname_a_len = 0, propname_b_len = 0;
|
|
|
|
char *propname_a = NULL;
|
|
|
|
char *propname_b = NULL;
|
|
|
|
char buff_a[4096];
|
|
|
|
char buff_b[4096];
|
|
|
|
if (nameprop_a != NULL) {
|
|
|
|
if (r_propname_a == NULL && propname_a_buff == NULL) {
|
|
|
|
propname_a_buff = buff_a;
|
|
|
|
propname_a_buff_size = sizeof(buff_a);
|
|
|
|
}
|
|
|
|
|
|
|
|
propname_a = RNA_property_string_get_alloc(
|
|
|
|
propptr_a, nameprop_a, propname_a_buff, propname_a_buff_size, &propname_a_len);
|
|
|
|
// printf("propname_a = %s\n", propname_a ? propname_a : "<NONE>");
|
|
|
|
|
|
|
|
if (r_propname_a != NULL) {
|
|
|
|
*r_propname_a = propname_a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// else printf("item of type %s a has no name property!\n", propptr_a->type->name);
|
|
|
|
if (nameprop_b != NULL) {
|
|
|
|
if (r_propname_b == NULL && propname_b_buff == NULL) {
|
|
|
|
propname_b_buff = buff_b;
|
|
|
|
propname_b_buff_size = sizeof(buff_b);
|
|
|
|
}
|
|
|
|
|
|
|
|
propname_b = RNA_property_string_get_alloc(
|
|
|
|
propptr_b, nameprop_b, propname_b_buff, propname_b_buff_size, &propname_b_len);
|
|
|
|
|
|
|
|
if (r_propname_b != NULL) {
|
|
|
|
*r_propname_b = propname_b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (propname_a != NULL && propname_b != NULL) {
|
|
|
|
if (propname_a_len != propname_b_len ||
|
|
|
|
propname_a[0] != propname_b[0] ||
|
|
|
|
!STREQ(propname_a, propname_b))
|
|
|
|
{
|
|
|
|
is_valid_for_diffing = false;
|
|
|
|
// printf("%s: different names\n", rna_path ? rna_path : "<UNKNOWN>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*r_is_id) {
|
2017-11-29 15:31:31 +01:00
|
|
|
BLI_assert(propptr_a->data == propptr_a->id.data && propptr_b->data == propptr_b->id.data);
|
2018-05-01 15:24:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return is_valid_for_diffing;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Used for both Pointer and Collection properties. */
|
|
|
|
static int rna_property_override_diff_propptr(
|
2018-06-29 12:46:54 +02:00
|
|
|
Main *bmain,
|
2018-06-05 11:58:56 +02:00
|
|
|
PointerRNA *propptr_a, PointerRNA *propptr_b,
|
|
|
|
eRNACompareMode mode, const bool no_ownership, const bool no_prop_name,
|
2018-05-01 15:24:17 +02:00
|
|
|
IDOverrideStatic *override, const char *rna_path, const int flags, bool *r_override_changed)
|
|
|
|
{
|
|
|
|
const bool do_create = override != NULL && (flags & RNA_OVERRIDE_COMPARE_CREATE) != 0 && rna_path != NULL;
|
|
|
|
|
|
|
|
bool is_id = false;
|
|
|
|
bool is_null = false;
|
|
|
|
bool is_type_diff = false;
|
|
|
|
/* If false, it means that the whole data itself is different, so no point in going inside of it at all! */
|
|
|
|
bool is_valid_for_diffing = rna_property_override_diff_propptr_validate_diffing(
|
2018-06-05 11:58:56 +02:00
|
|
|
propptr_a, propptr_b, no_prop_name, &is_id, &is_null, &is_type_diff,
|
2018-05-01 15:24:17 +02:00
|
|
|
NULL, NULL, 0, NULL, NULL, 0);
|
|
|
|
|
|
|
|
if (is_id) {
|
2017-12-18 10:13:43 +01:00
|
|
|
BLI_assert(no_ownership); /* For now, once we deal with nodetrees we'll want to get rid of that one. */
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (override) {
|
2018-05-01 15:24:17 +02:00
|
|
|
if (no_ownership /* || is_id */ || is_null || is_type_diff || !is_valid_for_diffing) {
|
2017-12-18 10:13:43 +01:00
|
|
|
/* In case this pointer prop does not own its data (or one is NULL), do not compare structs!
|
|
|
|
* This is a quite safe path to infinite loop, among other nasty issues.
|
|
|
|
* Instead, just compare pointers themselves. */
|
|
|
|
const int comp = (propptr_a->data != propptr_b->data);
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2017-12-18 10:13:43 +01:00
|
|
|
if (do_create && comp != 0) {
|
|
|
|
bool created = false;
|
|
|
|
IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created);
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2017-12-18 10:13:43 +01:00
|
|
|
if (op != NULL && created) { /* If not yet overridden... */
|
|
|
|
BKE_override_static_property_operation_get(
|
|
|
|
op, IDOVERRIDESTATIC_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
|
|
|
|
if (r_override_changed) {
|
|
|
|
*r_override_changed = created;
|
|
|
|
}
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
}
|
2017-12-18 10:13:43 +01:00
|
|
|
|
|
|
|
return comp;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
else {
|
2017-12-18 10:13:43 +01:00
|
|
|
eRNAOverrideMatchResult report_flags = 0;
|
2018-06-29 12:46:54 +02:00
|
|
|
const bool match = RNA_struct_override_matches(
|
|
|
|
bmain, propptr_a, propptr_b, rna_path, override, flags, &report_flags);
|
2017-12-18 10:13:43 +01:00
|
|
|
if (r_override_changed && (report_flags & RNA_OVERRIDE_MATCH_RESULT_CREATED) != 0) {
|
|
|
|
*r_override_changed = true;
|
|
|
|
}
|
|
|
|
return !match;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2018-05-01 15:24:17 +02:00
|
|
|
/* We could also use is_diff_pointer, but then we potentially lose the gt/lt info -
|
|
|
|
* and don't think performances are critical here for now anyway... */
|
2018-06-29 12:46:54 +02:00
|
|
|
return !RNA_struct_equals(bmain, propptr_a, propptr_b, mode);
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
#define RNA_PROPERTY_GET_SINGLE(_typename, _ptr, _prop, _index) \
|
|
|
|
(is_array ? RNA_property_##_typename##_get_index((_ptr), (_prop), (_index)) : \
|
|
|
|
RNA_property_##_typename##_get((_ptr), (_prop)))
|
|
|
|
#define RNA_PROPERTY_SET_SINGLE(_typename, _ptr, _prop, _index, _value) \
|
|
|
|
(is_array ? RNA_property_##_typename##_set_index((_ptr), (_prop), (_index), (_value)) : \
|
|
|
|
RNA_property_##_typename##_set((_ptr), (_prop), (_value)))
|
|
|
|
|
2018-06-29 12:46:54 +02:00
|
|
|
int rna_property_override_diff_default(
|
|
|
|
Main *bmain,
|
|
|
|
PointerRNA *ptr_a, PointerRNA *ptr_b,
|
2017-11-29 15:31:31 +01:00
|
|
|
PropertyRNA *prop_a, PropertyRNA *prop_b,
|
|
|
|
const int len_a, const int len_b,
|
|
|
|
const int mode,
|
|
|
|
IDOverrideStatic *override, const char *rna_path,
|
|
|
|
const int flags, bool *r_override_changed)
|
|
|
|
{
|
|
|
|
BLI_assert(len_a == len_b);
|
|
|
|
|
2017-12-18 10:13:43 +01:00
|
|
|
/* Note: at this point, we are sure that when len_a is zero, we are not handling an (empty) array. */
|
|
|
|
|
|
|
|
const bool do_create = override != NULL && (flags & RNA_OVERRIDE_COMPARE_CREATE) != 0 && rna_path != NULL;
|
|
|
|
|
2017-11-29 15:31:31 +01:00
|
|
|
switch (RNA_property_type(prop_a)) {
|
|
|
|
case PROP_BOOLEAN:
|
|
|
|
{
|
|
|
|
if (len_a) {
|
2018-07-01 16:22:06 +02:00
|
|
|
bool array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
|
|
|
|
bool *array_a, *array_b;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-07-01 16:22:06 +02:00
|
|
|
array_a = (len_a > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(bool) * len_a, "RNA equals") : array_stack_a;
|
|
|
|
array_b = (len_b > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(bool) * len_b, "RNA equals") : array_stack_b;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
|
|
|
RNA_property_boolean_get_array(ptr_a, prop_a, array_a);
|
|
|
|
RNA_property_boolean_get_array(ptr_b, prop_b, array_b);
|
|
|
|
|
2018-07-01 16:22:06 +02:00
|
|
|
const int comp = memcmp(array_a, array_b, sizeof(bool) * len_a);
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2017-12-18 10:13:43 +01:00
|
|
|
if (do_create && comp != 0) {
|
2017-11-29 15:31:31 +01:00
|
|
|
/* XXX TODO this will have to be refined to handle array items */
|
|
|
|
bool created = false;
|
|
|
|
IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created);
|
|
|
|
|
|
|
|
if (op != NULL && created) {
|
|
|
|
BKE_override_static_property_operation_get(
|
|
|
|
op, IDOVERRIDESTATIC_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
|
|
|
|
if (r_override_changed) {
|
|
|
|
*r_override_changed = created;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2018-09-24 18:46:51 +02:00
|
|
|
/* Already overridden prop, we'll have to check arrays items etc. */
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (array_a != array_stack_a) MEM_freeN(array_a);
|
|
|
|
if (array_b != array_stack_b) MEM_freeN(array_b);
|
|
|
|
|
|
|
|
return comp;
|
|
|
|
}
|
|
|
|
else {
|
2018-07-01 16:22:06 +02:00
|
|
|
const bool value_a = RNA_property_boolean_get(ptr_a, prop_a);
|
|
|
|
const bool value_b = RNA_property_boolean_get(ptr_b, prop_b);
|
2017-11-29 15:31:31 +01:00
|
|
|
const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0;
|
|
|
|
|
2017-12-18 10:13:43 +01:00
|
|
|
if (do_create && comp != 0) {
|
2017-11-29 15:31:31 +01:00
|
|
|
bool created = false;
|
|
|
|
IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created);
|
|
|
|
|
|
|
|
if (op != NULL && created) { /* If not yet overridden... */
|
|
|
|
BKE_override_static_property_operation_get(
|
|
|
|
op, IDOVERRIDESTATIC_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
|
|
|
|
if (r_override_changed) {
|
|
|
|
*r_override_changed = created;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return comp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case PROP_INT:
|
|
|
|
{
|
|
|
|
if (len_a) {
|
|
|
|
int array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
|
|
|
|
int *array_a, *array_b;
|
|
|
|
|
|
|
|
array_a = (len_a > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(int) * len_a, "RNA equals") : array_stack_a;
|
|
|
|
array_b = (len_b > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(int) * len_b, "RNA equals") : array_stack_b;
|
|
|
|
|
|
|
|
RNA_property_int_get_array(ptr_a, prop_a, array_a);
|
|
|
|
RNA_property_int_get_array(ptr_b, prop_b, array_b);
|
|
|
|
|
|
|
|
const int comp = memcmp(array_a, array_b, sizeof(int) * len_a);
|
|
|
|
|
2017-12-18 10:13:43 +01:00
|
|
|
if (do_create && comp != 0) {
|
2017-11-29 15:31:31 +01:00
|
|
|
/* XXX TODO this will have to be refined to handle array items */
|
|
|
|
bool created = false;
|
|
|
|
IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created);
|
|
|
|
|
|
|
|
if (op != NULL && created) {
|
|
|
|
BKE_override_static_property_operation_get(
|
|
|
|
op, IDOVERRIDESTATIC_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
|
|
|
|
if (r_override_changed) {
|
|
|
|
*r_override_changed = created;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2018-09-24 18:46:51 +02:00
|
|
|
/* Already overridden prop, we'll have to check arrays items etc. */
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (array_a != array_stack_a) MEM_freeN(array_a);
|
|
|
|
if (array_b != array_stack_b) MEM_freeN(array_b);
|
|
|
|
|
|
|
|
return comp;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const int value_a = RNA_property_int_get(ptr_a, prop_a);
|
|
|
|
const int value_b = RNA_property_int_get(ptr_b, prop_b);
|
|
|
|
const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0;
|
|
|
|
|
2017-12-18 10:13:43 +01:00
|
|
|
if (do_create && comp != 0) {
|
2017-11-29 15:31:31 +01:00
|
|
|
bool created = false;
|
|
|
|
IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created);
|
|
|
|
|
|
|
|
if (op != NULL && created) { /* If not yet overridden... */
|
|
|
|
BKE_override_static_property_operation_get(
|
|
|
|
op, IDOVERRIDESTATIC_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
|
|
|
|
if (r_override_changed) {
|
|
|
|
*r_override_changed = created;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return comp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case PROP_FLOAT:
|
|
|
|
{
|
|
|
|
if (len_a) {
|
|
|
|
float array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
|
|
|
|
float *array_a, *array_b;
|
|
|
|
|
|
|
|
array_a = (len_a > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(float) * len_a, "RNA equals") : array_stack_a;
|
|
|
|
array_b = (len_b > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(float) * len_b, "RNA equals") : array_stack_b;
|
|
|
|
|
|
|
|
RNA_property_float_get_array(ptr_a, prop_a, array_a);
|
|
|
|
RNA_property_float_get_array(ptr_b, prop_b, array_b);
|
|
|
|
|
|
|
|
const int comp = memcmp(array_a, array_b, sizeof(float) * len_a);
|
|
|
|
|
2017-12-18 10:13:43 +01:00
|
|
|
if (do_create && comp != 0) {
|
2017-11-29 15:31:31 +01:00
|
|
|
/* XXX TODO this will have to be refined to handle array items */
|
|
|
|
bool created = false;
|
|
|
|
IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created);
|
|
|
|
|
|
|
|
if (op != NULL && created) {
|
|
|
|
BKE_override_static_property_operation_get(
|
2018-04-23 15:14:51 +02:00
|
|
|
op, IDOVERRIDESTATIC_OP_REPLACE,
|
2017-11-29 15:31:31 +01:00
|
|
|
NULL, NULL, -1, -1, true, NULL, NULL);
|
|
|
|
if (r_override_changed) {
|
|
|
|
*r_override_changed = created;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2018-09-24 18:46:51 +02:00
|
|
|
/* Already overridden prop, we'll have to check arrays items etc. */
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (array_a != array_stack_a) MEM_freeN(array_a);
|
|
|
|
if (array_b != array_stack_b) MEM_freeN(array_b);
|
|
|
|
|
|
|
|
return comp;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const float value_a = RNA_property_float_get(ptr_a, prop_a);
|
|
|
|
const float value_b = RNA_property_float_get(ptr_b, prop_b);
|
|
|
|
const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0;
|
|
|
|
|
2017-12-18 10:13:43 +01:00
|
|
|
if (do_create && comp != 0) {
|
2017-11-29 15:31:31 +01:00
|
|
|
bool created = false;
|
|
|
|
IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created);
|
|
|
|
|
|
|
|
if (op != NULL && created) { /* If not yet overridden... */
|
|
|
|
BKE_override_static_property_operation_get(
|
2018-04-23 15:14:51 +02:00
|
|
|
op, IDOVERRIDESTATIC_OP_REPLACE,
|
2017-11-29 15:31:31 +01:00
|
|
|
NULL, NULL, -1, -1, true, NULL, NULL);
|
|
|
|
if (r_override_changed) {
|
|
|
|
*r_override_changed = created;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return comp ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case PROP_ENUM:
|
|
|
|
{
|
|
|
|
const int value_a = RNA_property_enum_get(ptr_a, prop_a);
|
|
|
|
const int value_b = RNA_property_enum_get(ptr_b, prop_b);
|
|
|
|
const int comp = value_a != value_b;
|
|
|
|
|
2017-12-18 10:13:43 +01:00
|
|
|
if (do_create && comp != 0) {
|
2017-11-29 15:31:31 +01:00
|
|
|
bool created = false;
|
|
|
|
IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created);
|
|
|
|
|
|
|
|
if (op != NULL && created) { /* If not yet overridden... */
|
|
|
|
BKE_override_static_property_operation_get(
|
|
|
|
op, IDOVERRIDESTATIC_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
|
|
|
|
if (r_override_changed) {
|
|
|
|
*r_override_changed = created;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return comp;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PROP_STRING:
|
|
|
|
{
|
2018-05-01 15:24:17 +02:00
|
|
|
char fixed_a[4096], fixed_b[4096];
|
2017-11-29 15:31:31 +01:00
|
|
|
int len_str_a, len_str_b;
|
|
|
|
char *value_a = RNA_property_string_get_alloc(ptr_a, prop_a, fixed_a, sizeof(fixed_a), &len_str_a);
|
|
|
|
char *value_b = RNA_property_string_get_alloc(ptr_b, prop_b, fixed_b, sizeof(fixed_b), &len_str_b);
|
2018-05-01 15:24:17 +02:00
|
|
|
/* TODO we could do a check on length too, but then we would not have a 'real' string comparison...
|
|
|
|
* Maybe behind a eRNAOverrideMatch flag? */
|
|
|
|
// const int comp = len_str_a < len_str_b ? -1 : len_str_a > len_str_b ? 1 : strcmp(value_a, value_b);
|
2017-11-29 15:31:31 +01:00
|
|
|
const int comp = strcmp(value_a, value_b);
|
|
|
|
|
2017-12-18 10:13:43 +01:00
|
|
|
if (do_create && comp != 0) {
|
2017-11-29 15:31:31 +01:00
|
|
|
bool created = false;
|
|
|
|
IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created);
|
|
|
|
|
|
|
|
if (op != NULL && created) { /* If not yet overridden... */
|
|
|
|
BKE_override_static_property_operation_get(
|
|
|
|
op, IDOVERRIDESTATIC_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
|
|
|
|
if (r_override_changed) {
|
|
|
|
*r_override_changed = created;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value_a != fixed_a) MEM_freeN(value_a);
|
|
|
|
if (value_b != fixed_b) MEM_freeN(value_b);
|
|
|
|
|
|
|
|
return comp;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PROP_POINTER:
|
|
|
|
{
|
|
|
|
if (STREQ(RNA_property_identifier(prop_a), "rna_type")) {
|
|
|
|
/* Dummy 'pass' answer, this is a meta-data and must be ignored... */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PointerRNA propptr_a = RNA_property_pointer_get(ptr_a, prop_a);
|
|
|
|
PointerRNA propptr_b = RNA_property_pointer_get(ptr_b, prop_b);
|
2017-12-18 10:13:43 +01:00
|
|
|
const bool no_ownership = (RNA_property_flag(prop_a) & PROP_PTR_NO_OWNERSHIP) != 0;
|
2018-06-05 11:58:56 +02:00
|
|
|
const bool no_prop_name = (RNA_property_override_flag(prop_a) & PROPOVERRIDE_NO_PROP_NAME) != 0;
|
2017-12-18 10:13:43 +01:00
|
|
|
return rna_property_override_diff_propptr(
|
2018-06-29 12:46:54 +02:00
|
|
|
bmain,
|
2018-06-05 11:58:56 +02:00
|
|
|
&propptr_a, &propptr_b, mode, no_ownership, no_prop_name,
|
2017-12-18 10:13:43 +01:00
|
|
|
override, rna_path, flags, r_override_changed);
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PROP_COLLECTION:
|
|
|
|
{
|
2018-05-01 15:24:17 +02:00
|
|
|
/* Note: we assume we only insert in ptr_a (i.e. we can only get new items in ptr_a),
|
|
|
|
* and that we never remove anything. */
|
2018-06-05 11:10:05 +02:00
|
|
|
const bool use_insertion = (RNA_property_override_flag(prop_a) & PROPOVERRIDE_STATIC_INSERTION) && do_create;
|
2018-06-05 11:58:56 +02:00
|
|
|
const bool no_prop_name = (RNA_property_override_flag(prop_a) & PROPOVERRIDE_NO_PROP_NAME) != 0;
|
2017-11-29 15:31:31 +01:00
|
|
|
bool equals = true;
|
2018-05-01 15:24:17 +02:00
|
|
|
bool abort = false;
|
|
|
|
bool is_first_insert = true;
|
|
|
|
int idx_a = 0;
|
|
|
|
int idx_b = 0;
|
|
|
|
|
|
|
|
#define RNA_PATH_BUFFSIZE 8192
|
|
|
|
|
|
|
|
char extended_rna_path_buffer[RNA_PATH_BUFFSIZE];
|
|
|
|
char *extended_rna_path = extended_rna_path_buffer;
|
|
|
|
|
|
|
|
#define RNA_PATH_PRINTF(_str, ...) \
|
|
|
|
if (BLI_snprintf(extended_rna_path_buffer, RNA_PATH_BUFFSIZE, \
|
|
|
|
(_str), __VA_ARGS__) >= RNA_PATH_BUFFSIZE - 1) \
|
|
|
|
{ extended_rna_path = BLI_sprintfN((_str), __VA_ARGS__); }(void)0
|
|
|
|
#define RNA_PATH_FREE() \
|
|
|
|
if (extended_rna_path != extended_rna_path_buffer) MEM_freeN(extended_rna_path)
|
2017-11-29 15:31:31 +01:00
|
|
|
|
|
|
|
CollectionPropertyIterator iter_a, iter_b;
|
|
|
|
RNA_property_collection_begin(ptr_a, prop_a, &iter_a);
|
|
|
|
RNA_property_collection_begin(ptr_b, prop_b, &iter_b);
|
|
|
|
|
2018-05-01 15:24:17 +02:00
|
|
|
char buff_a[4096];
|
|
|
|
char buff_prev_a[4096] = {0};
|
|
|
|
char buff_b[4096];
|
|
|
|
char *propname_a = NULL;
|
|
|
|
char *prev_propname_a = buff_prev_a;
|
|
|
|
char *propname_b = NULL;
|
|
|
|
|
|
|
|
for (; iter_a.valid && !abort; ) {
|
|
|
|
bool is_valid_for_diffing;
|
|
|
|
bool is_valid_for_insertion;
|
|
|
|
do {
|
|
|
|
bool is_id = false, is_null = false, is_type_diff = false;
|
|
|
|
|
|
|
|
is_valid_for_insertion = use_insertion;
|
|
|
|
|
|
|
|
/* If false, it means that the whole data itself is different, so no point in going inside of it at all! */
|
|
|
|
if (iter_b.valid) {
|
|
|
|
is_valid_for_diffing = rna_property_override_diff_propptr_validate_diffing(
|
2018-06-05 11:58:56 +02:00
|
|
|
&iter_a.ptr, &iter_b.ptr, no_prop_name,
|
|
|
|
&is_id, &is_null, &is_type_diff,
|
|
|
|
&propname_a, buff_a, sizeof(buff_a),
|
|
|
|
&propname_b, buff_b, sizeof(buff_b));
|
2018-05-01 15:24:17 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
is_valid_for_diffing = false;
|
|
|
|
if (is_valid_for_insertion) {
|
|
|
|
/* We still need propname from 'a' item... */
|
|
|
|
rna_property_override_diff_propptr_validate_diffing(
|
2018-06-05 11:58:56 +02:00
|
|
|
&iter_a.ptr, NULL, no_prop_name,
|
|
|
|
&is_id, &is_null, &is_type_diff,
|
2018-05-01 15:24:17 +02:00
|
|
|
&propname_a, buff_a, sizeof(buff_a),
|
|
|
|
&propname_b, buff_b, sizeof(buff_b));
|
|
|
|
}
|
|
|
|
}
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-01 15:24:17 +02:00
|
|
|
/* We do not support insertion of IDs for now, neither handle NULL pointers. */
|
|
|
|
if (is_id || is_valid_for_diffing) {
|
|
|
|
is_valid_for_insertion = false;
|
|
|
|
}
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-01 15:24:17 +02:00
|
|
|
#if 0
|
|
|
|
if (rna_path) {
|
2018-06-28 14:25:18 +02:00
|
|
|
printf("Checking %s, %s [%d] vs %s [%d]; is_id: %d, diffing: %d; "
|
|
|
|
"insert: %d (could be used: %d, do_create: %d)\n",
|
2018-05-01 15:24:17 +02:00
|
|
|
rna_path, propname_a ? propname_a : "", idx_a, propname_b ? propname_b : "", idx_b,
|
2018-06-28 14:25:18 +02:00
|
|
|
is_id, is_valid_for_diffing, is_valid_for_insertion,
|
2018-06-05 11:10:05 +02:00
|
|
|
(RNA_property_override_flag(prop_a) & PROPOVERRIDE_STATIC_INSERTION) != 0, do_create);
|
2018-05-01 15:24:17 +02:00
|
|
|
}
|
|
|
|
#endif
|
2018-04-23 16:51:01 +02:00
|
|
|
|
2018-06-28 14:25:18 +02:00
|
|
|
if (!(is_id || is_valid_for_diffing || is_valid_for_insertion)) {
|
2018-05-01 15:24:17 +02:00
|
|
|
/* Differences we cannot handle, we can break here
|
|
|
|
* (we do not support replacing ID pointers in collections e.g.). */
|
2017-11-29 15:31:31 +01:00
|
|
|
equals = false;
|
2018-05-01 15:24:17 +02:00
|
|
|
abort = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* There may be a propname defined in some cases, while no actual name set
|
|
|
|
* (e.g. happens with point cache), in that case too we want to fall back to index.
|
|
|
|
* Note that we do not need the RNA path for insertion operations. */
|
2018-06-28 14:25:18 +02:00
|
|
|
if (is_id || is_valid_for_diffing) {
|
2018-05-01 15:24:17 +02:00
|
|
|
if ((propname_a != NULL && propname_a[0] != '\0') &&
|
|
|
|
(propname_b != NULL && propname_b[0] != '\0'))
|
|
|
|
{
|
|
|
|
if (rna_path) {
|
|
|
|
/* In case of name, either it is valid for diffing, and _a and _b are identical,
|
|
|
|
* or it is valid for insertion, and we need to use _a. */
|
|
|
|
char esc_item_name[RNA_PATH_BUFFSIZE];
|
|
|
|
BLI_strescape(esc_item_name, propname_a, RNA_PATH_BUFFSIZE);
|
|
|
|
RNA_PATH_PRINTF("%s[\"%s\"]", rna_path, esc_item_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { /* Based on index... */
|
|
|
|
if (rna_path) {
|
|
|
|
/* In case of indices, we need _a one for insertion, but _b ones for in-depth diffing.
|
|
|
|
* Insertion always happen once all 'replace' operations have been done,
|
|
|
|
* otherwise local and reference paths for those would have to be different! */
|
|
|
|
RNA_PATH_PRINTF("%s[%d]", rna_path, is_valid_for_insertion ? idx_a : idx_b);
|
|
|
|
}
|
|
|
|
}
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
2018-05-01 15:24:17 +02:00
|
|
|
|
|
|
|
/* Collections do not support replacement of their data (since they do not support removing),
|
|
|
|
* only in *some* cases, insertion.
|
|
|
|
* We also assume then that _a data is the one where things are inserted. */
|
|
|
|
if (is_valid_for_insertion && use_insertion) {
|
|
|
|
bool created;
|
|
|
|
IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created);
|
|
|
|
|
|
|
|
if (is_first_insert) {
|
|
|
|
/* We need to clean up all possible existing insertion operations, otherwise we'd end up
|
|
|
|
* with a mess of ops everytime something changes. */
|
|
|
|
for (IDOverrideStaticPropertyOperation *opop = op->operations.first;
|
|
|
|
opop != NULL;)
|
|
|
|
{
|
|
|
|
IDOverrideStaticPropertyOperation *opop_next = opop->next;
|
|
|
|
if (ELEM(opop->operation,
|
|
|
|
IDOVERRIDESTATIC_OP_INSERT_AFTER, IDOVERRIDESTATIC_OP_INSERT_BEFORE))
|
|
|
|
{
|
|
|
|
BKE_override_static_property_operation_delete(op, opop);
|
|
|
|
}
|
|
|
|
opop = opop_next;
|
|
|
|
}
|
|
|
|
is_first_insert = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
BKE_override_static_property_operation_get(
|
|
|
|
op, IDOVERRIDESTATIC_OP_INSERT_AFTER,
|
|
|
|
NULL, prev_propname_a, -1, idx_a - 1, true, NULL, NULL);
|
|
|
|
// printf("%s: Adding insertion op override after '%s'/%d\n", rna_path, prev_propname_a, idx_a - 1);
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
2018-06-28 14:25:18 +02:00
|
|
|
else if (is_id || is_valid_for_diffing) {
|
2018-05-01 15:24:17 +02:00
|
|
|
if (equals || do_create) {
|
|
|
|
const bool no_ownership = (RNA_property_flag(prop_a) & PROP_PTR_NO_OWNERSHIP) != 0;
|
|
|
|
const int eq = rna_property_override_diff_propptr(
|
2018-06-29 12:46:54 +02:00
|
|
|
bmain,
|
|
|
|
&iter_a.ptr, &iter_b.ptr, mode, no_ownership, no_prop_name,
|
|
|
|
override, extended_rna_path, flags, r_override_changed);
|
2018-05-01 15:24:17 +02:00
|
|
|
equals = equals && eq;
|
|
|
|
}
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
|
2018-05-01 15:24:17 +02:00
|
|
|
if (prev_propname_a != buff_prev_a) {
|
|
|
|
MEM_freeN(prev_propname_a);
|
|
|
|
prev_propname_a = buff_prev_a;
|
|
|
|
}
|
|
|
|
prev_propname_a[0] = '\0';
|
|
|
|
if (propname_a != NULL &&
|
|
|
|
BLI_strncpy_rlen(prev_propname_a, propname_a, sizeof(buff_prev_a)) >= sizeof(buff_prev_a) - 1)
|
|
|
|
{
|
|
|
|
prev_propname_a = BLI_strdup(propname_a);
|
|
|
|
}
|
|
|
|
if (propname_a != buff_a) {
|
|
|
|
MEM_SAFE_FREE(propname_a);
|
|
|
|
propname_a = buff_a;
|
|
|
|
}
|
|
|
|
propname_a[0] = '\0';
|
|
|
|
if (propname_b != buff_b) {
|
|
|
|
MEM_SAFE_FREE(propname_b);
|
|
|
|
propname_b = buff_b;
|
|
|
|
}
|
|
|
|
propname_b[0] = '\0';
|
|
|
|
RNA_PATH_FREE();
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-01 15:24:17 +02:00
|
|
|
if (!do_create && !equals) {
|
|
|
|
abort = true; /* Early out in case we do not want to loop over whole collection. */
|
|
|
|
break;
|
|
|
|
}
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-06-28 14:25:18 +02:00
|
|
|
if (!(use_insertion && !(is_id || is_valid_for_diffing))) {
|
2018-05-01 15:24:17 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iter_a.valid) {
|
|
|
|
RNA_property_collection_next(&iter_a);
|
|
|
|
idx_a++;
|
|
|
|
}
|
|
|
|
} while (iter_a.valid);
|
|
|
|
|
|
|
|
if (iter_a.valid) {
|
|
|
|
RNA_property_collection_next(&iter_a);
|
|
|
|
idx_a++;
|
|
|
|
}
|
|
|
|
if (iter_b.valid) {
|
|
|
|
RNA_property_collection_next(&iter_b);
|
|
|
|
idx_b++;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
2018-04-23 16:51:01 +02:00
|
|
|
|
|
|
|
#undef RNA_PATH_BUFFSIZE
|
|
|
|
#undef RNA_PATH_PRINTF
|
|
|
|
#undef RNA_PATH_FREE
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
|
2018-05-01 15:24:17 +02:00
|
|
|
equals = equals && !(iter_a.valid || iter_b.valid) && !abort; /* Not same number of items in both collections... */
|
2017-11-29 15:31:31 +01:00
|
|
|
RNA_property_collection_end(&iter_a);
|
|
|
|
RNA_property_collection_end(&iter_b);
|
|
|
|
|
|
|
|
return (equals == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rna_property_override_store_default(
|
2018-06-29 12:46:54 +02:00
|
|
|
Main *UNUSED(bmain),
|
2017-11-29 15:31:31 +01:00
|
|
|
PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage,
|
|
|
|
PropertyRNA *prop_local, PropertyRNA *prop_reference, PropertyRNA *prop_storage,
|
|
|
|
const int len_local, const int len_reference, const int len_storage,
|
|
|
|
IDOverrideStaticPropertyOperation *opop)
|
|
|
|
{
|
|
|
|
BLI_assert(len_local == len_reference && (!ptr_storage || len_local == len_storage));
|
2017-12-01 17:41:54 +01:00
|
|
|
UNUSED_VARS_NDEBUG(len_reference, len_storage);
|
2017-11-29 15:31:31 +01:00
|
|
|
|
|
|
|
bool changed = false;
|
2018-05-17 17:06:08 +02:00
|
|
|
const bool is_array = len_local > 0;
|
|
|
|
const int index = is_array ? opop->subitem_reference_index : 0;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
|
|
|
if (!ELEM(opop->operation, IDOVERRIDESTATIC_OP_ADD, IDOVERRIDESTATIC_OP_SUBTRACT, IDOVERRIDESTATIC_OP_MULTIPLY)) {
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX TODO About range limits.
|
2018-09-24 18:46:51 +02:00
|
|
|
* Ideally, it would be great to get rid of RNA range in that specific case.
|
2017-11-29 15:31:31 +01:00
|
|
|
* However, this won't be that easy and will add yet another layer of complexity in generated code,
|
|
|
|
* not to mention that we could most likely *not* bypass custom setters anyway.
|
|
|
|
* So for now, if needed second operand value is not in valid range, we simply fall back
|
|
|
|
* to a mere REPLACE operation.
|
|
|
|
* Time will say whether this is acceptable limitation or not. */
|
|
|
|
switch (RNA_property_type(prop_local)) {
|
|
|
|
case PROP_BOOLEAN:
|
|
|
|
/* TODO support boolean ops? Really doubt this would ever be useful though... */
|
|
|
|
BLI_assert(0 && "Boolean properties support no override diff operation");
|
|
|
|
break;
|
|
|
|
case PROP_INT:
|
|
|
|
{
|
|
|
|
int prop_min, prop_max;
|
|
|
|
RNA_property_int_range(ptr_local, prop_local, &prop_min, &prop_max);
|
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
if (is_array && index == -1) {
|
|
|
|
int array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
|
|
|
|
int *array_a, *array_b;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
array_a = (len_local > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_local, __func__) : array_stack_a;
|
|
|
|
RNA_property_int_get_array(ptr_reference, prop_reference, array_a);
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
switch (opop->operation) {
|
|
|
|
case IDOVERRIDESTATIC_OP_ADD:
|
|
|
|
case IDOVERRIDESTATIC_OP_SUBTRACT:
|
|
|
|
{
|
|
|
|
const int fac = opop->operation == IDOVERRIDESTATIC_OP_ADD ? 1 : -1;
|
|
|
|
const int other_op = opop->operation == IDOVERRIDESTATIC_OP_ADD ? IDOVERRIDESTATIC_OP_SUBTRACT : IDOVERRIDESTATIC_OP_ADD;
|
|
|
|
bool do_set = true;
|
|
|
|
array_b = (len_local > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_local, __func__) : array_stack_b;
|
|
|
|
RNA_property_int_get_array(ptr_local, prop_local, array_b);
|
|
|
|
for (int i = len_local; i--;) {
|
|
|
|
array_b[i] = fac * (array_b[i] - array_a[i]);
|
|
|
|
if (array_b[i] < prop_min || array_b[i] > prop_max) {
|
|
|
|
opop->operation = other_op;
|
|
|
|
for (int j = len_local; j--;) {
|
|
|
|
array_b[j] = j >= i ? -array_b[j] : fac * (array_a[j] - array_b[j]);
|
|
|
|
if (array_b[j] < prop_min || array_b[j] > prop_max) {
|
|
|
|
/* We failed to find a suitable diff op,
|
|
|
|
* fall back to plain REPLACE one. */
|
|
|
|
opop->operation = IDOVERRIDESTATIC_OP_REPLACE;
|
|
|
|
do_set = false;
|
|
|
|
break;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
}
|
2018-05-17 17:06:08 +02:00
|
|
|
break;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
}
|
2018-05-17 17:06:08 +02:00
|
|
|
if (do_set) {
|
2017-11-29 15:31:31 +01:00
|
|
|
changed = true;
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_property_int_set_array(ptr_storage, prop_storage, array_b);
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
2018-05-17 17:06:08 +02:00
|
|
|
if (array_b != array_stack_b) MEM_freeN(array_b);
|
|
|
|
break;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
2018-05-17 17:06:08 +02:00
|
|
|
default:
|
|
|
|
BLI_assert(0 && "Unsupported RNA override diff operation on integer");
|
|
|
|
break;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
2018-05-17 17:06:08 +02:00
|
|
|
|
|
|
|
if (array_a != array_stack_a) MEM_freeN(array_a);
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
else {
|
2018-05-17 17:06:08 +02:00
|
|
|
const int value = RNA_PROPERTY_GET_SINGLE(int, ptr_reference, prop_reference, index);
|
2017-11-29 15:31:31 +01:00
|
|
|
|
|
|
|
switch (opop->operation) {
|
|
|
|
case IDOVERRIDESTATIC_OP_ADD:
|
|
|
|
case IDOVERRIDESTATIC_OP_SUBTRACT:
|
|
|
|
{
|
|
|
|
const int fac = opop->operation == IDOVERRIDESTATIC_OP_ADD ? 1 : -1;
|
|
|
|
const int other_op = opop->operation == IDOVERRIDESTATIC_OP_ADD ? IDOVERRIDESTATIC_OP_SUBTRACT : IDOVERRIDESTATIC_OP_ADD;
|
2018-05-17 17:06:08 +02:00
|
|
|
int b = fac * (RNA_PROPERTY_GET_SINGLE(int, ptr_local, prop_local, index) - value);
|
2017-11-29 15:31:31 +01:00
|
|
|
if (b < prop_min || b > prop_max) {
|
|
|
|
opop->operation = other_op;
|
|
|
|
b = -b;
|
|
|
|
if (b < prop_min || b > prop_max) {
|
|
|
|
opop->operation = IDOVERRIDESTATIC_OP_REPLACE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
changed = true;
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_PROPERTY_SET_SINGLE(int, ptr_storage, prop_storage, index, b);
|
2017-11-29 15:31:31 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
BLI_assert(0 && "Unsupported RNA override diff operation on integer");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_FLOAT:
|
|
|
|
{
|
|
|
|
float prop_min, prop_max;
|
|
|
|
RNA_property_float_range(ptr_local, prop_local, &prop_min, &prop_max);
|
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
if (is_array && index == -1) {
|
|
|
|
float array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
|
|
|
|
float *array_a, *array_b;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
array_a = (len_local > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_local, __func__) : array_stack_a;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_property_float_get_array(ptr_reference, prop_reference, array_a);
|
|
|
|
switch (opop->operation) {
|
|
|
|
case IDOVERRIDESTATIC_OP_ADD:
|
|
|
|
case IDOVERRIDESTATIC_OP_SUBTRACT:
|
|
|
|
{
|
|
|
|
const float fac = opop->operation == IDOVERRIDESTATIC_OP_ADD ? 1.0 : -1.0;
|
|
|
|
const int other_op = opop->operation == IDOVERRIDESTATIC_OP_ADD ? IDOVERRIDESTATIC_OP_SUBTRACT : IDOVERRIDESTATIC_OP_ADD;
|
|
|
|
bool do_set = true;
|
|
|
|
array_b = (len_local > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_local, __func__) : array_stack_b;
|
|
|
|
RNA_property_float_get_array(ptr_local, prop_local, array_b);
|
|
|
|
for (int i = len_local; i--;) {
|
|
|
|
array_b[i] = fac * (array_b[i] - array_a[i]);
|
|
|
|
if (array_b[i] < prop_min || array_b[i] > prop_max) {
|
|
|
|
opop->operation = other_op;
|
|
|
|
for (int j = len_local; j--;) {
|
|
|
|
array_b[j] = j >= i ? -array_b[j] : fac * (array_a[j] - array_b[j]);
|
|
|
|
if (array_b[j] < prop_min || array_b[j] > prop_max) {
|
|
|
|
/* We failed to find a suitable diff op,
|
|
|
|
* fall back to plain REPLACE one. */
|
|
|
|
opop->operation = IDOVERRIDESTATIC_OP_REPLACE;
|
|
|
|
do_set = false;
|
|
|
|
break;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
}
|
2018-05-17 17:06:08 +02:00
|
|
|
break;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
}
|
2018-05-17 17:06:08 +02:00
|
|
|
if (do_set) {
|
2017-11-29 15:31:31 +01:00
|
|
|
changed = true;
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_property_float_set_array(ptr_storage, prop_storage, array_b);
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
2018-05-17 17:06:08 +02:00
|
|
|
if (array_b != array_stack_b) MEM_freeN(array_b);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IDOVERRIDESTATIC_OP_MULTIPLY:
|
|
|
|
{
|
|
|
|
bool do_set = true;
|
|
|
|
array_b = (len_local > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_local, __func__) : array_stack_b;
|
|
|
|
RNA_property_float_get_array(ptr_local, prop_local, array_b);
|
|
|
|
for (int i = len_local; i--;) {
|
|
|
|
array_b[i] = array_a[i] == 0.0f ? array_b[i] : array_b[i] / array_a[i];
|
|
|
|
if (array_b[i] < prop_min || array_b[i] > prop_max) {
|
2017-11-29 15:31:31 +01:00
|
|
|
opop->operation = IDOVERRIDESTATIC_OP_REPLACE;
|
2018-05-17 17:06:08 +02:00
|
|
|
do_set = false;
|
2017-11-29 15:31:31 +01:00
|
|
|
break;
|
|
|
|
}
|
2018-05-17 17:06:08 +02:00
|
|
|
}
|
|
|
|
if (do_set) {
|
2017-11-29 15:31:31 +01:00
|
|
|
changed = true;
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_property_float_set_array(ptr_storage, prop_storage, array_b);
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
2018-05-17 17:06:08 +02:00
|
|
|
if (array_b != array_stack_b) MEM_freeN(array_b);
|
|
|
|
break;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
2018-05-17 17:06:08 +02:00
|
|
|
default:
|
|
|
|
BLI_assert(0 && "Unsupported RNA override diff operation on float");
|
|
|
|
break;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
2018-05-17 17:06:08 +02:00
|
|
|
|
|
|
|
if (array_a != array_stack_a) MEM_freeN(array_a);
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
else {
|
2018-05-17 17:06:08 +02:00
|
|
|
const float value = RNA_PROPERTY_GET_SINGLE(float, ptr_reference, prop_reference, index);
|
2017-11-29 15:31:31 +01:00
|
|
|
|
|
|
|
switch (opop->operation) {
|
|
|
|
case IDOVERRIDESTATIC_OP_ADD:
|
|
|
|
case IDOVERRIDESTATIC_OP_SUBTRACT:
|
|
|
|
{
|
|
|
|
const float fac = opop->operation == IDOVERRIDESTATIC_OP_ADD ? 1.0f : -1.0f;
|
|
|
|
const int other_op = opop->operation == IDOVERRIDESTATIC_OP_ADD ? IDOVERRIDESTATIC_OP_SUBTRACT : IDOVERRIDESTATIC_OP_ADD;
|
2018-05-17 17:06:08 +02:00
|
|
|
float b = fac * (RNA_PROPERTY_GET_SINGLE(float, ptr_local, prop_local, index) - value);
|
2017-11-29 15:31:31 +01:00
|
|
|
if (b < prop_min || b > prop_max) {
|
|
|
|
opop->operation = other_op;
|
|
|
|
b = -b;
|
|
|
|
if (b < prop_min || b > prop_max) {
|
|
|
|
opop->operation = IDOVERRIDESTATIC_OP_REPLACE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
changed = true;
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_PROPERTY_SET_SINGLE(float, ptr_storage, prop_storage, index, b);
|
2017-11-29 15:31:31 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IDOVERRIDESTATIC_OP_MULTIPLY:
|
|
|
|
{
|
2018-05-17 17:06:08 +02:00
|
|
|
const float b = RNA_property_float_get_index(ptr_local, prop_local, index) / (value == 0.0f ? 1.0f : value);
|
2017-11-29 15:31:31 +01:00
|
|
|
if (b < prop_min || b > prop_max) {
|
|
|
|
opop->operation = IDOVERRIDESTATIC_OP_REPLACE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
changed = true;
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_property_float_set_index(ptr_storage, prop_storage, index, b);
|
2017-11-29 15:31:31 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
BLI_assert(0 && "Unsupported RNA override diff operation on float");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case PROP_ENUM:
|
|
|
|
/* TODO support add/sub, for bitflags? */
|
|
|
|
BLI_assert(0 && "Enum properties support no override diff operation");
|
|
|
|
break;
|
|
|
|
case PROP_POINTER:
|
|
|
|
BLI_assert(0 && "Pointer properties support no override diff operation");
|
|
|
|
break;
|
|
|
|
case PROP_STRING:
|
|
|
|
BLI_assert(0 && "String properties support no override diff operation");
|
|
|
|
break;
|
|
|
|
case PROP_COLLECTION:
|
|
|
|
/* XXX TODO support this of course... */
|
|
|
|
BLI_assert(0 && "Collection properties support no override diff operation");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rna_property_override_apply_default(
|
2018-06-29 12:46:54 +02:00
|
|
|
Main *UNUSED(bmain),
|
2017-11-29 15:31:31 +01:00
|
|
|
PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *ptr_storage,
|
|
|
|
PropertyRNA *prop_dst, PropertyRNA *prop_src, PropertyRNA *prop_storage,
|
|
|
|
const int len_dst, const int len_src, const int len_storage,
|
2018-06-28 14:23:00 +02:00
|
|
|
PointerRNA *UNUSED(ptr_item_dst), PointerRNA *UNUSED(ptr_item_src), PointerRNA *UNUSED(ptr_item_storage),
|
2017-11-29 15:31:31 +01:00
|
|
|
IDOverrideStaticPropertyOperation *opop)
|
|
|
|
{
|
|
|
|
BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage));
|
2017-12-01 17:41:54 +01:00
|
|
|
UNUSED_VARS_NDEBUG(len_src, len_storage);
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
const bool is_array = len_dst > 0;
|
|
|
|
const int index = is_array ? opop->subitem_reference_index : 0;
|
2017-11-29 15:31:31 +01:00
|
|
|
const short override_op = opop->operation;
|
|
|
|
|
|
|
|
switch (RNA_property_type(prop_dst)) {
|
|
|
|
case PROP_BOOLEAN:
|
2018-05-17 17:06:08 +02:00
|
|
|
if (is_array && index == -1) {
|
2018-07-01 16:22:06 +02:00
|
|
|
bool array_stack_a[RNA_STACK_ARRAY];
|
|
|
|
bool *array_a;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
array_a = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_dst, __func__) : array_stack_a;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_property_boolean_get_array(ptr_src, prop_src, array_a);
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
switch (override_op) {
|
|
|
|
case IDOVERRIDESTATIC_OP_REPLACE:
|
|
|
|
RNA_property_boolean_set_array(ptr_dst, prop_dst, array_a);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BLI_assert(0 && "Unsupported RNA override operation on boolean");
|
|
|
|
return false;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
if (array_a != array_stack_a) MEM_freeN(array_a);
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
else {
|
2018-07-01 16:22:06 +02:00
|
|
|
const bool value = RNA_PROPERTY_GET_SINGLE(boolean, ptr_src, prop_src, index);
|
2017-11-29 15:31:31 +01:00
|
|
|
|
|
|
|
switch (override_op) {
|
|
|
|
case IDOVERRIDESTATIC_OP_REPLACE:
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_PROPERTY_SET_SINGLE(boolean, ptr_dst, prop_dst, index, value);
|
2017-11-29 15:31:31 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BLI_assert(0 && "Unsupported RNA override operation on boolean");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
case PROP_INT:
|
2018-05-17 17:06:08 +02:00
|
|
|
if (is_array && index == -1) {
|
|
|
|
int array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
|
|
|
|
int *array_a, *array_b;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
array_a = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_dst, __func__) : array_stack_a;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
switch (override_op) {
|
|
|
|
case IDOVERRIDESTATIC_OP_REPLACE:
|
|
|
|
RNA_property_int_get_array(ptr_src, prop_src, array_a);
|
|
|
|
RNA_property_int_set_array(ptr_dst, prop_dst, array_a);
|
|
|
|
break;
|
|
|
|
case IDOVERRIDESTATIC_OP_ADD:
|
|
|
|
case IDOVERRIDESTATIC_OP_SUBTRACT:
|
|
|
|
RNA_property_int_get_array(ptr_dst, prop_dst, array_a);
|
|
|
|
array_b = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_dst, __func__) : array_stack_b;
|
|
|
|
RNA_property_int_get_array(ptr_storage, prop_storage, array_b);
|
|
|
|
if (override_op == IDOVERRIDESTATIC_OP_ADD) {
|
|
|
|
for (int i = len_dst; i--;) array_a[i] += array_b[i];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (int i = len_dst; i--;) array_a[i] -= array_b[i];
|
|
|
|
}
|
|
|
|
RNA_property_int_set_array(ptr_dst, prop_dst, array_a);
|
|
|
|
if (array_b != array_stack_b) MEM_freeN(array_b);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BLI_assert(0 && "Unsupported RNA override operation on integer");
|
|
|
|
return false;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
if (array_a != array_stack_a) MEM_freeN(array_a);
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
else {
|
2018-05-17 17:06:08 +02:00
|
|
|
const int storage_value = ptr_storage ? RNA_PROPERTY_GET_SINGLE(int, ptr_storage, prop_storage, index) : 0;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
|
|
|
switch (override_op) {
|
|
|
|
case IDOVERRIDESTATIC_OP_REPLACE:
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_PROPERTY_SET_SINGLE(int, ptr_dst, prop_dst, index,
|
|
|
|
RNA_PROPERTY_GET_SINGLE(int, ptr_src, prop_src, index));
|
2017-11-29 15:31:31 +01:00
|
|
|
break;
|
|
|
|
case IDOVERRIDESTATIC_OP_ADD:
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_PROPERTY_SET_SINGLE(int, ptr_dst, prop_dst, index,
|
|
|
|
RNA_PROPERTY_GET_SINGLE(int, ptr_dst, prop_dst, index) - storage_value);
|
2017-11-29 15:31:31 +01:00
|
|
|
break;
|
|
|
|
case IDOVERRIDESTATIC_OP_SUBTRACT:
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_PROPERTY_SET_SINGLE(int, ptr_dst, prop_dst, index,
|
|
|
|
RNA_PROPERTY_GET_SINGLE(int, ptr_dst, prop_dst, index) - storage_value);
|
2017-11-29 15:31:31 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BLI_assert(0 && "Unsupported RNA override operation on integer");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
case PROP_FLOAT:
|
2018-05-17 17:06:08 +02:00
|
|
|
if (is_array && index == -1) {
|
|
|
|
float array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
|
|
|
|
float *array_a, *array_b;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
array_a = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_dst, __func__) : array_stack_a;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
switch (override_op) {
|
|
|
|
case IDOVERRIDESTATIC_OP_REPLACE:
|
|
|
|
RNA_property_float_get_array(ptr_src, prop_src, array_a);
|
|
|
|
RNA_property_float_set_array(ptr_dst, prop_dst, array_a);
|
|
|
|
break;
|
|
|
|
case IDOVERRIDESTATIC_OP_ADD:
|
|
|
|
case IDOVERRIDESTATIC_OP_SUBTRACT:
|
|
|
|
case IDOVERRIDESTATIC_OP_MULTIPLY:
|
|
|
|
RNA_property_float_get_array(ptr_dst, prop_dst, array_a);
|
|
|
|
array_b = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_dst, __func__) : array_stack_b;
|
|
|
|
RNA_property_float_get_array(ptr_storage, prop_storage, array_b);
|
|
|
|
if (override_op == IDOVERRIDESTATIC_OP_ADD) {
|
|
|
|
for (int i = len_dst; i--;) array_a[i] += array_b[i];
|
|
|
|
}
|
|
|
|
else if (override_op == IDOVERRIDESTATIC_OP_SUBTRACT) {
|
|
|
|
for (int i = len_dst; i--;) array_a[i] -= array_b[i];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (int i = len_dst; i--;) array_a[i] *= array_b[i];
|
|
|
|
}
|
|
|
|
RNA_property_float_set_array(ptr_dst, prop_dst, array_a);
|
|
|
|
if (array_b != array_stack_b) MEM_freeN(array_b);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BLI_assert(0 && "Unsupported RNA override operation on float");
|
|
|
|
return false;
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
if (array_a != array_stack_a) MEM_freeN(array_a);
|
2017-11-29 15:31:31 +01:00
|
|
|
}
|
|
|
|
else {
|
2018-05-17 17:06:08 +02:00
|
|
|
const float storage_value = ptr_storage ? RNA_PROPERTY_GET_SINGLE(float, ptr_storage, prop_storage, index) : 0.0f;
|
2017-11-29 15:31:31 +01:00
|
|
|
|
|
|
|
switch (override_op) {
|
|
|
|
case IDOVERRIDESTATIC_OP_REPLACE:
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_PROPERTY_SET_SINGLE(float, ptr_dst, prop_dst, index,
|
|
|
|
RNA_PROPERTY_GET_SINGLE(float, ptr_src, prop_src, index));
|
2017-11-29 15:31:31 +01:00
|
|
|
break;
|
|
|
|
case IDOVERRIDESTATIC_OP_ADD:
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_PROPERTY_SET_SINGLE(float, ptr_dst, prop_dst, index,
|
|
|
|
RNA_PROPERTY_GET_SINGLE(float, ptr_dst, prop_dst, index) + storage_value);
|
2017-11-29 15:31:31 +01:00
|
|
|
break;
|
|
|
|
case IDOVERRIDESTATIC_OP_SUBTRACT:
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_PROPERTY_SET_SINGLE(float, ptr_dst, prop_dst, index,
|
|
|
|
RNA_PROPERTY_GET_SINGLE(float, ptr_dst, prop_dst, index) - storage_value);
|
2017-11-29 15:31:31 +01:00
|
|
|
break;
|
|
|
|
case IDOVERRIDESTATIC_OP_MULTIPLY:
|
2018-05-17 17:06:08 +02:00
|
|
|
RNA_PROPERTY_SET_SINGLE(float, ptr_dst, prop_dst, index,
|
|
|
|
RNA_PROPERTY_GET_SINGLE(float, ptr_dst, prop_dst, index) * storage_value);
|
2017-11-29 15:31:31 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BLI_assert(0 && "Unsupported RNA override operation on float");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
case PROP_ENUM:
|
|
|
|
{
|
|
|
|
const int value = RNA_property_enum_get(ptr_src, prop_src);
|
|
|
|
|
|
|
|
switch (override_op) {
|
|
|
|
case IDOVERRIDESTATIC_OP_REPLACE:
|
|
|
|
RNA_property_enum_set(ptr_dst, prop_dst, value);
|
|
|
|
break;
|
|
|
|
/* TODO support add/sub, for bitflags? */
|
|
|
|
default:
|
|
|
|
BLI_assert(0 && "Unsupported RNA override operation on enum");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case PROP_POINTER:
|
|
|
|
{
|
|
|
|
PointerRNA value = RNA_property_pointer_get(ptr_src, prop_src);
|
|
|
|
|
|
|
|
switch (override_op) {
|
|
|
|
case IDOVERRIDESTATIC_OP_REPLACE:
|
|
|
|
RNA_property_pointer_set(ptr_dst, prop_dst, value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BLI_assert(0 && "Unsupported RNA override operation on pointer");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case PROP_STRING:
|
|
|
|
{
|
|
|
|
char buff[256];
|
|
|
|
char *value = RNA_property_string_get_alloc(ptr_src, prop_src, buff, sizeof(buff), NULL);
|
|
|
|
|
|
|
|
switch (override_op) {
|
|
|
|
case IDOVERRIDESTATIC_OP_REPLACE:
|
|
|
|
RNA_property_string_set(ptr_dst, prop_dst, value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BLI_assert(0 && "Unsupported RNA override operation on string");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value != buff) MEM_freeN(value);
|
|
|
|
return true;
|
|
|
|
}
|
2018-05-01 16:27:47 +02:00
|
|
|
case PROP_COLLECTION:
|
|
|
|
{
|
|
|
|
BLI_assert(!"You need to define a specific override apply callback for enums.");
|
|
|
|
return false;
|
|
|
|
}
|
2017-11-29 15:31:31 +01:00
|
|
|
default:
|
2018-05-01 16:27:47 +02:00
|
|
|
BLI_assert(0);
|
2017-11-29 15:31:31 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-05-17 17:06:08 +02:00
|
|
|
#undef RNA_PROPERTY_GET_SINGLE
|
|
|
|
#undef RNA_PROPERTY_SET_SINGLE
|
2017-11-29 15:31:31 +01:00
|
|
|
|
2010-01-22 14:06:42 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
#else
|
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
static void rna_def_struct(BlenderRNA *brna)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
StructRNA *srna;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "Struct", NULL);
|
2009-01-10 22:57:33 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Struct Definition", "RNA structure definition");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_RNA);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_Struct_name_get", "rna_Struct_name_length", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Name", "Human readable name");
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_Struct_identifier_get", "rna_Struct_identifier_length", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting");
|
2008-12-18 05:28:17 +00:00
|
|
|
RNA_def_struct_name_property(srna, prop);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-12-19 04:06:24 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_Struct_description_get", "rna_Struct_description_length", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Description", "Description of the Struct's purpose");
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-16 15:39:25 +00:00
|
|
|
prop = RNA_def_property(srna, "translation_context", PROP_STRING, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_Struct_translation_context_get",
|
|
|
|
"rna_Struct_translation_context_length", NULL);
|
2012-03-16 15:39:25 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Translation Context", "Translation context of the struct's name");
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "base", PROP_POINTER, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-12-15 13:46:50 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Struct");
|
2010-08-03 05:14:59 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_Struct_base_get", NULL, NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Base", "Struct definition this is derived from");
|
2008-12-15 13:46:50 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "nested", PROP_POINTER, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2009-01-09 16:08:47 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Struct");
|
2010-08-03 05:14:59 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_Struct_nested_get", NULL, NULL, NULL);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Nested",
|
|
|
|
"Struct in which this struct is always nested, and to which it logically belongs");
|
2009-01-09 16:08:47 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "name_property", PROP_POINTER, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
RNA_def_property_struct_type(prop, "StringProperty");
|
2010-08-03 05:14:59 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_Struct_name_property_get", NULL, NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Name Property", "Property that gives the name of the struct");
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Property");
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_collection_funcs(prop, "rna_Struct_properties_begin", "rna_Struct_properties_next",
|
|
|
|
"rna_iterator_listbase_end", "rna_Struct_properties_get",
|
|
|
|
NULL, NULL, NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Properties", "Properties in the struct");
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "functions", PROP_COLLECTION, PROP_NONE);
|
2009-04-07 00:49:39 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_struct_type(prop, "Function");
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_collection_funcs(prop, "rna_Struct_functions_begin", "rna_Struct_functions_next",
|
|
|
|
"rna_iterator_listbase_end", "rna_Struct_functions_get",
|
|
|
|
NULL, NULL, NULL, NULL);
|
2009-04-07 00:49:39 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Functions", "");
|
2017-11-23 13:41:07 +01:00
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "property_tags", PROP_COLLECTION, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_struct_type(prop, "EnumPropertyItem");
|
|
|
|
RNA_def_property_collection_funcs(prop, "rna_Struct_property_tags_begin", "rna_iterator_array_next",
|
|
|
|
"rna_iterator_array_end", "rna_iterator_array_get",
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Property Tags", "Tags that properties can use to influence behavior");
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_def_property(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
2008-11-14 14:34:19 +00:00
|
|
|
PropertyRNA *prop;
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem subtype_items[] = {
|
2009-06-16 00:52:21 +00:00
|
|
|
{PROP_NONE, "NONE", 0, "None", ""},
|
|
|
|
{PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""},
|
2014-02-26 18:50:27 +01:00
|
|
|
{PROP_DIRPATH, "DIR_PATH", 0, "Directory Path", ""},
|
2013-12-13 04:39:15 +11:00
|
|
|
{PROP_PIXEL, "PIXEL", 0, "Pixel", ""},
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
{PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned Number", ""},
|
|
|
|
{PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""},
|
2009-09-21 21:19:58 +00:00
|
|
|
{PROP_FACTOR, "FACTOR", 0, "Factor", ""},
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
{PROP_ANGLE, "ANGLE", 0, "Angle", ""},
|
|
|
|
{PROP_TIME, "TIME", 0, "Time", ""},
|
|
|
|
{PROP_DISTANCE, "DISTANCE", 0, "Distance", ""},
|
2009-06-16 00:52:21 +00:00
|
|
|
{PROP_COLOR, "COLOR", 0, "Color", ""},
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
{PROP_TRANSLATION, "TRANSLATION", 0, "Translation", ""},
|
|
|
|
{PROP_DIRECTION, "DIRECTION", 0, "Direction", ""},
|
2009-06-16 00:52:21 +00:00
|
|
|
{PROP_MATRIX, "MATRIX", 0, "Matrix", ""},
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
{PROP_EULER, "EULER", 0, "Euler", ""},
|
|
|
|
{PROP_QUATERNION, "QUATERNION", 0, "Quaternion", ""},
|
|
|
|
{PROP_XYZ, "XYZ", 0, "XYZ", ""},
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
{PROP_COLOR_GAMMA, "COLOR_GAMMA", 0, "Gamma Corrected Color", ""},
|
2011-04-08 13:32:56 +00:00
|
|
|
{PROP_COORDS, "COORDINATES", 0, "Vector Coordinates", ""},
|
2009-09-09 17:39:19 +00:00
|
|
|
{PROP_LAYER, "LAYER", 0, "Layer", ""},
|
|
|
|
{PROP_LAYER_MEMBER, "LAYER_MEMBERSHIP", 0, "Layer Membership", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2017-11-23 13:41:07 +01:00
|
|
|
EnumPropertyItem dummy_prop_tags[] = {
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2017-11-23 13:41:07 +01:00
|
|
|
};
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "Property", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Property Definition", "RNA property definition");
|
2009-01-01 15:52:51 +00:00
|
|
|
RNA_def_struct_refine_func(srna, "rna_Property_refine");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_RNA);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_Property_name_get", "rna_Property_name_length", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Name", "Human readable name");
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_Property_identifier_get", "rna_Property_identifier_length", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting");
|
2008-12-18 07:22:28 +00:00
|
|
|
RNA_def_struct_name_property(srna, prop);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_Property_description_get", "rna_Property_description_length", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Description", "Description of the property for tooltips");
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "translation_context", PROP_STRING, PROP_NONE);
|
2011-12-22 18:25:59 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_Property_translation_context_get",
|
|
|
|
"rna_Property_translation_context_length", NULL);
|
2012-03-16 15:39:25 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Translation Context", "Translation context of the property's name");
|
2011-12-22 18:25:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_property_type_items);
|
2009-05-28 23:23:47 +00:00
|
|
|
RNA_def_property_enum_funcs(prop, "rna_Property_type_get", NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Type", "Data type of the property");
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "subtype", PROP_ENUM, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 14:34:19 +00:00
|
|
|
RNA_def_property_enum_items(prop, subtype_items);
|
2009-05-28 23:23:47 +00:00
|
|
|
RNA_def_property_enum_funcs(prop, "rna_Property_subtype_get", NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Subtype", "Semantic interpretation of the property");
|
2009-01-10 22:57:33 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "srna", PROP_POINTER, PROP_NONE);
|
2009-11-13 17:42:44 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_struct_type(prop, "Struct");
|
2010-08-03 05:14:59 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_Property_srna_get", NULL, NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Base", "Struct definition used for properties assigned to this item");
|
2009-11-13 17:42:44 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "unit", PROP_ENUM, PROP_NONE);
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_property_unit_items);
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
RNA_def_property_enum_funcs(prop, "rna_Property_unit_get", NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Unit", "Type of units for this property");
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
|
2013-01-17 00:29:39 +00:00
|
|
|
prop = RNA_def_property(srna, "icon", PROP_ENUM, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_icon_items);
|
2013-01-17 00:29:39 +00:00
|
|
|
RNA_def_property_enum_funcs(prop, "rna_Property_icon_get", NULL, NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Icon", "Icon of the item");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_readonly", PROP_BOOLEAN, PROP_NONE);
|
2009-12-25 14:42:00 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_readonly_get", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Read Only", "Property is editable through RNA");
|
2009-12-25 14:42:00 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_animatable", PROP_BOOLEAN, PROP_NONE);
|
2011-10-08 12:27:52 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_animatable_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Animatable", "Property is animatable through RNA");
|
|
|
|
|
2017-11-29 15:31:31 +01:00
|
|
|
prop = RNA_def_property(srna, "is_overridable", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_overridable_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Overridable", "Property is overridable through RNA");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_required", PROP_BOOLEAN, PROP_NONE);
|
2009-12-25 14:42:00 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_is_required_get", NULL);
|
2010-05-04 05:15:53 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Required", "False when this property is an optional argument in an RNA function");
|
2009-12-25 14:42:00 +00:00
|
|
|
|
2013-08-26 21:39:06 +00:00
|
|
|
prop = RNA_def_property(srna, "is_argument_optional", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_is_argument_optional_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Optional Argument",
|
|
|
|
"True when the property is optional in a Python function implementing an RNA function");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_never_none", PROP_BOOLEAN, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2009-12-25 14:42:00 +00:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_is_never_none_get", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Never None", "True when this value can't be set to None");
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_hidden", PROP_BOOLEAN, PROP_NONE);
|
2010-12-24 07:30:15 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_is_hidden_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Hidden", "True when the property is hidden");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_skip_save", PROP_BOOLEAN, PROP_NONE);
|
2011-06-07 10:54:57 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_is_skip_save_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Skip Save", "True when the property is not saved in presets");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_output", PROP_BOOLEAN, PROP_NONE);
|
2009-08-16 15:46:09 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2010-01-24 11:02:43 +00:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_use_output_get", NULL);
|
2010-05-04 05:15:53 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Return", "True when this property is an output value from an RNA function");
|
2009-08-16 15:46:09 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_registered", PROP_BOOLEAN, PROP_NONE);
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2015-02-20 19:54:28 +11:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_is_registered_get", NULL);
|
2010-05-04 05:15:53 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Registered", "Property is registered as part of type registration");
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_registered_optional", PROP_BOOLEAN, PROP_NONE);
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2015-02-20 19:54:28 +11:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_is_registered_optional_get", NULL);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Registered Optionally",
|
|
|
|
"Property is optionally registered as part of type registration");
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_runtime", PROP_BOOLEAN, PROP_NONE);
|
2010-09-02 14:43:22 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2015-02-20 19:54:28 +11:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_is_runtime_get", NULL);
|
2011-06-25 17:36:33 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Runtime", "Property has been dynamically created at runtime");
|
2011-02-16 10:19:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_enum_flag", PROP_BOOLEAN, PROP_NONE);
|
2011-02-16 10:19:14 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_is_enum_flag_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Enum Flag", "True when multiple enums ");
|
2012-05-19 21:22:01 +00:00
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "is_library_editable", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_is_library_editable_flag_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Library Editable", "Property is editable from linked instances (changes not saved)");
|
2017-11-23 13:41:07 +01:00
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "tags", PROP_ENUM, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_enum_items(prop, dummy_prop_tags);
|
|
|
|
RNA_def_property_enum_funcs(prop, "rna_Property_tags_get", NULL, "rna_Property_tags_itemf");
|
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
|
|
|
|
RNA_def_property_ui_text(prop, "Tags", "Subset of tags (defined in parent struct) that are set for this property");
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
static void rna_def_function(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "Function", NULL);
|
2009-04-07 00:49:39 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Function Definition", "RNA function definition");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_RNA);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
|
2009-04-07 00:49:39 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_string_funcs(prop, "rna_Function_identifier_get", "rna_Function_identifier_length", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting");
|
2009-04-07 00:49:39 +00:00
|
|
|
RNA_def_struct_name_property(srna, prop);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
|
2009-04-07 00:49:39 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_string_funcs(prop, "rna_Function_description_get", "rna_Function_description_length", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Description", "Description of the Function's purpose");
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "parameters", PROP_COLLECTION, PROP_NONE);
|
2009-04-07 00:49:39 +00:00
|
|
|
/*RNA_def_property_clear_flag(prop, PROP_EDITABLE);*/
|
|
|
|
RNA_def_property_struct_type(prop, "Property");
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_collection_funcs(prop, "rna_Function_parameters_begin", "rna_iterator_listbase_next",
|
|
|
|
"rna_iterator_listbase_end", "rna_iterator_listbase_get",
|
|
|
|
NULL, NULL, NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Parameters", "Parameters for the function");
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_registered", PROP_BOOLEAN, PROP_NONE);
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Function_registered_get", NULL);
|
2010-05-04 05:15:53 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Registered", "Function is registered as callback as part of type registration");
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_registered_optional", PROP_BOOLEAN, PROP_NONE);
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Function_registered_optional_get", NULL);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Registered Optionally",
|
|
|
|
"Function is optionally registered as callback part of type registration");
|
2010-08-17 14:32:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_self", PROP_BOOLEAN, PROP_NONE);
|
2010-08-17 14:32:14 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Function_no_self_get", NULL);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_ui_text(prop, "No Self",
|
2012-12-20 09:33:12 +00:00
|
|
|
"Function does not pass its self as an argument (becomes a static method in python)");
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-12-20 09:33:12 +00:00
|
|
|
prop = RNA_def_property(srna, "use_self_type", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Function_use_self_type_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Use Self Type",
|
|
|
|
"Function passes its self type as an argument (becomes a class method in python if use_self is false)");
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_def_number_property(StructRNA *srna, PropertyType type)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "default", type, PROP_NONE);
|
2009-07-26 18:18:14 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_ui_text(prop, "Default", "Default value for this number");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (type) {
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
case PROP_BOOLEAN:
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_BoolProperty_default_get", NULL);
|
|
|
|
break;
|
|
|
|
case PROP_INT:
|
|
|
|
RNA_def_property_int_funcs(prop, "rna_IntProperty_default_get", NULL, NULL);
|
|
|
|
break;
|
|
|
|
case PROP_FLOAT:
|
|
|
|
RNA_def_property_float_funcs(prop, "rna_FloatProperty_default_get", NULL, NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2009-07-26 18:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "default_array", type, PROP_NONE);
|
2009-07-26 18:18:14 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2009-09-15 10:01:20 +00:00
|
|
|
RNA_def_property_array(prop, RNA_MAX_ARRAY_DIMENSION); /* no fixed default length, important its not 0 though */
|
|
|
|
RNA_def_property_flag(prop, PROP_DYNAMIC);
|
|
|
|
RNA_def_property_dynamic_array_funcs(prop, "rna_NumberProperty_default_array_get_length"); /* same for all types */
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (type) {
|
2009-09-15 10:01:20 +00:00
|
|
|
case PROP_BOOLEAN:
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_BoolProperty_default_array_get", NULL);
|
|
|
|
break;
|
|
|
|
case PROP_INT:
|
|
|
|
RNA_def_property_int_funcs(prop, "rna_IntProperty_default_array_get", NULL, NULL);
|
|
|
|
break;
|
|
|
|
case PROP_FLOAT:
|
|
|
|
RNA_def_property_float_funcs(prop, "rna_FloatProperty_default_array_get", NULL, NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
RNA_def_property_ui_text(prop, "Default Array", "Default value for this array");
|
|
|
|
|
2009-07-26 18:18:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "array_length", PROP_INT, PROP_UNSIGNED);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-24 12:12:24 +00:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_Property_array_length_get", NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Array Length", "Maximum length of the array, 0 means unlimited");
|
2008-11-14 18:46:57 +00:00
|
|
|
|
2017-09-20 16:37:01 +02:00
|
|
|
prop = RNA_def_property(srna, "array_dimensions", PROP_INT, PROP_UNSIGNED);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_array(prop, RNA_MAX_ARRAY_DIMENSION);
|
|
|
|
RNA_def_property_int_funcs(prop, "rna_Property_array_dimensions_get", NULL, NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Array Dimensions", "Length of each dimension of the array");
|
|
|
|
|
2016-02-29 11:02:08 +11:00
|
|
|
prop = RNA_def_property(srna, "is_array", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_NumberProperty_is_array_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Is Array", "");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type == PROP_BOOLEAN)
|
2008-11-14 18:46:57 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "hard_min", type, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_hard_min_get", NULL, NULL);
|
2008-11-24 12:12:24 +00:00
|
|
|
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_hard_min_get", NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Hard Minimum", "Minimum value used by buttons");
|
2008-11-14 18:46:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "hard_max", type, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_hard_max_get", NULL, NULL);
|
2008-11-24 12:12:24 +00:00
|
|
|
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_hard_max_get", NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Hard Maximum", "Maximum value used by buttons");
|
2008-11-14 18:46:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "soft_min", type, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_soft_min_get", NULL, NULL);
|
2008-11-24 12:12:24 +00:00
|
|
|
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_soft_min_get", NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Soft Minimum", "Minimum value used by buttons");
|
2008-11-14 18:46:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "soft_max", type, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_soft_max_get", NULL, NULL);
|
2008-11-24 12:12:24 +00:00
|
|
|
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_soft_max_get", NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Soft Maximum", "Maximum value used by buttons");
|
2008-11-14 18:46:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "step", type, PROP_UNSIGNED);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_step_get", NULL, NULL);
|
2008-11-24 12:12:24 +00:00
|
|
|
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_step_get", NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Step", "Step size used by number buttons, for floats 1/100th of the step size");
|
2008-11-14 18:46:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type == PROP_FLOAT) {
|
|
|
|
prop = RNA_def_property(srna, "precision", PROP_INT, PROP_UNSIGNED);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-24 12:12:24 +00:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_FloatProperty_precision_get", NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Precision", "Number of digits after the dot used by buttons");
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
static void rna_def_string_property(StructRNA *srna)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "default", PROP_STRING, PROP_NONE);
|
2009-07-26 18:18:14 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_string_funcs(prop, "rna_StringProperty_default_get", "rna_StringProperty_default_length", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Default", "string default value");
|
2009-07-26 18:18:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "length_max", PROP_INT, PROP_UNSIGNED);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-24 12:12:24 +00:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_StringProperty_max_length_get", NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Maximum Length", "Maximum length of the string, 0 means unlimited");
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-07-26 18:18:14 +00:00
|
|
|
/* the itemf func is used instead, keep blender happy */
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem default_dummy_items[] = {
|
2009-07-26 18:18:14 +00:00
|
|
|
{PROP_NONE, "DUMMY", 0, "Dummy", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2009-07-26 18:18:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "default", PROP_ENUM, PROP_NONE);
|
2009-07-26 18:18:14 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_enum_items(prop, default_dummy_items);
|
|
|
|
RNA_def_property_enum_funcs(prop, "rna_EnumProperty_default_get", NULL, "rna_EnumProperty_default_itemf");
|
|
|
|
RNA_def_property_ui_text(prop, "Default", "Default value for this enum");
|
2011-02-16 10:19:14 +00:00
|
|
|
|
|
|
|
/* same 'default' but uses 'PROP_ENUM_FLAG' */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "default_flag", PROP_ENUM, PROP_NONE);
|
2011-02-16 10:19:14 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
|
|
|
|
RNA_def_property_enum_items(prop, default_dummy_items);
|
|
|
|
RNA_def_property_enum_funcs(prop, "rna_EnumProperty_default_get", NULL, "rna_EnumProperty_default_itemf");
|
|
|
|
RNA_def_property_ui_text(prop, "Default", "Default value for this enum");
|
2009-07-26 18:18:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "enum_items", PROP_COLLECTION, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_struct_type(prop, "EnumPropertyItem");
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_collection_funcs(prop, "rna_EnumProperty_items_begin", "rna_iterator_array_next",
|
|
|
|
"rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Items", "Possible values for the property");
|
2008-11-14 18:46:57 +00:00
|
|
|
|
2016-02-09 12:44:06 +01:00
|
|
|
prop = RNA_def_property(srna, "enum_items_static", PROP_COLLECTION, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_struct_type(prop, "EnumPropertyItem");
|
|
|
|
RNA_def_property_collection_funcs(prop, "rna_EnumProperty_items_begin", "rna_iterator_array_next",
|
|
|
|
"rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Static Items",
|
|
|
|
"Possible values for the property (never calls optional dynamic generation of those)");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "EnumPropertyItem", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Enum Item Definition", "Definition of a choice in an RNA enum property");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_RNA);
|
2008-11-14 18:46:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_EnumPropertyItem_name_get", "rna_EnumPropertyItem_name_length", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Name", "Human readable name");
|
2008-11-14 18:46:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
|
2009-07-08 15:34:41 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_EnumPropertyItem_description_get",
|
|
|
|
"rna_EnumPropertyItem_description_length", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Description", "Description of the item's purpose");
|
2009-07-08 15:34:41 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_EnumPropertyItem_identifier_get",
|
|
|
|
"rna_EnumPropertyItem_identifier_length", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting");
|
2008-12-18 23:34:19 +00:00
|
|
|
RNA_def_struct_name_property(srna, prop);
|
2008-11-14 18:46:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "value", PROP_INT, PROP_UNSIGNED);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-24 12:12:24 +00:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_EnumPropertyItem_value_get", NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Value", "Value of the item");
|
2013-01-13 16:18:35 +00:00
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "icon", PROP_ENUM, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_icon_items);
|
2013-01-13 16:18:35 +00:00
|
|
|
RNA_def_property_enum_funcs(prop, "rna_EnumPropertyItem_icon_get", NULL, NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Icon", "Icon of the item");
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_def_pointer_property(StructRNA *srna, PropertyType type)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "fixed_type", PROP_POINTER, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Struct");
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type == PROP_POINTER)
|
2010-08-03 05:14:59 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_PointerProperty_fixed_type_get", NULL, NULL, NULL);
|
2008-11-14 18:46:57 +00:00
|
|
|
else
|
2010-08-03 05:14:59 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_CollectionProperty_fixed_type_get", NULL, NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Pointer Type", "Fixed pointer type, empty if variable type");
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
void RNA_def_rna(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
2008-12-15 13:46:50 +00:00
|
|
|
PropertyRNA *prop;
|
2008-11-14 14:34:19 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
/* Struct*/
|
|
|
|
rna_def_struct(brna);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
/* Property */
|
|
|
|
rna_def_property(brna);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2011-12-01 22:08:42 +00:00
|
|
|
/* BoolProperty */
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "BoolProperty", "Property");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Boolean Definition", "RNA boolean property definition");
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_def_number_property(srna, PROP_BOOLEAN);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
/* IntProperty */
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "IntProperty", "Property");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Int Definition", "RNA integer number property definition");
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_def_number_property(srna, PROP_INT);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
/* FloatProperty */
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "FloatProperty", "Property");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Float Definition", "RNA floating pointer number property definition");
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_def_number_property(srna, PROP_FLOAT);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
/* StringProperty */
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "StringProperty", "Property");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "String Definition", "RNA text string property definition");
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_def_string_property(srna);
|
2008-11-14 17:05:25 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
/* EnumProperty */
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "EnumProperty", "Property");
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Enum Definition",
|
|
|
|
"RNA enumeration property definition, to choose from a number of predefined options");
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_def_enum_property(brna, srna);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
/* PointerProperty */
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "PointerProperty", "Property");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Pointer Definition", "RNA pointer property to point to another RNA struct");
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_def_pointer_property(srna, PROP_POINTER);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
/* CollectionProperty */
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "CollectionProperty", "Property");
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Collection Definition",
|
|
|
|
"RNA collection property to define lists, arrays and mappings");
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_def_pointer_property(srna, PROP_COLLECTION);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
/* Function */
|
|
|
|
rna_def_function(brna);
|
2008-12-15 13:46:50 +00:00
|
|
|
|
|
|
|
/* Blender RNA */
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "BlenderRNA", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Blender RNA", "Blender RNA structure definitions");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_RNA);
|
2008-12-15 13:46:50 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "structs", PROP_COLLECTION, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-12-15 13:46:50 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Struct");
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_collection_funcs(prop, "rna_BlenderRNA_structs_begin", "rna_iterator_listbase_next",
|
|
|
|
"rna_iterator_listbase_end", "rna_iterator_listbase_get",
|
2012-05-12 11:01:29 +00:00
|
|
|
/* included for speed, can be removed */
|
2010-01-22 14:06:42 +00:00
|
|
|
#if 0
|
2012-03-18 09:27:36 +00:00
|
|
|
NULL, NULL, NULL, NULL);
|
2010-01-22 14:06:42 +00:00
|
|
|
#else
|
2012-03-18 09:27:36 +00:00
|
|
|
"rna_BlenderRNA_structs_length", "rna_BlenderRNA_structs_lookup_int",
|
|
|
|
"rna_BlenderRNA_structs_lookup_string", NULL);
|
2010-01-22 14:06:42 +00:00
|
|
|
#endif
|
|
|
|
|
2008-12-15 13:46:50 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Structs", "");
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|