2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Blender Foundation (2008).
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file blender/makesrna/RNA_types.h
28 #include "../blenlib/BLI_sys_types.h"
30 #ifndef __RNA_TYPES_H__
31 #define __RNA_TYPES_H__
40 struct EnumPropertyRNA;
50 * RNA pointers are not a single C pointer but include the type,
51 * and a pointer to the ID struct that owns the struct, since
52 * in some cases this information is needed to correctly get/set
53 * the properties and validate them. */
55 typedef struct PointerRNA {
60 struct StructRNA *type;
64 typedef struct PropertyPointerRNA {
66 struct PropertyRNA *prop;
71 typedef enum PropertyType {
81 /* also update rna_property_subtype_unit when you change this */
82 typedef enum PropertyUnit {
83 PROP_UNIT_NONE = (0 << 16),
84 PROP_UNIT_LENGTH = (1 << 16), /* m */
85 PROP_UNIT_AREA = (2 << 16), /* m^2 */
86 PROP_UNIT_VOLUME = (3 << 16), /* m^3 */
87 PROP_UNIT_MASS = (4 << 16), /* kg */
88 PROP_UNIT_ROTATION = (5 << 16), /* radians */
89 PROP_UNIT_TIME = (6 << 16), /* frame */
90 PROP_UNIT_VELOCITY = (7 << 16), /* m/s */
91 PROP_UNIT_ACCELERATION = (8 << 16), /* m/(s^2) */
92 PROP_UNIT_CAMERA = (9 << 16), /* mm */
95 #define RNA_SUBTYPE_UNIT(subtype) ((subtype) & 0x00FF0000)
96 #define RNA_SUBTYPE_VALUE(subtype) ((subtype) & ~0x00FF0000)
97 #define RNA_SUBTYPE_UNIT_VALUE(subtype) ((subtype) >> 16)
99 #define RNA_ENUM_BITFLAG_SIZE 32
101 #define RNA_TRANSLATION_PREC_DEFAULT 5
103 /* also update enums in bpy_props.c when adding items here
104 * watch it: these values are written to files as part of
105 * node socket button subtypes!
107 typedef enum PropertySubType {
114 PROP_BYTESTRING = 4, /* a string which should be represented as bytes in python, NULL terminated though. */
115 /* 5 was used by "PROP_TRANSLATE" sub-type, which is now a flag. */
116 PROP_PASSWORD = 6, /* a string which should not be displayed in UI */
121 PROP_PERCENTAGE = 14,
123 PROP_ANGLE = 16 | PROP_UNIT_ROTATION,
124 PROP_TIME = 17 | PROP_UNIT_TIME,
125 /* distance in 3d space, don't use for pixel distance for eg. */
126 PROP_DISTANCE = 18 | PROP_UNIT_LENGTH,
127 PROP_DISTANCE_CAMERA = 19 | PROP_UNIT_CAMERA,
131 PROP_TRANSLATION = 21 | PROP_UNIT_LENGTH,
133 PROP_VELOCITY = 23 | PROP_UNIT_VELOCITY,
134 PROP_ACCELERATION = 24 | PROP_UNIT_ACCELERATION,
136 PROP_EULER = 26 | PROP_UNIT_ROTATION,
137 PROP_QUATERNION = 27,
140 PROP_XYZ_LENGTH = 29 | PROP_UNIT_LENGTH,
141 PROP_COLOR_GAMMA = 30, /* used for colors which would be color managed before display */
142 PROP_COORDS = 31, /* generic array, no units applied, only that x/y/z/w are used (python vec) */
146 PROP_LAYER_MEMBER = 41,
149 /* Make sure enums are updated with these */
150 /* HIGHEST FLAG IN USE: 1 << 31 */
151 typedef enum PropertyFlag {
152 /* editable means the property is editable in the user
153 * interface, properties are editable by default except
154 * for pointers and collections. */
155 PROP_EDITABLE = (1 << 0),
157 /* this property is editable even if it is lib linked,
158 * meaning it will get lost on reload, but it's useful
160 PROP_LIB_EXCEPTION = (1 << 16),
162 /* animatable means the property can be driven by some
163 * other input, be it animation curves, expressions, ..
164 * properties are animatable by default except for pointers
166 PROP_ANIMATABLE = (1 << 1),
168 /* This flag means when the property's widget is in 'textedit' mode, it will be updated after every typed char,
169 * instead of waiting final validation. Used e.g. for text searchbox. */
170 PROP_TEXTEDIT_UPDATE = (1 << 31),
173 PROP_ICONS_CONSECUTIVE = (1 << 12),
175 /* hidden in the user interface */
176 PROP_HIDDEN = (1 << 19),
177 /* do not write in presets */
178 PROP_SKIP_SAVE = (1 << 28),
180 /* function parameter flags */
181 PROP_REQUIRED = (1 << 2),
182 PROP_OUTPUT = (1 << 3),
183 PROP_RNAPTR = (1 << 11),
184 /* This allows for non-breaking API updates, when adding non-critical new parameter to a callback function.
185 * This way, old py code defining funcs without that parameter would still work.
186 * WARNING: any parameter after the first PYFUNC_OPTIONAL one will be considered as optional!
187 * NOTE: only for input parameters!
189 PROP_PYFUNC_OPTIONAL = (1 << 30),
191 PROP_REGISTER = (1 << 4),
192 PROP_REGISTER_OPTIONAL = PROP_REGISTER | (1 << 5),
196 /* each value is related proportionally (object scale, image size) */
197 PROP_PROPORTIONAL = (1 << 26),
200 PROP_ID_REFCOUNT = (1 << 6),
202 /* disallow assigning a variable to its self, eg an object tracking its self
203 * only apply this to types that are derived from an ID ()*/
204 PROP_ID_SELF_CHECK = (1 << 20),
206 * - pointers: in the UI and python so unsetting or setting to None won't work
207 * - strings: so our internal generated get/length/set functions know to do NULL checks before access [#30865] */
208 PROP_NEVER_NULL = (1 << 18),
209 /* currently only used for UI, this is similar to PROP_NEVER_NULL
210 * except that the value may be NULL at times, used for ObData, where an Empty's will be NULL
211 * but setting NULL on a mesh object is not possible. So, if its not NULL, setting NULL cant be done! */
212 PROP_NEVER_UNLINK = (1 << 25),
214 /* flag contains multiple enums.
215 * note: not to be confused with prop->enumbitflags
216 * this exposes the flag as multiple options in python and the UI.
218 * note: these can't be animated so use with care.
220 PROP_ENUM_FLAG = (1 << 21),
222 /* need context for update function */
223 PROP_CONTEXT_UPDATE = (1 << 22),
224 PROP_CONTEXT_PROPERTY_UPDATE = (1 << 22) | (1 << 27),
226 /* Use for arrays or for any data that should not have a reference kept
227 * most common case is functions that return arrays where the array */
228 PROP_THICK_WRAP = (1 << 23),
231 PROP_BUILTIN = (1 << 7),
232 PROP_EXPORT = (1 << 8),
233 PROP_RUNTIME = (1 << 9),
234 PROP_IDPROPERTY = (1 << 10),
235 PROP_RAW_ACCESS = (1 << 13),
236 PROP_RAW_ARRAY = (1 << 14),
237 PROP_FREE_POINTERS = (1 << 15),
238 PROP_DYNAMIC = (1 << 17), /* for dynamic arrays, and retvals of type string */
239 PROP_ENUM_NO_CONTEXT = (1 << 24), /* for enum that shouldn't be contextual */
240 PROP_ENUM_NO_TRANSLATE = (1 << 29), /* for enums not to be translated (e.g. renderlayers' names in nodes) */
243 struct CollectionPropertyIterator;
245 typedef int (*IteratorSkipFunc)(struct CollectionPropertyIterator *iter, void *data);
247 typedef struct ListBaseIterator {
250 IteratorSkipFunc skip;
253 typedef struct ArrayIterator {
255 char *endptr; /* past the last valid pointer, only for comparisons, ignores skipped values */
256 void *free_ptr; /* will be freed if set */
259 /* array length with no skip functions applied, take care not to compare against index from animsys
260 * or python indices */
263 /* optional skip function, when set the array as viewed by rna can contain only a subset of the members.
264 * this changes indices so quick array index lookups are not possible when skip function is used. */
265 IteratorSkipFunc skip;
268 typedef struct CollectionPropertyIterator {
271 PointerRNA builtin_parent;
272 struct PropertyRNA *prop;
275 ListBaseIterator listbase;
283 } CollectionPropertyIterator;
285 typedef struct CollectionPointerLink {
286 struct CollectionPointerLink *next, *prev;
288 } CollectionPointerLink;
290 typedef enum RawPropertyType {
292 PROP_RAW_INT, // XXX - abused for types that are not set, eg. MFace.verts, needs fixing.
299 typedef struct RawArray {
301 RawPropertyType type;
306 typedef struct EnumPropertyItem {
308 const char *identifier;
311 const char *description;
314 /* extended versions with PropertyRNA argument */
315 typedef int (*BooleanPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop);
316 typedef void (*BooleanPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int value);
317 typedef void (*BooleanArrayPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int *values);
318 typedef void (*BooleanArrayPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, const int *values);
319 typedef int (*IntPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop);
320 typedef void (*IntPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int value);
321 typedef void (*IntArrayPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int *values);
322 typedef void (*IntArrayPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, const int *values);
323 typedef void (*IntPropertyRangeFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int *min, int *max, int *softmin, int *softmax);
324 typedef float (*FloatPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop);
325 typedef void (*FloatPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, float value);
326 typedef void (*FloatArrayPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, float *values);
327 typedef void (*FloatArrayPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, const float *values);
328 typedef void (*FloatPropertyRangeFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, float *min, float *max, float *softmin, float *softmax);
329 typedef void (*StringPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, char *value);
330 typedef int (*StringPropertyLengthFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop);
331 typedef void (*StringPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, const char *value);
332 typedef int (*EnumPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop);
333 typedef void (*EnumPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int value);
334 /* same as PropEnumItemFunc */
335 typedef EnumPropertyItem *(*EnumPropertyItemFunc)(struct bContext *C, PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free);
337 typedef struct PropertyRNA PropertyRNA;
341 typedef struct ParameterList {
342 /* storage for parameters */
345 /* function passed at creation time */
346 struct FunctionRNA *func;
348 /* store the parameter size */
351 int arg_count, ret_count;
354 typedef struct ParameterIterator {
355 struct ParameterList *parms;
356 /* PointerRNA funcptr; */ /*UNUSED*/
364 /* mainly to avoid confusing casts */
365 typedef struct ParameterDynAlloc {
366 intptr_t array_tot; /* important, this breaks when set to an int */
372 typedef enum FunctionFlag {
373 FUNC_NO_SELF = (1 << 0), /* for static functions */
374 FUNC_USE_SELF_TYPE = (1 << 1), /* for class methods, only used when FUNC_NO_SELF is set */
375 FUNC_USE_MAIN = (1 << 2),
376 FUNC_USE_CONTEXT = (1 << 3),
377 FUNC_USE_REPORTS = (1 << 4),
378 FUNC_USE_SELF_ID = (1 << 11),
379 FUNC_ALLOW_WRITE = (1 << 12),
382 FUNC_REGISTER = (1 << 5),
383 FUNC_REGISTER_OPTIONAL = FUNC_REGISTER | (1 << 6),
386 FUNC_BUILTIN = (1 << 7),
387 FUNC_EXPORT = (1 << 8),
388 FUNC_RUNTIME = (1 << 9),
389 FUNC_FREE_POINTERS = (1 << 10),
392 typedef void (*CallFunc)(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, ParameterList *parms);
394 typedef struct FunctionRNA FunctionRNA;
398 typedef enum StructFlag {
399 /* indicates that this struct is an ID struct, and to use refcounting */
400 STRUCT_ID = (1 << 0),
401 STRUCT_ID_REFCOUNT = (1 << 1),
402 STRUCT_UNDO = (1 << 2), /* defaults on, clear for user preferences and similar */
405 STRUCT_RUNTIME = (1 << 3),
406 STRUCT_GENERATED = (1 << 4),
407 STRUCT_FREE_POINTERS = (1 << 5),
408 STRUCT_NO_IDPROPERTIES = (1 << 6), /* Menu's and Panels don't need properties */
411 typedef int (*StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_function);
412 typedef int (*StructCallbackFunc)(struct bContext *C, struct PointerRNA *ptr, struct FunctionRNA *func, ParameterList *list);
413 typedef void (*StructFreeFunc)(void *data);
414 typedef struct StructRNA *(*StructRegisterFunc)(
415 struct Main *bmain, struct ReportList *reports, void *data, const char *identifier,
416 StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free);
418 typedef void (*StructUnregisterFunc)(struct Main *bmain, struct StructRNA *type);
419 typedef void **(*StructInstanceFunc)(PointerRNA *ptr);
421 typedef struct StructRNA StructRNA;
425 * Root RNA data structure that lists all struct types. */
427 typedef struct BlenderRNA BlenderRNA;
431 * This struct must be embedded in *Type structs in
432 * order to make then definable through RNA. */
434 typedef struct ExtensionRNA {
437 StructCallbackFunc call;
446 #endif /* __RNA_TYPES_H__ */