diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-04-19 17:37:59 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-04-19 17:37:59 +0400 |
commit | adff6aeb1c749183921c0facd373972bbeb874b4 (patch) | |
tree | 07987d408713eee8a3dd8bb5cb4ecf3c112de654 /source/blender/editors/animation | |
parent | d880257d165888638b7c924fb6ef7071343b783e (diff) |
RNA: Generic Type Registration
The Python API to define Panels and Operators is based on subclassing,
this makes that system more generic, and based on RNA. Hopefully that
will make it easy to make various parts of Blender more extensible.
* The system simply uses RNA properties and functions and marks them
with REGISTER to make them part of the type registration process.
Additionally, the struct must provide a register/unregister callback
to create/free the PanelType or similar.
* From the python side there were some small changes, mainly that
registration now goes trough bpy.types.register instead of
bpy.ui.addPanel.
* Only Panels have been wrapped this way now. Check rna_ui.c to see
how this code works. There's still some rough edges and possibilities
to make it cleaner, though it works without any manual python code.
* Started some docs here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/RNATypeRegistration
* Also changed some RNA_property and RNA_struct functions to not
require a PointerRNA anymore, where they were not required (which
is actually the cause of most changed files).
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r-- | source/blender/editors/animation/anim_ipo_utils.c | 12 | ||||
-rw-r--r-- | source/blender/editors/animation/drivers.c | 4 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 22 | ||||
-rw-r--r-- | source/blender/editors/animation/keyingsets.c | 4 |
4 files changed, 21 insertions, 21 deletions
diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index ae0b8435635..4d4079a260a 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -135,19 +135,19 @@ void getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* for structname, we use a custom name if one is available */ // xxx we might want an icon from types? // xxx it is hard to differentiate between object and bone channels then, if ob + bone motion occur together... - nameprop= RNA_struct_name_property(&ptr); + nameprop= RNA_struct_name_property(ptr.type); if (nameprop) { /* this gets a string which will need to be freed */ structname= RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0); } else - structname= (char *)RNA_struct_ui_name(&ptr); + structname= (char *)RNA_struct_ui_name(ptr.type); /* Property Name is straightforward */ - propname= (char *)RNA_property_ui_name(&ptr, prop); + propname= (char *)RNA_property_ui_name(prop); /* Array Index - only if applicable */ - if (RNA_property_array_length(&ptr, prop)) { + if (RNA_property_array_length(prop)) { // XXX the format of these is not final... we don't know how this will go yet // format 1 style //static char *vectoritem[4]= {".X", ".Y", ".Z", ".W"}; @@ -158,8 +158,8 @@ void getname_anim_fcurve(char *name, ID *id, FCurve *fcu) static char *quatitem[4]= {"W ", "X ", "Y ", "Z "}; static char *coloritem[4]= {"R ", "G ", "B ", "A "}; - int tot= RNA_property_array_length(&ptr, prop); - int propsubtype= RNA_property_subtype(&ptr, prop); + int tot= RNA_property_array_length(prop); + int propsubtype= RNA_property_subtype(prop); /* get string to use for array index */ if ((tot == 4) && (propsubtype == PROP_ROTATION)) diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index ef8ac517e54..9c401289011 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -183,7 +183,7 @@ static int add_driver_button_exec (bContext *C, wmOperator *op) if (path) { if (all) { - length= RNA_property_array_length(&ptr, prop); + length= RNA_property_array_length(prop); if (length) index= 0; else length= 1; @@ -245,7 +245,7 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op) if (path) { if (all) { - length= RNA_property_array_length(&ptr, prop); + length= RNA_property_array_length(prop); if(length) index= 0; else length= 1; diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 0a911f2281a..c341e32db8c 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -473,21 +473,21 @@ static float setting_get_rna_value (PointerRNA *ptr, PropertyRNA *prop, int inde { float value= 0.0f; - switch (RNA_property_type(ptr, prop)) { + switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(ptr, prop)) + if (RNA_property_array_length(prop)) value= (float)RNA_property_boolean_get_index(ptr, prop, index); else value= (float)RNA_property_boolean_get(ptr, prop); break; case PROP_INT: - if (RNA_property_array_length(ptr, prop)) + if (RNA_property_array_length(prop)) value= (float)RNA_property_int_get_index(ptr, prop, index); else value= (float)RNA_property_int_get(ptr, prop); break; case PROP_FLOAT: - if (RNA_property_array_length(ptr, prop)) + if (RNA_property_array_length(prop)) value= RNA_property_float_get_index(ptr, prop, index); else value= RNA_property_float_get(ptr, prop); @@ -538,14 +538,14 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) Object *ob= (Object *)ptr->data; con= ob->constraints.first; - identifier= (char *)RNA_property_identifier(ptr, prop); + identifier= (char *)RNA_property_identifier(prop); } else if (ptr->type == &RNA_PoseChannel) { /* Pose Channel */ bPoseChannel *pchan= (bPoseChannel *)ptr->data; con= pchan->constraints.first; - identifier= (char *)RNA_property_identifier(ptr, prop); + identifier= (char *)RNA_property_identifier(prop); } /* check if any data to search using */ @@ -624,7 +624,7 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) */ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_index) { - char *identifier= (char *)RNA_property_identifier(ptr, prop); + char *identifier= (char *)RNA_property_identifier(prop); /* handle for Objects or PoseChannels only * - constraints can be on either Objects or PoseChannels, so we only check if the @@ -726,7 +726,7 @@ short insert_keyframe (ID *id, bAction *act, const char group[], const char rna_ float curval= 0.0f; /* set additional flags for the F-Curve (i.e. only integer values) */ - if (RNA_property_type(&ptr, prop) != PROP_FLOAT) + if (RNA_property_type(prop) != PROP_FLOAT) fcu->flag |= FCURVE_INT_VALUES; /* apply special time tweaking */ @@ -1201,12 +1201,12 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) memset(&ptr, 0, sizeof(PointerRNA)); uiAnimContextProperty(C, &ptr, &prop, &index); - if(ptr.data && prop && RNA_property_animateable(ptr.data, prop)) { + if(ptr.data && prop && RNA_property_animateable(&ptr, prop)) { path= RNA_path_from_ID_to_property(&ptr, prop); if(path) { if(all) { - length= RNA_property_array_length(&ptr, prop); + length= RNA_property_array_length(prop); if(length) index= 0; else length= 1; @@ -1270,7 +1270,7 @@ static int delete_key_button_exec (bContext *C, wmOperator *op) if(path) { if(all) { - length= RNA_property_array_length(&ptr, prop); + length= RNA_property_array_length(prop); if(length) index= 0; else length= 1; diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index adc0b744d53..0f5cef51bdb 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -1031,7 +1031,7 @@ int modify_keyframes (bContext *C, ListBase *dsources, bAction *act, KeyingSet * RNA_id_pointer_create(ksp->id, &id_ptr); if (RNA_path_resolve(&id_ptr, ksp->rna_path, &ptr, &prop) && prop) - arraylen= RNA_property_array_length(&ptr, prop); + arraylen= RNA_property_array_length(prop); } /* for each possible index, perform operation @@ -1133,7 +1133,7 @@ int modify_keyframes (bContext *C, ListBase *dsources, bAction *act, KeyingSet * RNA_id_pointer_create(cks->id, &id_ptr); if (RNA_path_resolve(&id_ptr, path, &ptr, &prop) && prop) - arraylen= RNA_property_array_length(&ptr, prop); + arraylen= RNA_property_array_length(prop); } /* for each possible index, perform operation |