4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * Contributor(s): Blender Foundation (2008).
22 * ***** END GPL LICENSE BLOCK *****
25 /** \file blender/makesrna/RNA_types.h
30 #include "BLO_sys_types.h"
42 struct EnumPropertyRNA;
52 * RNA pointers are not a single C pointer but include the type,
53 * and a pointer to the ID struct that owns the struct, since
54 * in some cases this information is needed to correctly get/set
55 * the properties and validate them. */
57 typedef struct PointerRNA {
62 struct StructRNA *type;
66 typedef struct PropertyPointerRNA {
68 struct PropertyRNA *prop;
73 typedef enum PropertyType {
83 /* also update rna_property_subtype_unit when you change this */
84 typedef enum PropertyUnit {
85 PROP_UNIT_NONE = (0<<16),
86 PROP_UNIT_LENGTH = (1<<16), /* m */
87 PROP_UNIT_AREA = (2<<16), /* m^2 */
88 PROP_UNIT_VOLUME = (3<<16), /* m^3 */
89 PROP_UNIT_MASS = (4<<16), /* kg */
90 PROP_UNIT_ROTATION = (5<<16), /* radians */
91 PROP_UNIT_TIME = (6<<16), /* frame */
92 PROP_UNIT_VELOCITY = (7<<16), /* m/s */
93 PROP_UNIT_ACCELERATION = (8<<16) /* m/(s^2) */
96 #define RNA_SUBTYPE_UNIT(subtype) ((subtype) & 0x00FF0000)
97 #define RNA_SUBTYPE_VALUE(subtype) ((subtype) & ~0x00FF0000)
98 #define RNA_SUBTYPE_UNIT_VALUE(subtype) ((subtype)>>16)
100 #define RNA_ENUM_BITFLAG_SIZE 32
102 /* also update enums in bpy_props.c when adding items here */
103 typedef enum PropertySubType {
113 PROP_PERCENTAGE = 14,
115 PROP_ANGLE = 16|PROP_UNIT_ROTATION,
116 PROP_TIME = 17|PROP_UNIT_TIME,
117 PROP_DISTANCE = 18|PROP_UNIT_LENGTH,
121 PROP_TRANSLATION = 21|PROP_UNIT_LENGTH,
123 PROP_VELOCITY = 23|PROP_UNIT_VELOCITY,
124 PROP_ACCELERATION = 24|PROP_UNIT_ACCELERATION,
126 PROP_EULER = 26|PROP_UNIT_ROTATION,
127 PROP_QUATERNION = 27,
130 PROP_XYZ_LENGTH = 29|PROP_UNIT_LENGTH,
131 PROP_COLOR_GAMMA = 30,
132 PROP_COORDS = 31, /* generic array, no units applied, only that x/y/z/w are used (python vec) */
136 PROP_LAYER_MEMBER = 41
139 /* Make sure enums are updated with thses */
140 typedef enum PropertyFlag {
141 /* editable means the property is editable in the user
142 * interface, properties are editable by default except
143 * for pointers and collections. */
144 PROP_EDITABLE = 1<<0,
146 /* this property is editable even if it is lib linked,
147 * meaning it will get lost on reload, but it's useful
149 PROP_LIB_EXCEPTION = 1<<16,
151 /* animateable means the property can be driven by some
152 * other input, be it animation curves, expressions, ..
153 * properties are animateable by default except for pointers
155 PROP_ANIMATABLE = 1<<1,
158 PROP_ICONS_CONSECUTIVE = 1<<12,
160 /* hidden in the user interface */
162 /* do not write in presets */
163 PROP_SKIP_SAVE = 1<<28,
165 /* function paramater flags */
166 PROP_REQUIRED = 1<<2,
170 PROP_REGISTER = 1<<4,
171 PROP_REGISTER_OPTIONAL = (1<<4)|(1<<5),
174 PROP_ID_REFCOUNT = 1<<6,
176 /* disallow assigning a variable to its self, eg an object tracking its self
177 * only apply this to types that are derived from an ID ()*/
178 PROP_ID_SELF_CHECK = 1<<20,
179 PROP_NEVER_NULL = 1<<18,
180 /* currently only used for UI, this is similar to PROP_NEVER_NULL
181 * except that the value may be NULL at times, used for ObData, where an Empty's will be NULL
182 * but setting NULL on a mesh object is not possible. So, if its not NULL, setting NULL cant be done! */
183 PROP_NEVER_UNLINK = 1<<25,
185 /* flag contains multiple enums.
186 * note: not to be confused with prop->enumbitflags
187 * this exposes the flag as multiple options in python and the UI.
189 * note: these can't be animated so use with care.
191 PROP_ENUM_FLAG = 1<<21,
193 /* need context for update function */
194 PROP_CONTEXT_UPDATE = 1<<22,
195 PROP_CONTEXT_PROPERTY_UPDATE = (1<<22)|(1<<27),
197 /* Use for arrays or for any data that should not have a referene kept
198 * most common case is functions that return arrays where the array */
199 PROP_THICK_WRAP = 1<<23,
201 /* Reject values outside limits, use for python api only so far
202 * this is for use when silently clamping string length will give
203 * bad behavior later. Could also enforce this for INT's and other types.
204 * note: currently no support for function arguments or non utf8 paths (filepaths) */
205 PROP_NEVER_CLAMP = 1<<26,
211 PROP_IDPROPERTY = 1<<10,
212 PROP_RAW_ACCESS = 1<<13,
213 PROP_RAW_ARRAY = 1<<14,
214 PROP_FREE_POINTERS = 1<<15,
215 PROP_DYNAMIC = 1<<17, /* for dynamic arrays, and retvals of type string */
216 PROP_ENUM_NO_CONTEXT = 1<<24 /* for enum that shouldn't be contextual */
219 typedef struct CollectionPropertyIterator {
222 PointerRNA builtin_parent;
223 struct PropertyRNA *prop;
231 } CollectionPropertyIterator;
233 typedef struct CollectionPointerLink {
234 struct CollectionPointerLink *next, *prev;
236 } CollectionPointerLink;
238 typedef enum RawPropertyType {
240 PROP_RAW_INT, // XXX - abused for types that are not set, eg. MFace.verts, needs fixing.
247 typedef struct RawArray {
249 RawPropertyType type;
254 typedef struct EnumPropertyItem {
256 const char *identifier;
259 const char *description;
262 /* this is a copy of 'PropEnumItemFunc' defined in rna_internal_types.h */
263 typedef EnumPropertyItem *(*EnumPropertyItemFunc)(struct bContext *C, PointerRNA *ptr, struct PropertyRNA *prop, int *free);
265 typedef struct PropertyRNA PropertyRNA;
269 typedef struct ParameterList {
270 /* storage for parameters */
273 /* store the parameter size */
276 int arg_count, ret_count;
278 /* function passed at creation time */
279 struct FunctionRNA *func;
282 typedef struct ParameterIterator {
283 struct ParameterList *parms;
292 /* mainly to avoid confusing casts */
293 typedef struct ParameterDynAlloc {
294 intptr_t array_tot; /* important, this breaks when set to an int */
300 typedef enum FunctionFlag {
301 FUNC_NO_SELF = 1, /* for static functions */
302 FUNC_USE_CONTEXT = 2,
303 FUNC_USE_REPORTS = 4,
304 FUNC_USE_SELF_ID = 2048,
308 FUNC_REGISTER_OPTIONAL = 8|16,
314 FUNC_FREE_POINTERS = 1024
317 typedef void (*CallFunc)(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, ParameterList *parms);
319 typedef struct FunctionRNA FunctionRNA;
323 typedef enum StructFlag {
324 /* indicates that this struct is an ID struct, and to use refcounting */
326 STRUCT_ID_REFCOUNT = 2,
330 STRUCT_GENERATED = 8,
331 STRUCT_FREE_POINTERS = 16,
332 STRUCT_NO_IDPROPERTIES = 32 /* Menu's and Panels don't need properties */
335 typedef int (*StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_function);
336 typedef int (*StructCallbackFunc)(struct bContext *C, struct PointerRNA *ptr, struct FunctionRNA *func, ParameterList *list);
337 typedef void (*StructFreeFunc)(void *data);
338 typedef struct StructRNA *(*StructRegisterFunc)(struct Main *bmain, struct ReportList *reports, void *data,
339 const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free);
340 typedef void (*StructUnregisterFunc)(struct Main *bmain, struct StructRNA *type);
341 typedef void **(*StructInstanceFunc)(PointerRNA *ptr);
343 typedef struct StructRNA StructRNA;
347 * Root RNA data structure that lists all struct types. */
349 typedef struct BlenderRNA BlenderRNA;
353 * This struct must be embedded in *Type structs in
354 * order to make then definable through RNA. */
356 typedef struct ExtensionRNA {
359 StructCallbackFunc call;
368 #endif /* RNA_TYPES_H */