2023-08-15 16:20:26 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup RNA
|
2011-02-27 21:20:01 +01:00
|
|
|
*/
|
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
/* Use a define instead of `#pragma once` because of `BKE_addon.h`, `ED_object.hh` & others. */
|
2012-02-17 19:59:41 +01:00
|
|
|
#ifndef __RNA_TYPES_H__
|
|
|
|
#define __RNA_TYPES_H__
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2019-01-09 22:46:38 +01:00
|
|
|
#include "../blenlib/BLI_sys_types.h"
|
2023-05-25 16:30:16 +02:00
|
|
|
#include "../blenlib/BLI_utildefines.h"
|
2019-01-09 22:46:38 +01:00
|
|
|
|
2019-01-28 11:08:24 +01:00
|
|
|
struct BlenderRNA;
|
2009-04-07 02:49:39 +02:00
|
|
|
struct FunctionRNA;
|
2019-08-23 09:52:12 +02:00
|
|
|
struct ID;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct Main;
|
|
|
|
struct ParameterList;
|
2008-11-24 16:51:55 +01:00
|
|
|
struct PropertyRNA;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct ReportList;
|
2008-11-24 16:51:55 +01:00
|
|
|
struct StructRNA;
|
2009-04-19 15:37:59 +02:00
|
|
|
struct bContext;
|
2008-11-24 16:51:55 +01:00
|
|
|
|
2019-11-24 15:14:39 +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. */
|
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct PointerRNA {
|
|
|
|
ID *owner_id;
|
|
|
|
StructRNA *type;
|
2008-11-07 03:58:25 +01:00
|
|
|
void *data;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2008-11-07 03:58:25 +01:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct PropertyPointerRNA {
|
2009-10-02 01:32:57 +02:00
|
|
|
PointerRNA ptr;
|
2023-11-14 09:51:41 +01:00
|
|
|
PropertyRNA *prop;
|
|
|
|
};
|
2009-10-02 01:32:57 +02:00
|
|
|
|
2016-07-30 08:34:01 +02:00
|
|
|
/**
|
|
|
|
* Stored result of a RNA path lookup (as used by anim-system)
|
|
|
|
*/
|
2023-11-14 09:51:41 +01:00
|
|
|
struct PathResolvedRNA {
|
|
|
|
PointerRNA ptr;
|
|
|
|
PropertyRNA *prop;
|
2019-06-26 04:40:22 +02:00
|
|
|
/** -1 for non-array access. */
|
2016-07-30 08:34:01 +02:00
|
|
|
int prop_index;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2016-07-30 08:34:01 +02:00
|
|
|
|
2008-11-07 03:58:25 +01:00
|
|
|
/* Property */
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
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,
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2009-08-11 13:50:40 +02:00
|
|
|
/* also update rna_property_subtype_unit when you change this */
|
2023-11-14 09:51:41 +01:00
|
|
|
enum PropertyUnit {
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_UNIT_NONE = (0 << 16),
|
2021-06-08 11:50:19 +02:00
|
|
|
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_TIME_ABSOLUTE = (7 << 16), /* time in seconds (independent of scene) */
|
|
|
|
PROP_UNIT_VELOCITY = (8 << 16), /* m/s */
|
|
|
|
PROP_UNIT_ACCELERATION = (9 << 16), /* m/(s^2) */
|
|
|
|
PROP_UNIT_CAMERA = (10 << 16), /* mm */
|
|
|
|
PROP_UNIT_POWER = (11 << 16), /* W */
|
|
|
|
PROP_UNIT_TEMPERATURE = (12 << 16), /* C */
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2023-05-25 16:30:16 +02:00
|
|
|
ENUM_OPERATORS(PropertyUnit, PROP_UNIT_TEMPERATURE)
|
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
|
|
|
|
2021-05-17 09:28:12 +02:00
|
|
|
/**
|
|
|
|
* Use values besides #PROP_SCALE_LINEAR
|
|
|
|
* so the movement of the mouse doesn't map linearly to the value of the slider.
|
|
|
|
*
|
2023-02-12 04:37:16 +01:00
|
|
|
* For some settings it's useful to space motion in a non-linear way, see #77868.
|
2021-05-17 09:28:12 +02:00
|
|
|
*
|
|
|
|
* NOTE: The scale types are available for all float sliders.
|
|
|
|
* For integer sliders they are only available if they use the visible value bar.
|
|
|
|
* Sliders with logarithmic scale and value bar must have a range > 0
|
|
|
|
* while logarithmic sliders without the value bar can have a range of >= 0.
|
|
|
|
*/
|
2023-11-14 09:51:41 +01:00
|
|
|
enum PropertyScaleType {
|
2021-05-17 09:28:12 +02:00
|
|
|
/** Linear scale (default). */
|
|
|
|
PROP_SCALE_LINEAR = 0,
|
|
|
|
/**
|
|
|
|
* Logarithmic scale
|
|
|
|
* - Maximum range: `0 <= x < inf`
|
|
|
|
*/
|
|
|
|
PROP_SCALE_LOG = 1,
|
|
|
|
/**
|
|
|
|
* Cubic scale.
|
|
|
|
* - Maximum range: `-inf < x < inf`
|
|
|
|
*/
|
|
|
|
PROP_SCALE_CUBIC = 2,
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2021-05-17 09:28:12 +02:00
|
|
|
|
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
|
|
|
|
|
2017-11-29 15:16:12 +01:00
|
|
|
#define RNA_STACK_ARRAY 32
|
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
2023-07-31 03:50:54 +02:00
|
|
|
* \note Also update enums in `bpy_props.cc` and `rna_rna.cc` when adding items here.
|
2022-09-16 10:13:19 +02:00
|
|
|
* Watch it: these values are written to files as part of node socket button sub-types!
|
2011-09-05 23:01:50 +02:00
|
|
|
*/
|
2023-11-14 09:51:41 +01:00
|
|
|
enum PropertySubType {
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_NONE = 0,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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,
|
2019-06-26 04:40:22 +02:00
|
|
|
/** A string which should be represented as bytes in python, NULL terminated though. */
|
|
|
|
PROP_BYTESTRING = 4,
|
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. */
|
2019-06-26 04:40:22 +02:00
|
|
|
/** A string which should not be displayed in UI. */
|
|
|
|
PROP_PASSWORD = 6,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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 */
|
2020-03-10 15:12:20 +01:00
|
|
|
/** A dimension in pixel units, possibly before DPI scaling (so value may not be the final pixel
|
|
|
|
* value but the one to apply DPI scale to). */
|
2013-12-12 18:39:15 +01:00
|
|
|
PROP_PIXEL = 12,
|
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,
|
2021-06-08 11:50:19 +02:00
|
|
|
PROP_TIME_ABSOLUTE = 17 | PROP_UNIT_TIME_ABSOLUTE,
|
2019-06-26 04:40:22 +02: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,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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,
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Used for colors which would be color managed before display. */
|
|
|
|
PROP_COLOR_GAMMA = 30,
|
|
|
|
/** Generic array, no units applied, only that x/y/z/w are used (Python vector). */
|
|
|
|
PROP_COORDS = 31,
|
2019-04-17 06:17:24 +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,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Light */
|
2019-02-08 12:31:28 +01:00
|
|
|
PROP_POWER = 42 | PROP_UNIT_POWER,
|
2020-09-07 21:59:07 +02:00
|
|
|
|
|
|
|
/* temperature */
|
|
|
|
PROP_TEMPERATURE = 43 | PROP_UNIT_TEMPERATURE,
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2013-08-30 15:24:16 +02:00
|
|
|
/* Make sure enums are updated with these */
|
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
|
|
|
/* HIGHEST FLAG IN USE: 1 << 31
|
2022-09-21 10:57:36 +02:00
|
|
|
* FREE FLAGS: 9, 11, 13, 14, 15. */
|
2023-11-14 09:51:41 +01:00
|
|
|
enum PropertyFlag {
|
2019-06-26 04:40:22 +02: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
|
2019-06-26 04:40:22 +02:00
|
|
|
* for pointers and collections.
|
|
|
|
*/
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_EDITABLE = (1 << 0),
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* This property is editable even if it is lib linked,
|
2009-07-24 18:41:12 +02:00
|
|
|
* meaning it will get lost on reload, but it's useful
|
2019-06-26 04:40:22 +02:00
|
|
|
* for editing.
|
|
|
|
*/
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_LIB_EXCEPTION = (1 << 16),
|
2019-06-26 04:40:22 +02: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
|
2019-06-26 04:40:22 +02:00
|
|
|
* and collections.
|
|
|
|
*/
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_ANIMATABLE = (1 << 1),
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
2020-03-22 02:09:48 +01:00
|
|
|
* This flag means when the property's widget is in 'text-edit' mode, it will be updated
|
|
|
|
* after every typed char, instead of waiting final validation. Used e.g. for text search-box.
|
2017-01-11 22:11:13 +01:00
|
|
|
* It will also cause UI_BUT_VALUE_CLEAR to be set for text buttons. We could add an own flag
|
2019-06-26 04:40:22 +02:00
|
|
|
* for search/filter properties, but this works just fine for now.
|
|
|
|
*/
|
2017-07-29 00:42:32 +02:00
|
|
|
PROP_TEXTEDIT_UPDATE = (1u << 31),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-06-16 02:52:21 +02:00
|
|
|
/* icon */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_ICONS_CONSECUTIVE = (1 << 12),
|
2018-10-29 16:58:34 +01:00
|
|
|
PROP_ICONS_REVERSE = (1 << 8),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-07-23 08:56:00 +02:00
|
|
|
/** Hidden in the user interface. */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_HIDDEN = (1 << 19),
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Do not write in presets. */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_SKIP_SAVE = (1 << 28),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-02-08 20:30:48 +01:00
|
|
|
/* numbers */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Each value is related proportionally (object scale, image size). */
|
2014-02-08 20:30:48 +01:00
|
|
|
PROP_PROPORTIONAL = (1 << 26),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-05-29 17:12:31 +02:00
|
|
|
/* pointers */
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_ID_REFCOUNT = (1 << 6),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
2022-01-24 05:34:56 +01:00
|
|
|
* Disallow assigning a variable to itself, eg an object tracking itself
|
2019-06-26 04:40:22 +02:00
|
|
|
* 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),
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* Use for...
|
2019-04-21 18:48:05 +02:00
|
|
|
* - pointers: in the UI and python so unsetting or setting to None won't work.
|
|
|
|
* - strings: so our internal generated get/length/set
|
2023-02-12 04:37:16 +01:00
|
|
|
* functions know to do NULL checks before access #30865.
|
2019-04-21 18:48:05 +02:00
|
|
|
*/
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_NEVER_NULL = (1 << 18),
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* Currently only used for UI, this is similar to PROP_NEVER_NULL
|
2010-12-30 13:22:28 +01:00
|
|
|
* except that the value may be NULL at times, used for ObData, where an Empty's will be NULL
|
2019-04-21 18:48:05 +02:00
|
|
|
* but setting NULL on a mesh object is not possible.
|
2021-06-22 19:42:32 +02:00
|
|
|
* So if it's not NULL, setting NULL can't be done!
|
2019-04-21 18:48:05 +02:00
|
|
|
*/
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_NEVER_UNLINK = (1 << 25),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* Pointers to data that is not owned by the struct.
|
2017-12-18 10:08:22 +01:00
|
|
|
* Typical example: Bone.parent, Bone.child, etc., and nearly all ID pointers.
|
2019-04-21 18:48:05 +02:00
|
|
|
* This is crucial information for processes that walk the whole data of an ID e.g.
|
2019-06-14 23:16:04 +02:00
|
|
|
* (like library override).
|
2019-04-21 18:48:05 +02:00
|
|
|
* Note that all ID pointers are enforced to this by default,
|
2022-01-06 03:54:52 +01:00
|
|
|
* this probably will need to be rechecked
|
|
|
|
* (see ugly infamous node-trees of material/texture/scene/etc.).
|
2019-04-21 18:48:05 +02:00
|
|
|
*/
|
2017-12-18 10:08:22 +01:00
|
|
|
PROP_PTR_NO_OWNERSHIP = (1 << 7),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* flag contains multiple enums.
|
2022-03-08 03:48:31 +01:00
|
|
|
* NOTE: not to be confused with `prop->enumbitflags`
|
2009-12-22 17:11:11 +01:00
|
|
|
* this exposes the flag as multiple options in python and the UI.
|
|
|
|
*
|
2019-06-26 04:40:22 +02:00
|
|
|
* \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),
|
2019-04-17 06:17:24 +02: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),
|
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
|
|
|
PROP_CONTEXT_PROPERTY_UPDATE = PROP_CONTEXT_UPDATE | (1 << 27),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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
|
|
|
/* registering */
|
|
|
|
PROP_REGISTER = (1 << 4),
|
|
|
|
PROP_REGISTER_OPTIONAL = PROP_REGISTER | (1 << 5),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
2019-08-02 05:12:07 +02:00
|
|
|
* Use for allocated function return values of arrays or strings
|
|
|
|
* for any data that should not have a reference kept.
|
|
|
|
*
|
|
|
|
* It can be used for properties which are dynamically allocated too.
|
|
|
|
*
|
|
|
|
* \note Currently dynamic sized thick wrapped data isn't supported.
|
|
|
|
* This would be a useful addition and avoid a fixed maximum sized as in done at the moment.
|
2019-06-26 04:40:22 +02:00
|
|
|
*/
|
2013-08-30 15:24:16 +02:00
|
|
|
PROP_THICK_WRAP = (1 << 23),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/** This is an IDProperty, not a DNA one. */
|
|
|
|
PROP_IDPROPERTY = (1 << 10),
|
2023-05-24 03:21:18 +02:00
|
|
|
/** For dynamic arrays & return values of type string. */
|
2019-06-26 04:40:22 +02:00
|
|
|
PROP_DYNAMIC = (1 << 17),
|
|
|
|
/** For enum that shouldn't be contextual */
|
|
|
|
PROP_ENUM_NO_CONTEXT = (1 << 24),
|
2023-05-24 03:21:18 +02:00
|
|
|
/** For enums not to be translated (e.g. view-layers' names in nodes). */
|
2019-06-26 04:40:22 +02:00
|
|
|
PROP_ENUM_NO_TRANSLATE = (1 << 29),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* Don't do dependency graph tag from a property update callback.
|
2019-04-01 10:22:06 +02:00
|
|
|
* Use this for properties which defines interface state, for example,
|
2019-06-26 04:40:22 +02:00
|
|
|
* properties which denotes whether modifier panel is collapsed or not.
|
|
|
|
*/
|
2019-04-01 10:22:06 +02:00
|
|
|
PROP_NO_DEG_UPDATE = (1 << 30),
|
2022-09-21 10:57:36 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filepaths that refer to output get a special treatment such
|
|
|
|
* as having the +/- operators available in the file browser.
|
|
|
|
**/
|
|
|
|
PROP_PATH_OUTPUT = (1 << 2),
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2023-07-28 22:41:42 +02:00
|
|
|
ENUM_OPERATORS(PropertyFlag, PROP_TEXTEDIT_UPDATE)
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* Flags related to comparing and overriding RNA properties.
|
|
|
|
* Make sure enums are updated with these.
|
|
|
|
*
|
|
|
|
* FREE FLAGS: 2, 3, 4, 5, 6, 7, 8, 9, 12 and above.
|
|
|
|
*/
|
2023-11-14 09:51:41 +01:00
|
|
|
enum PropertyOverrideFlag {
|
2022-02-03 17:57:40 +01:00
|
|
|
/** Means that the property can be overridden by a local override of some linked datablock. */
|
2019-06-14 23:16:04 +02:00
|
|
|
PROPOVERRIDE_OVERRIDABLE_LIBRARY = (1 << 0),
|
2018-06-05 11:10:05 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* Forbid usage of this property in comparison (& hence override) code.
|
|
|
|
* Useful e.g. for collections of data like mesh's geometry, particles, etc.
|
2020-02-19 16:07:21 +01:00
|
|
|
* Also for runtime data that should never be considered as part of actual Blend data (e.g.
|
2020-02-26 05:21:32 +01:00
|
|
|
* depsgraph from ViewLayers...).
|
2019-06-26 04:40:22 +02:00
|
|
|
*/
|
2018-06-05 11:10:05 +02:00
|
|
|
PROPOVERRIDE_NO_COMPARISON = (1 << 1),
|
|
|
|
|
2020-06-09 19:35:11 +02:00
|
|
|
/**
|
|
|
|
* Means the property can be fully ignored by override process.
|
|
|
|
* Unlike NO_COMPARISON, it can still be used by diffing code, but no override operation will be
|
|
|
|
* created for it, and no attempt to restore the data from linked reference either.
|
|
|
|
*
|
|
|
|
* WARNING: This flag should be used with a lot of caution, as it completely by-passes override
|
|
|
|
* system. It is currently only used for ID's names, since we cannot prevent local override to
|
|
|
|
* get a different name from the linked reference, and ID names are 'rna name property' (i.e. are
|
|
|
|
* used in overrides of collections of IDs). See also `BKE_lib_override_library_update()` where
|
|
|
|
* we deal manually with the value of that property at DNA level. */
|
|
|
|
PROPOVERRIDE_IGNORE = (1 << 2),
|
|
|
|
|
2018-06-05 11:10:05 +02:00
|
|
|
/*** Collections-related ***/
|
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/** The property supports insertion (collections only). */
|
2019-06-14 23:16:04 +02:00
|
|
|
PROPOVERRIDE_LIBRARY_INSERTION = (1 << 10),
|
2018-06-05 11:10:05 +02:00
|
|
|
|
2023-05-27 07:10:58 +02:00
|
|
|
/**
|
|
|
|
* Only use indices to compare items in the property, never names (collections only).
|
2019-06-26 04:40:22 +02:00
|
|
|
*
|
2023-08-12 08:29:51 +02:00
|
|
|
* Useful when #StructRNA::nameproperty of the items is generated from other data
|
2019-06-26 04:40:22 +02:00
|
|
|
* (e.g. name of material slots is actually name of assigned material).
|
|
|
|
*/
|
2018-06-05 11:58:56 +02:00
|
|
|
PROPOVERRIDE_NO_PROP_NAME = (1 << 11),
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2023-06-09 11:45:41 +02:00
|
|
|
ENUM_OPERATORS(PropertyOverrideFlag, PROPOVERRIDE_NO_PROP_NAME);
|
2018-06-05 11:10:05 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* Function parameters flags.
|
|
|
|
* \warning 16bits only.
|
|
|
|
*/
|
2023-11-14 09:51:41 +01:00
|
|
|
enum ParameterFlag {
|
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
|
|
|
PARM_REQUIRED = (1 << 0),
|
|
|
|
PARM_OUTPUT = (1 << 1),
|
|
|
|
PARM_RNAPTR = (1 << 2),
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* This allows for non-breaking API updates,
|
2019-04-21 18:48:05 +02:00
|
|
|
* when adding non-critical new parameter to a callback function.
|
2022-09-19 06:47:27 +02:00
|
|
|
* This way, old Python code defining functions without that parameter would still work.
|
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
|
|
|
* WARNING: any parameter after the first PYFUNC_OPTIONAL one will be considered as optional!
|
2019-06-26 04:40:22 +02:00
|
|
|
* \note only for input parameters!
|
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
|
|
|
*/
|
|
|
|
PARM_PYFUNC_OPTIONAL = (1 << 3),
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2023-05-25 16:30:16 +02:00
|
|
|
ENUM_OPERATORS(ParameterFlag, PARM_PYFUNC_OPTIONAL)
|
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
|
|
|
|
2014-04-05 14:36:18 +02:00
|
|
|
struct CollectionPropertyIterator;
|
|
|
|
struct Link;
|
2023-11-14 09:51:41 +01:00
|
|
|
typedef int (*IteratorSkipFunc)(CollectionPropertyIterator *iter, void *data);
|
2014-04-05 14:36:18 +02:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct ListBaseIterator {
|
|
|
|
Link *link;
|
2014-04-05 14:36:18 +02:00
|
|
|
int flag;
|
|
|
|
IteratorSkipFunc skip;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2014-04-05 14:36:18 +02:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct ArrayIterator {
|
2014-04-05 14:36:18 +02:00
|
|
|
char *ptr;
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Past the last valid pointer, only for comparisons, ignores skipped values. */
|
2019-04-21 18:48:05 +02:00
|
|
|
char *endptr;
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Will be freed if set. */
|
2019-04-21 18:48:05 +02:00
|
|
|
void *free_ptr;
|
2014-04-05 14:36:18 +02:00
|
|
|
int itemsize;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* Array length with no skip functions applied,
|
|
|
|
* take care not to compare against index from animsys or Python indices.
|
|
|
|
*/
|
2014-04-05 14:36:18 +02:00
|
|
|
int length;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* Optional skip function,
|
2019-04-21 18:48:05 +02:00
|
|
|
* when set the array as viewed by rna can contain only a subset of the members.
|
|
|
|
* this changes indices so quick array index lookups are not possible when skip function is used.
|
|
|
|
*/
|
2014-04-05 14:36:18 +02:00
|
|
|
IteratorSkipFunc skip;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2014-04-05 14:36:18 +02:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct CountIterator {
|
2020-03-17 14:41:48 +01:00
|
|
|
void *ptr;
|
|
|
|
int item;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2020-03-17 14:41:48 +01:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
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;
|
2023-11-14 09:51:41 +01:00
|
|
|
PropertyRNA *prop;
|
2014-04-05 14:36:18 +02:00
|
|
|
union {
|
|
|
|
ArrayIterator array;
|
|
|
|
ListBaseIterator listbase;
|
2020-03-17 14:41:48 +01:00
|
|
|
CountIterator count;
|
2017-04-21 12:31:48 +02:00
|
|
|
void *custom;
|
2014-04-05 14:36:18 +02:00
|
|
|
} 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;
|
2019-04-17 06:17:24 +02: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;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct CollectionPointerLink {
|
|
|
|
CollectionPointerLink *next, *prev;
|
2009-03-19 20:03:38 +01:00
|
|
|
PointerRNA ptr;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2009-03-19 20:03:38 +01:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Copy of ListBase for RNA. */
|
2023-11-14 09:51:41 +01:00
|
|
|
struct CollectionListBase {
|
|
|
|
CollectionPointerLink *first, *last;
|
|
|
|
};
|
2016-06-22 18:04:04 +02:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
enum RawPropertyType {
|
2012-05-12 13:01:29 +02:00
|
|
|
PROP_RAW_UNSET = -1,
|
2021-07-03 15:08:40 +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,
|
2018-07-01 15:47:09 +02:00
|
|
|
PROP_RAW_BOOLEAN,
|
2009-08-30 01:05:46 +02:00
|
|
|
PROP_RAW_DOUBLE,
|
2019-04-16 16:40:47 +02:00
|
|
|
PROP_RAW_FLOAT,
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
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
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct RawArray {
|
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
|
|
|
void *array;
|
|
|
|
RawPropertyType type;
|
|
|
|
int len;
|
|
|
|
int stride;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
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
|
|
|
|
2016-05-08 18:32:54 +02:00
|
|
|
/**
|
|
|
|
* This struct is are typically defined in arrays which define an *enum* for RNA,
|
|
|
|
* which is used by the RNA API both for user-interface and the Python API.
|
|
|
|
*/
|
2023-11-14 09:51:41 +01:00
|
|
|
struct EnumPropertyItem {
|
2016-05-08 18:32:54 +02:00
|
|
|
/** The internal value of the enum, not exposed to users. */
|
2008-11-01 00:50:02 +01:00
|
|
|
int value;
|
2016-05-08 18:32:54 +02:00
|
|
|
/**
|
|
|
|
* Note that identifiers must be unique within the array,
|
|
|
|
* by convention they're upper case with underscores for separators.
|
|
|
|
* - An empty string is used to define menu separators.
|
|
|
|
* - NULL denotes the end of the array of items.
|
|
|
|
*/
|
2008-11-14 19:46:57 +01:00
|
|
|
const char *identifier;
|
2016-05-08 18:32:54 +02:00
|
|
|
/** Optional icon, typically 'ICON_NONE' */
|
2009-06-16 02:52:21 +02:00
|
|
|
int icon;
|
2016-05-08 18:32:54 +02:00
|
|
|
/** Name displayed in the interface. */
|
2008-11-01 00:50:02 +01:00
|
|
|
const char *name;
|
2016-05-08 18:32:54 +02:00
|
|
|
/** Longer description used in the interface. */
|
2008-11-24 13:12:24 +01:00
|
|
|
const char *description;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2022-05-31 06:07:15 +02:00
|
|
|
/**
|
|
|
|
* Heading for RNA enum items (shown in the UI).
|
|
|
|
*
|
|
|
|
* The description is currently only shown in the Python documentation.
|
|
|
|
* By convention the value should be a non-empty string or NULL when there is no description
|
|
|
|
* (never an empty string).
|
|
|
|
*/
|
|
|
|
#define RNA_ENUM_ITEM_HEADING(name, description) \
|
|
|
|
{ \
|
|
|
|
0, "", 0, name, description \
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Separator for RNA enum items (shown in the UI). */
|
|
|
|
#define RNA_ENUM_ITEM_SEPR \
|
|
|
|
{ \
|
|
|
|
0, "", 0, NULL, NULL \
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Separator for RNA enum that begins a new column in menus (shown in the UI). */
|
|
|
|
#define RNA_ENUM_ITEM_SEPR_COLUMN RNA_ENUM_ITEM_HEADING("", NULL)
|
|
|
|
|
2013-01-05 15:56:37 +01:00
|
|
|
/* extended versions with PropertyRNA argument */
|
2023-11-14 09:51:41 +01:00
|
|
|
typedef bool (*BooleanPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop);
|
|
|
|
typedef void (*BooleanPropertySetFunc)(PointerRNA *ptr, PropertyRNA *prop, bool value);
|
|
|
|
typedef void (*BooleanArrayPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop, bool *values);
|
|
|
|
typedef void (*BooleanArrayPropertySetFunc)(PointerRNA *ptr,
|
|
|
|
PropertyRNA *prop,
|
2018-07-01 15:47:09 +02:00
|
|
|
const bool *values);
|
2023-11-14 09:51:41 +01:00
|
|
|
typedef int (*IntPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop);
|
|
|
|
typedef void (*IntPropertySetFunc)(PointerRNA *ptr, PropertyRNA *prop, int value);
|
|
|
|
typedef void (*IntArrayPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop, int *values);
|
|
|
|
typedef void (*IntArrayPropertySetFunc)(PointerRNA *ptr, PropertyRNA *prop, const int *values);
|
|
|
|
typedef void (*IntPropertyRangeFunc)(
|
|
|
|
PointerRNA *ptr, PropertyRNA *prop, int *min, int *max, int *softmin, int *softmax);
|
|
|
|
typedef float (*FloatPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop);
|
|
|
|
typedef void (*FloatPropertySetFunc)(PointerRNA *ptr, PropertyRNA *prop, float value);
|
|
|
|
typedef void (*FloatArrayPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop, float *values);
|
|
|
|
typedef void (*FloatArrayPropertySetFunc)(PointerRNA *ptr, PropertyRNA *prop, const float *values);
|
|
|
|
typedef void (*FloatPropertyRangeFunc)(
|
|
|
|
PointerRNA *ptr, PropertyRNA *prop, float *min, float *max, float *softmin, float *softmax);
|
|
|
|
typedef void (*StringPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop, char *value);
|
|
|
|
typedef int (*StringPropertyLengthFunc)(PointerRNA *ptr, PropertyRNA *prop);
|
|
|
|
typedef void (*StringPropertySetFunc)(PointerRNA *ptr, PropertyRNA *prop, const char *value);
|
|
|
|
|
|
|
|
struct StringPropertySearchVisitParams {
|
2022-05-20 06:30:17 +02:00
|
|
|
/** Text being searched for (never NULL). */
|
|
|
|
const char *text;
|
|
|
|
/** Additional information to display (optional, may be NULL). */
|
|
|
|
const char *info;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2022-05-20 06:30:17 +02:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
enum eStringPropertySearchFlag {
|
2022-05-20 06:30:17 +02:00
|
|
|
/**
|
|
|
|
* Used so the result of #RNA_property_string_search_flag can be used to check
|
|
|
|
* if search is supported.
|
|
|
|
*/
|
|
|
|
PROP_STRING_SEARCH_SUPPORTED = (1 << 0),
|
2023-10-19 09:53:16 +02:00
|
|
|
/** Items resulting from the search must be sorted. */
|
2022-05-20 06:30:17 +02:00
|
|
|
PROP_STRING_SEARCH_SORT = (1 << 1),
|
|
|
|
/**
|
|
|
|
* Allow members besides the ones listed to be entered.
|
|
|
|
*
|
|
|
|
* \warning disabling this options causes the search callback to run on redraw and should
|
|
|
|
* only be enabled this doesn't cause performance issues.
|
|
|
|
*/
|
|
|
|
PROP_STRING_SEARCH_SUGGESTION = (1 << 2),
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2023-07-01 16:38:46 +02:00
|
|
|
ENUM_OPERATORS(eStringPropertySearchFlag, PROP_STRING_SEARCH_SUGGESTION)
|
2022-05-20 06:30:17 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Visit string search candidates, `text` may be freed once this callback has finished,
|
|
|
|
* so references to it should not be held.
|
|
|
|
*/
|
|
|
|
typedef void (*StringPropertySearchVisitFunc)(void *visit_user_data,
|
|
|
|
const StringPropertySearchVisitParams *params);
|
|
|
|
/**
|
|
|
|
* \param C: context, may be NULL (in this case all available items should be shown).
|
|
|
|
* \param ptr: RNA pointer.
|
|
|
|
* \param prop: RNA property. This must have it's #StringPropertyRNA.search callback set,
|
|
|
|
* to check this use `RNA_property_string_search_flag(prop) & PROP_STRING_SEARCH_SUPPORTED`.
|
|
|
|
* \param edit_text: Optionally use the string being edited by the user as a basis
|
|
|
|
* for the search results (auto-complete Python attributes for e.g.).
|
|
|
|
* \param visit_fn: This function is called with every search candidate and is typically
|
|
|
|
* responsible for storing the search results.
|
|
|
|
* \param visit_user_data: Caller defined data, passed to `visit_fn`.
|
|
|
|
*/
|
2023-11-14 09:51:41 +01:00
|
|
|
typedef void (*StringPropertySearchFunc)(const bContext *C,
|
|
|
|
PointerRNA *ptr,
|
|
|
|
PropertyRNA *prop,
|
2022-05-20 06:30:17 +02:00
|
|
|
const char *edit_text,
|
|
|
|
StringPropertySearchVisitFunc visit_fn,
|
|
|
|
void *visit_user_data);
|
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
typedef int (*EnumPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop);
|
|
|
|
typedef void (*EnumPropertySetFunc)(PointerRNA *ptr, PropertyRNA *prop, int value);
|
2013-01-05 15:56:37 +01:00
|
|
|
/* same as PropEnumItemFunc */
|
2023-11-14 09:51:41 +01:00
|
|
|
typedef const EnumPropertyItem *(*EnumPropertyItemFunc)(bContext *C,
|
2017-10-18 06:07:26 +02:00
|
|
|
PointerRNA *ptr,
|
2023-11-14 09:51:41 +01:00
|
|
|
PropertyRNA *prop,
|
2017-10-18 06:07:26 +02:00
|
|
|
bool *r_free);
|
2009-07-08 17:34:41 +02:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct PropertyRNA;
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2009-04-07 02:49:39 +02:00
|
|
|
/* Parameter List */
|
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct ParameterList {
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Storage for parameters*. */
|
2009-07-17 04:31:28 +02:00
|
|
|
void *data;
|
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Function passed at creation time. */
|
2023-11-14 09:51:41 +01:00
|
|
|
FunctionRNA *func;
|
2011-10-03 03:36:25 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Store the parameter size. */
|
2010-03-23 16:04:06 +01:00
|
|
|
int alloc_size;
|
|
|
|
|
|
|
|
int arg_count, ret_count;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2009-04-07 02:49:39 +02:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct ParameterIterator {
|
|
|
|
ParameterList *parms;
|
2021-06-26 13:35:18 +02:00
|
|
|
// PointerRNA funcptr; /* UNUSED */
|
2009-04-07 02:49:39 +02:00
|
|
|
void *data;
|
|
|
|
int size, offset;
|
|
|
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
int valid;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2009-04-07 02:49:39 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Mainly to avoid confusing casts. */
|
2023-11-14 09:51:41 +01:00
|
|
|
struct ParameterDynAlloc {
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Important, this breaks when set to an int. */
|
|
|
|
intptr_t array_tot;
|
2010-08-31 13:31:21 +02:00
|
|
|
void *array;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2010-08-31 13:31:21 +02:00
|
|
|
|
2009-04-07 02:49:39 +02:00
|
|
|
/* Function */
|
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* Options affecting callback signature.
|
|
|
|
*
|
|
|
|
* Those add additional parameters at the beginning of the C callback, like that:
|
|
|
|
* <pre>
|
|
|
|
* rna_my_func([ID *_selfid],
|
|
|
|
* [<DNA_STRUCT> *self|StructRNA *type],
|
|
|
|
* [Main *bmain],
|
|
|
|
* [bContext *C],
|
|
|
|
* [ReportList *reports],
|
|
|
|
* <other RNA-defined parameters>);
|
|
|
|
* </pre>
|
|
|
|
*/
|
2023-11-14 09:51:41 +01:00
|
|
|
enum FunctionFlag {
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* Pass ID owning 'self' data
|
2019-08-23 09:52:12 +02:00
|
|
|
* (i.e. ptr->owner_id, might be same as self in case data is an ID...).
|
2018-02-09 12:04:29 +01:00
|
|
|
*/
|
|
|
|
FUNC_USE_SELF_ID = (1 << 11),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* Do not pass the object (DNA struct pointer) from which it is called,
|
|
|
|
* used to define static or class functions.
|
|
|
|
*/
|
2018-02-09 12:04:29 +01:00
|
|
|
FUNC_NO_SELF = (1 << 0),
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Pass RNA type, used to define class functions, only valid when #FUNC_NO_SELF is set. */
|
2018-02-09 12:04:29 +01:00
|
|
|
FUNC_USE_SELF_TYPE = (1 << 1),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-02-09 12:04:29 +01:00
|
|
|
/* Pass Main, bContext and/or ReportList. */
|
2013-08-30 15:24:16 +02:00
|
|
|
FUNC_USE_MAIN = (1 << 2),
|
|
|
|
FUNC_USE_CONTEXT = (1 << 3),
|
|
|
|
FUNC_USE_REPORTS = (1 << 4),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/***** Registering of Python subclasses. *****/
|
|
|
|
/**
|
|
|
|
* This function is part of the registerable class' interface,
|
|
|
|
* and can be implemented/redefined in Python.
|
|
|
|
*/
|
2013-08-30 15:24:16 +02:00
|
|
|
FUNC_REGISTER = (1 << 5),
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Subclasses can choose not to implement this function. */
|
2013-08-30 15:24:16 +02:00
|
|
|
FUNC_REGISTER_OPTIONAL = FUNC_REGISTER | (1 << 6),
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* If not set, the Python function implementing this call
|
2019-04-21 18:48:05 +02:00
|
|
|
* is not allowed to write into data-blocks.
|
2023-07-31 03:50:54 +02:00
|
|
|
* Except for WindowManager and Screen currently, see rna_id_write_error() in `bpy_rna.cc`.
|
2019-06-26 04:40:22 +02:00
|
|
|
*/
|
2018-02-09 12:04:29 +01:00
|
|
|
FUNC_ALLOW_WRITE = (1 << 12),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-02-09 12:04:29 +01:00
|
|
|
/***** Internal flags. *****/
|
2019-06-26 04:40:22 +02:00
|
|
|
/** UNUSED CURRENTLY? ??? */
|
2013-08-30 15:24:16 +02:00
|
|
|
FUNC_BUILTIN = (1 << 7),
|
2019-06-26 04:40:22 +02:00
|
|
|
/** UNUSED CURRENTLY. ??? */
|
2013-08-30 15:24:16 +02:00
|
|
|
FUNC_EXPORT = (1 << 8),
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Function has been defined at runtime, not statically in RNA source code. */
|
2013-08-30 15:24:16 +02:00
|
|
|
FUNC_RUNTIME = (1 << 9),
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* UNUSED CURRENTLY? Function owns its identifier and description strings,
|
|
|
|
* and has to free them when deleted.
|
|
|
|
*/
|
2013-08-30 15:24:16 +02:00
|
|
|
FUNC_FREE_POINTERS = (1 << 10),
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2009-04-07 02:49:39 +02:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
typedef void (*CallFunc)(bContext *C, ReportList *reports, PointerRNA *ptr, ParameterList *parms);
|
2009-04-07 02:49:39 +02:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct FunctionRNA;
|
2009-04-07 02:49:39 +02:00
|
|
|
|
2008-11-07 03:58:25 +01:00
|
|
|
/* Struct */
|
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
enum StructFlag {
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Indicates that this struct is an ID struct, and to use reference-counting. */
|
2013-08-30 15:24:16 +02:00
|
|
|
STRUCT_ID = (1 << 0),
|
|
|
|
STRUCT_ID_REFCOUNT = (1 << 1),
|
2021-03-30 21:10:58 +02:00
|
|
|
/** defaults on, indicates when changes in members of a StructRNA should trigger undo steps. */
|
2019-06-26 04:40:22 +02:00
|
|
|
STRUCT_UNDO = (1 << 2),
|
2019-04-17 06:17:24 +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 03:23:46 +01:00
|
|
|
/* internal flags */
|
2013-08-30 15:24:16 +02:00
|
|
|
STRUCT_RUNTIME = (1 << 3),
|
2020-02-20 00:21:23 +01:00
|
|
|
/* STRUCT_GENERATED = (1 << 4), */ /* UNUSED */
|
2013-08-30 15:24:16 +02:00
|
|
|
STRUCT_FREE_POINTERS = (1 << 5),
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Menus and Panels don't need properties */
|
|
|
|
STRUCT_NO_IDPROPERTIES = (1 << 6),
|
|
|
|
/** e.g. for Operator */
|
|
|
|
STRUCT_NO_DATABLOCK_IDPROPERTIES = (1 << 7),
|
|
|
|
/** for PropertyGroup which contains pointers to datablocks */
|
|
|
|
STRUCT_CONTAINS_DATABLOCK_IDPROPERTIES = (1 << 8),
|
|
|
|
/** Added to type-map #BlenderRNA.structs_map */
|
|
|
|
STRUCT_PUBLIC_NAMESPACE = (1 << 9),
|
2022-09-16 10:13:19 +02:00
|
|
|
/** All sub-types are added too. */
|
2019-06-26 04:40:22 +02:00
|
|
|
STRUCT_PUBLIC_NAMESPACE_INHERIT = (1 << 10),
|
2021-04-16 07:04:37 +02:00
|
|
|
/**
|
|
|
|
* When the #PointerRNA.owner_id is NULL, this signifies the property should be accessed
|
|
|
|
* without any context (the key-map UI and import/export for example).
|
|
|
|
* So accessing the property should not read from the current context to derive values/limits.
|
|
|
|
*/
|
|
|
|
STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID = (1 << 11),
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2008-11-07 03:58:25 +01:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
typedef int (*StructValidateFunc)(PointerRNA *ptr, void *data, bool *have_function);
|
|
|
|
typedef int (*StructCallbackFunc)(bContext *C,
|
|
|
|
PointerRNA *ptr,
|
|
|
|
FunctionRNA *func,
|
2010-12-07 05:12:15 +01:00
|
|
|
ParameterList *list);
|
2009-04-19 15:37:59 +02:00
|
|
|
typedef void (*StructFreeFunc)(void *data);
|
2023-11-14 09:51:41 +01:00
|
|
|
typedef StructRNA *(*StructRegisterFunc)(Main *bmain,
|
|
|
|
ReportList *reports,
|
|
|
|
void *data,
|
|
|
|
const char *identifier,
|
|
|
|
StructValidateFunc validate,
|
|
|
|
StructCallbackFunc call,
|
|
|
|
StructFreeFunc free);
|
2023-02-28 03:38:50 +01:00
|
|
|
/** Return true when `type` was successfully unregistered & freed. */
|
2023-11-14 09:51:41 +01:00
|
|
|
typedef bool (*StructUnregisterFunc)(Main *bmain, StructRNA *type);
|
2011-05-18 13:21:10 +02:00
|
|
|
typedef void **(*StructInstanceFunc)(PointerRNA *ptr);
|
2009-04-19 15:37:59 +02:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct StructRNA;
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* Blender RNA
|
2008-11-07 03:58:25 +01:00
|
|
|
*
|
2019-06-26 04:40:22 +02:00
|
|
|
* Root RNA data structure that lists all struct types.
|
|
|
|
*/
|
2023-11-14 09:51:41 +01:00
|
|
|
struct BlenderRNA;
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/**
|
|
|
|
* Extending
|
2009-07-21 22:05:16 +02:00
|
|
|
*
|
|
|
|
* This struct must be embedded in *Type structs in
|
2019-06-26 04:40:22 +02:00
|
|
|
* order to make them definable through RNA.
|
|
|
|
*/
|
2023-11-14 09:51:41 +01:00
|
|
|
struct ExtensionRNA {
|
2009-07-21 22:05:16 +02:00
|
|
|
void *data;
|
|
|
|
StructRNA *srna;
|
2010-12-07 05:12:15 +01:00
|
|
|
StructCallbackFunc call;
|
|
|
|
StructFreeFunc free;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2009-07-21 22:05:16 +02:00
|
|
|
|
2023-03-09 00:46:49 +01:00
|
|
|
/* Primitive types. */
|
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct PrimitiveStringRNA {
|
2023-03-09 00:46:49 +01:00
|
|
|
const char *value;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2023-03-09 00:46:49 +01:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct PrimitiveIntRNA {
|
2023-03-09 00:46:49 +01:00
|
|
|
int value;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2023-03-09 00:46:49 +01:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct PrimitiveFloatRNA {
|
2023-03-09 00:46:49 +01:00
|
|
|
float value;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2023-03-09 00:46:49 +01:00
|
|
|
|
2023-11-14 09:51:41 +01:00
|
|
|
struct PrimitiveBooleanRNA {
|
2023-03-09 00:46:49 +01:00
|
|
|
bool value;
|
2023-11-14 09:51:41 +01:00
|
|
|
};
|
2023-03-09 00:46:49 +01:00
|
|
|
|
2012-02-17 19:59:41 +01:00
|
|
|
#endif /* __RNA_TYPES_H__ */
|