2011-02-23 11:52:22 +01:00
|
|
|
/*
|
2008-11-01 00:50:02 +01:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* 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 14:34:04 +01:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-11-01 00:50:02 +01:00
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation (2008).
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 21:20:01 +01:00
|
|
|
/** \file blender/makesrna/RNA_types.h
|
|
|
|
* \ingroup RNA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-05-28 21:35:26 +02:00
|
|
|
#include "../blenlib/BLI_sys_types.h"
|
2010-08-31 13:31:21 +02:00
|
|
|
|
2012-02-17 19:59:41 +01:00
|
|
|
#ifndef __RNA_TYPES_H__
|
|
|
|
#define __RNA_TYPES_H__
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2009-03-15 00:17:55 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2009-04-07 02:49:39 +02:00
|
|
|
struct ParameterList;
|
|
|
|
struct FunctionRNA;
|
2008-11-24 16:51:55 +01:00
|
|
|
struct PropertyRNA;
|
2011-05-26 15:38:16 +02:00
|
|
|
struct EnumPropertyRNA;
|
2008-11-24 16:51:55 +01:00
|
|
|
struct StructRNA;
|
|
|
|
struct BlenderRNA;
|
2009-03-19 20:03:38 +01:00
|
|
|
struct IDProperty;
|
2009-04-19 15:37:59 +02:00
|
|
|
struct bContext;
|
2011-05-18 12:56:26 +02:00
|
|
|
struct Main;
|
2009-04-19 15:37:59 +02:00
|
|
|
struct ReportList;
|
2008-11-24 16:51:55 +01:00
|
|
|
|
2011-02-27 21:20:01 +01:00
|
|
|
/** Pointer
|
2008-11-07 03:58:25 +01:00
|
|
|
*
|
|
|
|
* RNA pointers are not a single C pointer but include the type,
|
|
|
|
* and a pointer to the ID struct that owns the struct, since
|
|
|
|
* in some cases this information is needed to correctly get/set
|
|
|
|
* the properties and validate them. */
|
|
|
|
|
|
|
|
typedef struct PointerRNA {
|
|
|
|
struct {
|
|
|
|
void *data;
|
|
|
|
} id;
|
|
|
|
|
|
|
|
struct StructRNA *type;
|
|
|
|
void *data;
|
|
|
|
} PointerRNA;
|
|
|
|
|
2009-10-02 01:32:57 +02:00
|
|
|
typedef struct PropertyPointerRNA {
|
|
|
|
PointerRNA ptr;
|
|
|
|
struct PropertyRNA *prop;
|
|
|
|
} PropertyPointerRNA;
|
|
|
|
|
2008-11-07 03:58:25 +01:00
|
|
|
/* Property */
|
2008-11-01 00:50:02 +01:00
|
|
|
|
|
|
|
typedef enum PropertyType {
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_BOOLEAN = 0,
|
|
|
|
PROP_INT = 1,
|
|
|
|
PROP_FLOAT = 2,
|
|
|
|
PROP_STRING = 3,
|
|
|
|
PROP_ENUM = 4,
|
|
|
|
PROP_POINTER = 5,
|
|
|
|
PROP_COLLECTION = 6,
|
2008-11-01 00:50:02 +01:00
|
|
|
} PropertyType;
|
|
|
|
|
2009-08-11 13:50:40 +02:00
|
|
|
/* also update rna_property_subtype_unit when you change this */
|
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 23:31:05 +02:00
|
|
|
typedef enum PropertyUnit {
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_UNIT_NONE = (0 << 16),
|
|
|
|
PROP_UNIT_LENGTH = (1 << 16), /* m */
|
|
|
|
PROP_UNIT_AREA = (2 << 16), /* m^2 */
|
|
|
|
PROP_UNIT_VOLUME = (3 << 16), /* m^3 */
|
|
|
|
PROP_UNIT_MASS = (4 << 16), /* kg */
|
|
|
|
PROP_UNIT_ROTATION = (5 << 16), /* radians */
|
|
|
|
PROP_UNIT_TIME = (6 << 16), /* frame */
|
|
|
|
PROP_UNIT_VELOCITY = (7 << 16), /* m/s */
|
2013-03-13 18:16:49 +01:00
|
|
|
PROP_UNIT_ACCELERATION = (8 << 16), /* m/(s^2) */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_UNIT_CAMERA = (9 << 16), /* mm */
|
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 23:31:05 +02:00
|
|
|
} PropertyUnit;
|
|
|
|
|
2012-04-10 11:03:45 +02:00
|
|
|
#define RNA_SUBTYPE_UNIT(subtype) ((subtype) & 0x00FF0000)
|
|
|
|
#define RNA_SUBTYPE_VALUE(subtype) ((subtype) & ~0x00FF0000)
|
|
|
|
#define RNA_SUBTYPE_UNIT_VALUE(subtype) ((subtype) >> 16)
|
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 23:31:05 +02:00
|
|
|
|
2009-12-07 01:16:57 +01:00
|
|
|
#define RNA_ENUM_BITFLAG_SIZE 32
|
|
|
|
|
2012-04-10 10:33:30 +02:00
|
|
|
#define RNA_TRANSLATION_PREC_DEFAULT 5
|
|
|
|
|
2011-09-05 23:01:50 +02:00
|
|
|
/* also update enums in bpy_props.c when adding items here
|
|
|
|
* watch it: these values are written to files as part of
|
|
|
|
* node socket button subtypes!
|
|
|
|
*/
|
2008-11-01 00:50:02 +01:00
|
|
|
typedef enum PropertySubType {
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_NONE = 0,
|
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 23:31:05 +02:00
|
|
|
|
|
|
|
/* strings */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_FILEPATH = 1,
|
|
|
|
PROP_DIRPATH = 2,
|
|
|
|
PROP_FILENAME = 3,
|
|
|
|
PROP_BYTESTRING = 4, /* a string which should be represented as bytes in python, NULL terminated though. */
|
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 18:29:07 +01:00
|
|
|
/* 5 was used by "PROP_TRANSLATE" sub-type, which is now a flag. */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_PASSWORD = 6, /* a string which should not be displayed in UI */
|
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 23:31:05 +02:00
|
|
|
|
|
|
|
/* numbers */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_UNSIGNED = 13,
|
|
|
|
PROP_PERCENTAGE = 14,
|
|
|
|
PROP_FACTOR = 15,
|
|
|
|
PROP_ANGLE = 16 | PROP_UNIT_ROTATION,
|
|
|
|
PROP_TIME = 17 | PROP_UNIT_TIME,
|
2013-02-12 06:09:35 +01:00
|
|
|
/* distance in 3d space, don't use for pixel distance for eg. */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_DISTANCE = 18 | PROP_UNIT_LENGTH,
|
|
|
|
PROP_DISTANCE_CAMERA = 19 | PROP_UNIT_CAMERA,
|
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 23:31:05 +02:00
|
|
|
|
|
|
|
/* number arrays */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_COLOR = 20,
|
|
|
|
PROP_TRANSLATION = 21 | PROP_UNIT_LENGTH,
|
|
|
|
PROP_DIRECTION = 22,
|
|
|
|
PROP_VELOCITY = 23 | PROP_UNIT_VELOCITY,
|
|
|
|
PROP_ACCELERATION = 24 | PROP_UNIT_ACCELERATION,
|
|
|
|
PROP_MATRIX = 25,
|
|
|
|
PROP_EULER = 26 | PROP_UNIT_ROTATION,
|
|
|
|
PROP_QUATERNION = 27,
|
|
|
|
PROP_AXISANGLE = 28,
|
|
|
|
PROP_XYZ = 29,
|
|
|
|
PROP_XYZ_LENGTH = 29 | PROP_UNIT_LENGTH,
|
|
|
|
PROP_COLOR_GAMMA = 30, /* used for colors which would be color managed before display */
|
|
|
|
PROP_COORDS = 31, /* generic array, no units applied, only that x/y/z/w are used (python vec) */
|
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 23:31:05 +02:00
|
|
|
|
2009-09-09 19:39:19 +02:00
|
|
|
/* booleans */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_LAYER = 40,
|
|
|
|
PROP_LAYER_MEMBER = 41,
|
2008-11-01 00:50:02 +01:00
|
|
|
} PropertySubType;
|
|
|
|
|
2013-08-30 15:24:16 +02:00
|
|
|
/* Make sure enums are updated with these */
|
2013-08-26 23:11:52 +02:00
|
|
|
/* HIGHEST FLAG IN USE: 1 << 30 */
|
2008-11-01 00:50:02 +01:00
|
|
|
typedef enum PropertyFlag {
|
2008-11-07 03:58:25 +01:00
|
|
|
/* editable means the property is editable in the user
|
2009-01-17 14:54:56 +01:00
|
|
|
* interface, properties are editable by default except
|
|
|
|
* for pointers and collections. */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_EDITABLE = (1 << 0),
|
2008-11-07 03:58:25 +01:00
|
|
|
|
2009-07-24 18:41:12 +02:00
|
|
|
/* this property is editable even if it is lib linked,
|
|
|
|
* meaning it will get lost on reload, but it's useful
|
|
|
|
* for editing. */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_LIB_EXCEPTION = (1 << 16),
|
2009-07-24 18:41:12 +02:00
|
|
|
|
2012-03-03 12:45:08 +01:00
|
|
|
/* animatable means the property can be driven by some
|
2008-11-07 03:58:25 +01:00
|
|
|
* other input, be it animation curves, expressions, ..
|
2012-03-03 12:45:08 +01:00
|
|
|
* properties are animatable by default except for pointers
|
2009-01-17 14:54:56 +01:00
|
|
|
* and collections */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_ANIMATABLE = (1 << 1),
|
2008-11-14 15:34:19 +01:00
|
|
|
|
2009-06-16 02:52:21 +02:00
|
|
|
/* icon */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_ICONS_CONSECUTIVE = (1 << 12),
|
2009-06-16 02:52:21 +02:00
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 20:40:03 +02:00
|
|
|
/* hidden in the user interface */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_HIDDEN = (1 << 19),
|
2011-06-07 12:54:57 +02:00
|
|
|
/* do not write in presets */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_SKIP_SAVE = (1 << 28),
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 20:40:03 +02:00
|
|
|
|
2013-08-26 23:11:52 +02:00
|
|
|
/* function parameter flags */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_REQUIRED = (1 << 2),
|
|
|
|
PROP_OUTPUT = (1 << 3),
|
|
|
|
PROP_RNAPTR = (1 << 11),
|
2013-08-26 23:11:52 +02:00
|
|
|
/* This allows for non-breaking API updates, when adding non-critical new parameter to a callback function.
|
|
|
|
* This way, old py code defining funcs without that parameter would still work.
|
|
|
|
* WARNING: any parameter after the first PYFUNC_OPTIONAL one will be considered as optional!
|
|
|
|
* NOTE: only for input parameters!
|
|
|
|
*/
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_PYFUNC_OPTIONAL = (1 << 30),
|
2009-04-19 15:37:59 +02:00
|
|
|
/* registering */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_REGISTER = (1 << 4),
|
|
|
|
PROP_REGISTER_OPTIONAL = PROP_REGISTER | (1 << 5),
|
2009-04-11 03:43:50 +02:00
|
|
|
|
2009-05-29 17:12:31 +02:00
|
|
|
/* pointers */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_ID_REFCOUNT = (1 << 6),
|
2009-10-14 15:20:20 +02:00
|
|
|
|
|
|
|
/* disallow assigning a variable to its self, eg an object tracking its self
|
|
|
|
* only apply this to types that are derived from an ID ()*/
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_ID_SELF_CHECK = (1 << 20),
|
2012-04-09 06:39:47 +02:00
|
|
|
/* use for...
|
|
|
|
* - pointers: in the UI and python so unsetting or setting to None won't work
|
|
|
|
* - strings: so our internal generated get/length/set functions know to do NULL checks before access [#30865] */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_NEVER_NULL = (1 << 18),
|
2010-12-30 13:22:28 +01:00
|
|
|
/* currently only used for UI, this is similar to PROP_NEVER_NULL
|
|
|
|
* except that the value may be NULL at times, used for ObData, where an Empty's will be NULL
|
|
|
|
* but setting NULL on a mesh object is not possible. So, if its not NULL, setting NULL cant be done! */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_NEVER_UNLINK = (1 << 25),
|
2009-05-29 17:12:31 +02:00
|
|
|
|
2009-12-22 17:11:11 +01:00
|
|
|
/* flag contains multiple enums.
|
|
|
|
* note: not to be confused with prop->enumbitflags
|
|
|
|
* this exposes the flag as multiple options in python and the UI.
|
|
|
|
*
|
|
|
|
* note: these can't be animated so use with care.
|
2012-03-09 19:28:30 +01:00
|
|
|
*/
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_ENUM_FLAG = (1 << 21),
|
2009-12-07 01:16:57 +01:00
|
|
|
|
2009-12-08 18:23:48 +01:00
|
|
|
/* need context for update function */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_CONTEXT_UPDATE = (1 << 22),
|
2012-05-12 13:01:29 +02:00
|
|
|
PROP_CONTEXT_PROPERTY_UPDATE = (1 << 22) | (1 << 27),
|
2009-12-08 18:23:48 +01:00
|
|
|
|
2012-07-17 01:23:33 +02:00
|
|
|
/* Use for arrays or for any data that should not have a reference kept
|
2009-12-28 23:59:09 +01:00
|
|
|
* most common case is functions that return arrays where the array */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_THICK_WRAP = (1 << 23),
|
2009-12-28 23:59:09 +01:00
|
|
|
|
2011-01-24 04:38:34 +01:00
|
|
|
/* Reject values outside limits, use for python api only so far
|
|
|
|
* this is for use when silently clamping string length will give
|
|
|
|
* bad behavior later. Could also enforce this for INT's and other types.
|
|
|
|
* note: currently no support for function arguments or non utf8 paths (filepaths) */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_NEVER_CLAMP = (1 << 26),
|
2011-01-24 04:38:34 +01:00
|
|
|
|
2008-11-17 19:44:06 +01:00
|
|
|
/* internal flags */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_BUILTIN = (1 << 7),
|
|
|
|
PROP_EXPORT = (1 << 8),
|
|
|
|
PROP_RUNTIME = (1 << 9),
|
|
|
|
PROP_IDPROPERTY = (1 << 10),
|
|
|
|
PROP_RAW_ACCESS = (1 << 13),
|
|
|
|
PROP_RAW_ARRAY = (1 << 14),
|
|
|
|
PROP_FREE_POINTERS = (1 << 15),
|
|
|
|
PROP_DYNAMIC = (1 << 17), /* for dynamic arrays, and retvals of type string */
|
|
|
|
PROP_ENUM_NO_CONTEXT = (1 << 24), /* for enum that shouldn't be contextual */
|
|
|
|
PROP_ENUM_NO_TRANSLATE = (1 << 29), /* for enums not to be translated (e.g. renderlayers' names in nodes) */
|
2008-11-01 00:50:02 +01:00
|
|
|
} PropertyFlag;
|
|
|
|
|
|
|
|
typedef struct CollectionPropertyIterator {
|
2009-02-02 20:57:57 +01:00
|
|
|
/* internal */
|
2008-11-14 18:05:25 +01:00
|
|
|
PointerRNA parent;
|
2009-05-20 11:17:21 +02:00
|
|
|
PointerRNA builtin_parent;
|
2008-11-24 16:51:55 +01:00
|
|
|
struct PropertyRNA *prop;
|
2008-11-01 00:50:02 +01:00
|
|
|
void *internal;
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 21:38:52 +01:00
|
|
|
int idprop;
|
2009-02-02 20:57:57 +01:00
|
|
|
int level;
|
2008-11-14 18:05:25 +01:00
|
|
|
|
2009-02-02 20:57:57 +01:00
|
|
|
/* external */
|
2008-11-14 18:05:25 +01:00
|
|
|
PointerRNA ptr;
|
2011-10-03 03:36:25 +02:00
|
|
|
int valid;
|
2008-11-01 00:50:02 +01:00
|
|
|
} CollectionPropertyIterator;
|
|
|
|
|
2009-03-19 20:03:38 +01:00
|
|
|
typedef struct CollectionPointerLink {
|
|
|
|
struct CollectionPointerLink *next, *prev;
|
|
|
|
PointerRNA ptr;
|
|
|
|
} CollectionPointerLink;
|
|
|
|
|
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 21:15:51 +02:00
|
|
|
typedef enum RawPropertyType {
|
2012-05-12 13:01:29 +02:00
|
|
|
PROP_RAW_UNSET = -1,
|
2009-08-30 01:05:46 +02:00
|
|
|
PROP_RAW_INT, // XXX - abused for types that are not set, eg. MFace.verts, needs fixing.
|
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 21:15:51 +02:00
|
|
|
PROP_RAW_SHORT,
|
2009-08-30 01:05:46 +02:00
|
|
|
PROP_RAW_CHAR,
|
|
|
|
PROP_RAW_DOUBLE,
|
|
|
|
PROP_RAW_FLOAT
|
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 21:15:51 +02:00
|
|
|
} RawPropertyType;
|
|
|
|
|
|
|
|
typedef struct RawArray {
|
|
|
|
void *array;
|
|
|
|
RawPropertyType type;
|
|
|
|
int len;
|
|
|
|
int stride;
|
|
|
|
} RawArray;
|
|
|
|
|
2008-11-14 19:46:57 +01:00
|
|
|
typedef struct EnumPropertyItem {
|
2008-11-01 00:50:02 +01:00
|
|
|
int value;
|
2008-11-14 19:46:57 +01:00
|
|
|
const char *identifier;
|
2009-06-16 02:52:21 +02:00
|
|
|
int icon;
|
2008-11-01 00:50:02 +01:00
|
|
|
const char *name;
|
2008-11-24 13:12:24 +01:00
|
|
|
const char *description;
|
2008-11-14 19:46:57 +01:00
|
|
|
} EnumPropertyItem;
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2013-01-05 15:56:37 +01:00
|
|
|
/* extended versions with PropertyRNA argument */
|
|
|
|
typedef int (*BooleanPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop);
|
|
|
|
typedef void (*BooleanPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int value);
|
|
|
|
typedef void (*BooleanArrayPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int *values);
|
|
|
|
typedef void (*BooleanArrayPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, const int *values);
|
|
|
|
typedef int (*IntPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop);
|
|
|
|
typedef void (*IntPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int value);
|
|
|
|
typedef void (*IntArrayPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int *values);
|
|
|
|
typedef void (*IntArrayPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, const int *values);
|
|
|
|
typedef void (*IntPropertyRangeFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int *min, int *max, int *softmin, int *softmax);
|
|
|
|
typedef float (*FloatPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop);
|
|
|
|
typedef void (*FloatPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, float value);
|
|
|
|
typedef void (*FloatArrayPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, float *values);
|
|
|
|
typedef void (*FloatArrayPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, const float *values);
|
|
|
|
typedef void (*FloatPropertyRangeFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, float *min, float *max, float *softmin, float *softmax);
|
|
|
|
typedef void (*StringPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, char *value);
|
|
|
|
typedef int (*StringPropertyLengthFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop);
|
|
|
|
typedef void (*StringPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, const char *value);
|
|
|
|
typedef int (*EnumPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop);
|
|
|
|
typedef void (*EnumPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int value);
|
|
|
|
/* same as PropEnumItemFunc */
|
2011-05-26 15:38:16 +02:00
|
|
|
typedef EnumPropertyItem *(*EnumPropertyItemFunc)(struct bContext *C, PointerRNA *ptr, struct PropertyRNA *prop, int *free);
|
2009-07-08 17:34:41 +02:00
|
|
|
|
2008-11-17 19:44:06 +01:00
|
|
|
typedef struct PropertyRNA PropertyRNA;
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2009-04-07 02:49:39 +02:00
|
|
|
/* Parameter List */
|
|
|
|
|
2009-07-17 04:31:28 +02:00
|
|
|
typedef struct ParameterList {
|
|
|
|
/* storage for parameters */
|
|
|
|
void *data;
|
|
|
|
|
2011-10-03 03:36:25 +02:00
|
|
|
/* function passed at creation time */
|
|
|
|
struct FunctionRNA *func;
|
|
|
|
|
2010-03-23 16:04:06 +01:00
|
|
|
/* store the parameter size */
|
|
|
|
int alloc_size;
|
|
|
|
|
|
|
|
int arg_count, ret_count;
|
2009-07-17 04:31:28 +02:00
|
|
|
} ParameterList;
|
2009-04-07 02:49:39 +02:00
|
|
|
|
|
|
|
typedef struct ParameterIterator {
|
2009-07-17 04:31:28 +02:00
|
|
|
struct ParameterList *parms;
|
2011-08-15 05:41:31 +02:00
|
|
|
/* PointerRNA funcptr; */ /*UNUSED*/
|
2009-04-07 02:49:39 +02:00
|
|
|
void *data;
|
|
|
|
int size, offset;
|
|
|
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
int valid;
|
|
|
|
} ParameterIterator;
|
|
|
|
|
2010-08-31 13:31:21 +02:00
|
|
|
/* mainly to avoid confusing casts */
|
|
|
|
typedef struct ParameterDynAlloc {
|
|
|
|
intptr_t array_tot; /* important, this breaks when set to an int */
|
|
|
|
void *array;
|
|
|
|
} ParameterDynAlloc;
|
|
|
|
|
2009-04-07 02:49:39 +02:00
|
|
|
/* Function */
|
|
|
|
|
|
|
|
typedef enum FunctionFlag {
|
2013-08-30 15:24:16 +02:00
|
|
|
FUNC_NO_SELF = (1 << 0), /* for static functions */
|
|
|
|
FUNC_USE_SELF_TYPE = (1 << 1), /* for class methods, only used when FUNC_NO_SELF is set */
|
|
|
|
FUNC_USE_MAIN = (1 << 2),
|
|
|
|
FUNC_USE_CONTEXT = (1 << 3),
|
|
|
|
FUNC_USE_REPORTS = (1 << 4),
|
|
|
|
FUNC_USE_SELF_ID = (1 << 11),
|
|
|
|
FUNC_ALLOW_WRITE = (1 << 12),
|
2009-04-07 02:49:39 +02:00
|
|
|
|
2009-04-19 15:37:59 +02:00
|
|
|
/* registering */
|
2013-08-30 15:24:16 +02:00
|
|
|
FUNC_REGISTER = (1 << 5),
|
|
|
|
FUNC_REGISTER_OPTIONAL = FUNC_REGISTER | (1 << 6),
|
2009-04-19 15:37:59 +02:00
|
|
|
|
2009-04-07 02:49:39 +02:00
|
|
|
/* internal flags */
|
2013-08-30 15:24:16 +02:00
|
|
|
FUNC_BUILTIN = (1 << 7),
|
|
|
|
FUNC_EXPORT = (1 << 8),
|
|
|
|
FUNC_RUNTIME = (1 << 9),
|
|
|
|
FUNC_FREE_POINTERS = (1 << 10),
|
2009-04-07 02:49:39 +02:00
|
|
|
} FunctionFlag;
|
|
|
|
|
2009-06-18 21:48:55 +02:00
|
|
|
typedef void (*CallFunc)(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, ParameterList *parms);
|
2009-04-07 02:49:39 +02:00
|
|
|
|
|
|
|
typedef struct FunctionRNA FunctionRNA;
|
|
|
|
|
2008-11-07 03:58:25 +01:00
|
|
|
/* Struct */
|
|
|
|
|
|
|
|
typedef enum StructFlag {
|
2009-05-29 17:12:31 +02:00
|
|
|
/* indicates that this struct is an ID struct, and to use refcounting */
|
2013-08-30 15:24:16 +02:00
|
|
|
STRUCT_ID = (1 << 0),
|
|
|
|
STRUCT_ID_REFCOUNT = (1 << 1),
|
|
|
|
STRUCT_UNDO = (1 << 2), /* defaults on, clear for user preferences and similar */
|
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 03:23:46 +01:00
|
|
|
|
|
|
|
/* internal flags */
|
2013-08-30 15:24:16 +02:00
|
|
|
STRUCT_RUNTIME = (1 << 3),
|
|
|
|
STRUCT_GENERATED = (1 << 4),
|
|
|
|
STRUCT_FREE_POINTERS = (1 << 5),
|
|
|
|
STRUCT_NO_IDPROPERTIES = (1 << 6), /* Menu's and Panels don't need properties */
|
2008-11-07 03:58:25 +01:00
|
|
|
} StructFlag;
|
|
|
|
|
2009-04-19 15:37:59 +02:00
|
|
|
typedef int (*StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_function);
|
2010-12-07 05:12:15 +01:00
|
|
|
typedef int (*StructCallbackFunc)(struct bContext *C, struct PointerRNA *ptr, struct FunctionRNA *func, ParameterList *list);
|
2009-04-19 15:37:59 +02:00
|
|
|
typedef void (*StructFreeFunc)(void *data);
|
2012-04-15 09:24:14 +02:00
|
|
|
typedef struct StructRNA *(*StructRegisterFunc)(
|
|
|
|
struct Main *bmain, struct ReportList *reports, void *data, const char *identifier,
|
|
|
|
StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free);
|
|
|
|
|
2011-05-18 12:56:26 +02:00
|
|
|
typedef void (*StructUnregisterFunc)(struct Main *bmain, struct StructRNA *type);
|
2011-05-18 13:21:10 +02:00
|
|
|
typedef void **(*StructInstanceFunc)(PointerRNA *ptr);
|
2009-04-19 15:37:59 +02:00
|
|
|
|
2008-11-17 19:44:06 +01:00
|
|
|
typedef struct StructRNA StructRNA;
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2008-11-07 03:58:25 +01:00
|
|
|
/* Blender RNA
|
|
|
|
*
|
|
|
|
* Root RNA data structure that lists all struct types. */
|
|
|
|
|
2008-11-17 19:44:06 +01:00
|
|
|
typedef struct BlenderRNA BlenderRNA;
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2009-07-21 22:05:16 +02:00
|
|
|
/* Extending
|
|
|
|
*
|
|
|
|
* This struct must be embedded in *Type structs in
|
|
|
|
* order to make then definable through RNA. */
|
|
|
|
|
|
|
|
typedef struct ExtensionRNA {
|
|
|
|
void *data;
|
|
|
|
StructRNA *srna;
|
2010-12-07 05:12:15 +01:00
|
|
|
StructCallbackFunc call;
|
|
|
|
StructFreeFunc free;
|
|
|
|
|
2009-07-21 22:05:16 +02:00
|
|
|
} ExtensionRNA;
|
|
|
|
|
2009-03-15 00:17:55 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-02-17 19:59:41 +01:00
|
|
|
#endif /* __RNA_TYPES_H__ */
|