2008-11-14 14:34:19 +00:00
|
|
|
/**
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** 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,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation (2008).
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2009-01-08 13:57:29 +00:00
|
|
|
#include "DNA_ID.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
2008-11-14 14:34:19 +00:00
|
|
|
#include "RNA_define.h"
|
|
|
|
#include "RNA_types.h"
|
|
|
|
|
2009-06-03 23:16:51 +00:00
|
|
|
#include "rna_internal.h"
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
|
2009-06-19 23:05:21 +00:00
|
|
|
#include "BLI_ghash.h"
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
/* Struct */
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_Struct_identifier_get(PointerRNA *ptr, char *value)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-14 18:46:57 +00:00
|
|
|
strcpy(value, ((StructRNA*)ptr->data)->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Struct_identifier_length(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-14 18:46:57 +00:00
|
|
|
return strlen(((StructRNA*)ptr->data)->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-12-19 04:06:24 +00:00
|
|
|
static void rna_Struct_description_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
|
|
|
strcpy(value, ((StructRNA*)ptr->data)->description);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_Struct_description_length(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return strlen(((StructRNA*)ptr->data)->description);
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_Struct_name_get(PointerRNA *ptr, char *value)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
|
|
|
strcpy(value, ((StructRNA*)ptr->data)->name);
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Struct_name_length(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
|
|
|
return strlen(((StructRNA*)ptr->data)->name);
|
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_Struct_base_get(PointerRNA *ptr)
|
2008-12-15 13:46:50 +00:00
|
|
|
{
|
2009-02-02 19:57:57 +00:00
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((StructRNA*)ptr->data)->base);
|
2008-12-15 13:46:50 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_Struct_nested_get(PointerRNA *ptr)
|
2009-01-09 16:08:47 +00:00
|
|
|
{
|
2009-02-02 19:57:57 +00:00
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((StructRNA*)ptr->data)->nested);
|
2009-01-09 16:08:47 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_Struct_name_property_get(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2009-02-02 19:57:57 +00:00
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_Property, ((StructRNA*)ptr->data)->nameproperty);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
/* Struct property iteration. This is quite complicated, the purpose is to
|
|
|
|
* iterate over properties of all inheritance levels, and for each struct to
|
|
|
|
* also iterator over id properties not known by RNA. */
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
static int rna_idproperty_known(CollectionPropertyIterator *iter, void *data)
|
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 02:23:46 +00:00
|
|
|
{
|
2008-11-24 12:12:24 +00:00
|
|
|
IDProperty *idprop= (IDProperty*)data;
|
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 02:23:46 +00:00
|
|
|
PropertyRNA *prop;
|
2009-05-20 09:17:21 +00:00
|
|
|
StructRNA *ptype= iter->builtin_parent.type;
|
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 02:23:46 +00:00
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
/* function to skip any id properties that are already known by RNA,
|
|
|
|
* for the second loop where we go over unknown id properties */
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
for(prop= ptype->cont.properties.first; prop; prop=prop->next)
|
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 02:23:46 +00:00
|
|
|
if(strcmp(prop->identifier, idprop->name) == 0)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
static int rna_property_builtin(CollectionPropertyIterator *iter, void *data)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)data;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
/* function to skip builtin rna properties */
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
return (prop->flag & PROP_BUILTIN);
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
static int rna_function_builtin(CollectionPropertyIterator *iter, void *data)
|
|
|
|
{
|
|
|
|
FunctionRNA *func= (FunctionRNA*)data;
|
|
|
|
|
|
|
|
/* function to skip builtin rna functions */
|
|
|
|
|
|
|
|
return (func->flag & FUNC_BUILTIN);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_inheritance_next_level_restart(CollectionPropertyIterator *iter, IteratorSkipFunc skip, int funcs)
|
2009-02-02 19:57:57 +00:00
|
|
|
{
|
|
|
|
/* RNA struct inheritance */
|
|
|
|
while(!iter->valid && iter->level > 0) {
|
|
|
|
StructRNA *srna;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
srna= (StructRNA*)iter->parent.data;
|
|
|
|
iter->level--;
|
|
|
|
for(i=iter->level; i>0; i--)
|
|
|
|
srna= srna->base;
|
|
|
|
|
|
|
|
rna_iterator_listbase_end(iter);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
if (funcs)
|
|
|
|
rna_iterator_listbase_begin(iter, &srna->functions, skip);
|
|
|
|
else
|
|
|
|
rna_iterator_listbase_begin(iter, &srna->cont.properties, skip);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
static void rna_inheritance_properties_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb, IteratorSkipFunc skip)
|
|
|
|
{
|
|
|
|
rna_iterator_listbase_begin(iter, lb, skip);
|
|
|
|
rna_inheritance_next_level_restart(iter, skip, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_inheritance_properties_listbase_next(CollectionPropertyIterator *iter, IteratorSkipFunc skip)
|
|
|
|
{
|
|
|
|
rna_iterator_listbase_next(iter);
|
|
|
|
rna_inheritance_next_level_restart(iter, skip, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_inheritance_functions_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb, IteratorSkipFunc skip)
|
2009-02-02 19:57:57 +00:00
|
|
|
{
|
|
|
|
rna_iterator_listbase_begin(iter, lb, skip);
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_inheritance_next_level_restart(iter, skip, 1);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
static void rna_inheritance_functions_listbase_next(CollectionPropertyIterator *iter, IteratorSkipFunc skip)
|
2009-02-02 19:57:57 +00:00
|
|
|
{
|
|
|
|
rna_iterator_listbase_next(iter);
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_inheritance_next_level_restart(iter, skip, 1);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_Struct_properties_next(CollectionPropertyIterator *iter)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
ListBaseIterator *internal= iter->internal;
|
|
|
|
IDProperty *group;
|
|
|
|
|
|
|
|
if(internal->flag) {
|
|
|
|
/* id properties */
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_next(iter);
|
2008-11-17 18:44:06 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* regular properties */
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_inheritance_properties_listbase_next(iter, rna_property_builtin);
|
2008-11-17 18:44:06 +00:00
|
|
|
|
|
|
|
/* try id properties */
|
|
|
|
if(!iter->valid) {
|
2009-05-20 09:52:02 +00:00
|
|
|
group= RNA_struct_idproperties(&iter->builtin_parent, 0);
|
2008-11-17 18:44:06 +00:00
|
|
|
|
|
|
|
if(group) {
|
|
|
|
rna_iterator_listbase_end(iter);
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &group->data.group, rna_idproperty_known);
|
2008-11-17 18:44:06 +00:00
|
|
|
internal= iter->internal;
|
|
|
|
internal->flag= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_Struct_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2009-02-02 19:57:57 +00:00
|
|
|
StructRNA *srna;
|
|
|
|
|
|
|
|
/* here ptr->data should always be the same as iter->parent.type */
|
|
|
|
srna= (StructRNA *)ptr->data;
|
|
|
|
|
|
|
|
while(srna->base) {
|
|
|
|
iter->level++;
|
|
|
|
srna= srna->base;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_inheritance_properties_listbase_begin(iter, &srna->cont.properties, rna_property_builtin);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_Struct_properties_get(CollectionPropertyIterator *iter)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
ListBaseIterator *internal= iter->internal;
|
|
|
|
|
|
|
|
/* we return either PropertyRNA* or IDProperty*, the rna_access.c
|
|
|
|
* functions can handle both as PropertyRNA* with some tricks */
|
2009-02-02 19:57:57 +00:00
|
|
|
return rna_pointer_inherit_refine(&iter->parent, &RNA_Property, internal->link);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
static void rna_Struct_functions_next(CollectionPropertyIterator *iter)
|
|
|
|
{
|
|
|
|
rna_inheritance_functions_listbase_next(iter, rna_function_builtin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Struct_functions_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
|
|
|
|
|
|
|
/* here ptr->data should always be the same as iter->parent.type */
|
|
|
|
srna= (StructRNA *)ptr->data;
|
|
|
|
|
|
|
|
while(srna->base) {
|
|
|
|
iter->level++;
|
|
|
|
srna= srna->base;
|
|
|
|
}
|
|
|
|
|
|
|
|
rna_inheritance_functions_listbase_begin(iter, &srna->functions, rna_function_builtin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PointerRNA rna_Struct_functions_get(CollectionPropertyIterator *iter)
|
|
|
|
{
|
|
|
|
ListBaseIterator *internal= iter->internal;
|
|
|
|
|
|
|
|
/* we return either PropertyRNA* or IDProperty*, the rna_access.c
|
|
|
|
* functions can handle both as PropertyRNA* with some tricks */
|
|
|
|
return rna_pointer_inherit_refine(&iter->parent, &RNA_Function, internal->link);
|
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
/* Builtin properties iterator re-uses the Struct properties iterator, only
|
2009-05-20 09:17:21 +00:00
|
|
|
* difference is that we need to set the ptr data to the type of the struct
|
2009-02-02 19:57:57 +00:00
|
|
|
* whose properties we want to iterate over. */
|
|
|
|
|
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 02:23:46 +00:00
|
|
|
void rna_builtin_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
|
|
|
PointerRNA newptr;
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
/* we create a new pointer with the type as the data */
|
2008-11-14 18:46:57 +00:00
|
|
|
newptr.type= &RNA_Struct;
|
2008-11-14 14:34:19 +00:00
|
|
|
newptr.data= ptr->type;
|
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
if(ptr->type->flag & STRUCT_ID)
|
2008-11-14 14:34:19 +00:00
|
|
|
newptr.id.data= ptr->data;
|
2009-03-19 19:03:38 +00:00
|
|
|
else
|
2008-11-14 14:34:19 +00:00
|
|
|
newptr.id.data= NULL;
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
iter->parent= newptr;
|
2009-05-20 09:17:21 +00:00
|
|
|
iter->builtin_parent = *ptr;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_Struct_properties_begin(iter, &newptr);
|
2008-11-14 14:34:19 +00: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 02:23:46 +00:00
|
|
|
void rna_builtin_properties_next(CollectionPropertyIterator *iter)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_Struct_properties_next(iter);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
PointerRNA rna_builtin_properties_get(CollectionPropertyIterator *iter)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-14 18:46:57 +00:00
|
|
|
return rna_Struct_properties_get(iter);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2009-06-19 23:05:21 +00:00
|
|
|
PointerRNA rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
PointerRNA propptr;
|
|
|
|
|
|
|
|
memset(&propptr, 0, sizeof(propptr));
|
|
|
|
srna= ptr->type;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if(srna->cont.prophash) {
|
|
|
|
prop= BLI_ghash_lookup(srna->cont.prophash, (void*)key);
|
|
|
|
|
|
|
|
if(prop) {
|
|
|
|
propptr.type= &RNA_Property;
|
|
|
|
propptr.data= prop;
|
|
|
|
return propptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(prop=srna->cont.properties.first; prop; prop=prop->next) {
|
|
|
|
if(!(prop->flag & PROP_BUILTIN) && strcmp(prop->identifier, key)==0) {
|
|
|
|
propptr.type= &RNA_Property;
|
|
|
|
propptr.data= prop;
|
|
|
|
return propptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while((srna=srna->base));
|
|
|
|
|
2009-11-18 10:59:17 +00:00
|
|
|
/* this was used pre 2.5beta0, now ID property access uses python's
|
|
|
|
* getitem style access
|
|
|
|
* - ob["foo"] rather then ob.foo */
|
|
|
|
#if 0
|
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 19:15:51 +00:00
|
|
|
if(ptr->data) {
|
2009-11-18 10:59:17 +00:00
|
|
|
IDProperty *group, *idp;
|
|
|
|
|
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 19:15:51 +00:00
|
|
|
group= RNA_struct_idproperties(ptr, 0);
|
|
|
|
|
|
|
|
if(group) {
|
|
|
|
for(idp=group->data.group.first; idp; idp=idp->next) {
|
|
|
|
if(strcmp(idp->name, key) == 0) {
|
|
|
|
propptr.type= &RNA_Property;
|
|
|
|
propptr.data= idp;
|
|
|
|
return propptr;
|
|
|
|
}
|
2009-06-19 23:05:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-11-18 10:59:17 +00:00
|
|
|
#endif
|
2009-06-19 23:05:21 +00:00
|
|
|
return propptr;
|
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
PointerRNA rna_builtin_type_get(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2009-02-02 19:57:57 +00:00
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ptr->type);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Property */
|
|
|
|
|
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 02:23:46 +00:00
|
|
|
static StructRNA *rna_Property_refine(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
|
|
|
|
rna_idproperty_check(&prop, ptr); /* XXX ptr? */
|
|
|
|
|
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_BOOLEAN: return &RNA_BooleanProperty;
|
|
|
|
case PROP_INT: return &RNA_IntProperty;
|
|
|
|
case PROP_FLOAT: return &RNA_FloatProperty;
|
|
|
|
case PROP_STRING: return &RNA_StringProperty;
|
|
|
|
case PROP_ENUM: return &RNA_EnumProperty;
|
|
|
|
case PROP_POINTER: return &RNA_PointerProperty;
|
|
|
|
case PROP_COLLECTION: return &RNA_CollectionProperty;
|
|
|
|
default: return &RNA_Property;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_Property_identifier_get(PointerRNA *ptr, char *value)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
strcpy(value, ((PropertyRNA*)prop)->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Property_identifier_length(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return strlen(prop->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_Property_name_get(PointerRNA *ptr, char *value)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
strcpy(value, prop->name);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Property_name_length(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return strlen(prop->name);
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_Property_description_get(PointerRNA *ptr, char *value)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2009-10-14 18:48:19 +00:00
|
|
|
strcpy(value, prop->description ? prop->description:"");
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Property_description_length(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2009-10-14 18:48:19 +00:00
|
|
|
return prop->description ? strlen(prop->description) : 0;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Property_type_get(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return prop->type;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Property_subtype_get(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return prop->subtype;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2009-11-13 17:42:44 +00:00
|
|
|
static PointerRNA rna_Property_srna_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_Struct, prop->srna);
|
|
|
|
}
|
|
|
|
|
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 21:31:05 +00:00
|
|
|
static int rna_Property_unit_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
return RNA_SUBTYPE_UNIT(prop->subtype);
|
|
|
|
}
|
|
|
|
|
2009-12-25 14:42:00 +00:00
|
|
|
static int rna_Property_readonly_get(PointerRNA *ptr)
|
2008-12-19 04:06:24 +00:00
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
2009-11-23 23:17:23 +00:00
|
|
|
|
|
|
|
/* dont use this becaure it will call functions that check the internal
|
|
|
|
* data for introspection we only need to know if it can be edited so the
|
|
|
|
* flag is better for this */
|
|
|
|
// return RNA_property_editable(ptr, prop);
|
2009-12-25 14:42:00 +00:00
|
|
|
return prop->flag & PROP_EDITABLE ? 0:1;
|
2008-12-19 04:06:24 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 15:46:09 +00:00
|
|
|
static int rna_Property_use_return_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
return prop->flag & PROP_RETURN ? 1:0;
|
|
|
|
}
|
|
|
|
|
2009-12-25 14:42:00 +00:00
|
|
|
static int rna_Property_is_required_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
return prop->flag & PROP_REQUIRED ? 1:0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_Property_is_never_none_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
return prop->flag & PROP_NEVER_NULL ? 1:0;
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_Property_array_length_get(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2009-09-09 19:40:46 +00:00
|
|
|
return prop->totarraylength;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2009-04-19 13:37:59 +00:00
|
|
|
static int rna_Property_registered_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
return prop->flag & PROP_REGISTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_Property_registered_optional_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
return prop->flag & PROP_REGISTER_OPTIONAL;
|
|
|
|
}
|
|
|
|
|
2009-07-26 18:18:14 +00:00
|
|
|
static int rna_BoolProperty_default_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
return ((BooleanPropertyRNA*)prop)->defaultvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_IntProperty_default_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
return ((IntPropertyRNA*)prop)->defaultvalue;
|
|
|
|
}
|
2009-09-15 10:01:20 +00:00
|
|
|
/* int/float/bool */
|
|
|
|
static int rna_NumberProperty_default_array_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
|
|
|
|
length[0]= prop->totarraylength;
|
|
|
|
|
|
|
|
return length[0];
|
|
|
|
}
|
|
|
|
static void rna_IntProperty_default_array_get(PointerRNA *ptr, int *values)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
IntPropertyRNA *nprop= (IntPropertyRNA*)prop;
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
|
|
|
|
if(nprop->defaultarray) {
|
|
|
|
memcpy(values, nprop->defaultarray, prop->totarraylength * sizeof(int));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int i;
|
|
|
|
for(i=0; i < prop->totarraylength; i++)
|
|
|
|
values[i]= nprop->defaultvalue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void rna_BoolProperty_default_array_get(PointerRNA *ptr, int *values)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
BooleanPropertyRNA *nprop= (BooleanPropertyRNA*)prop;
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
|
|
|
|
if(nprop->defaultarray) {
|
|
|
|
memcpy(values, nprop->defaultarray, prop->totarraylength * sizeof(int));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int i;
|
|
|
|
for(i=0; i < prop->totarraylength; i++)
|
|
|
|
values[i]= nprop->defaultvalue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void rna_FloatProperty_default_array_get(PointerRNA *ptr, float *values)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
FloatPropertyRNA *nprop= (FloatPropertyRNA*)prop;
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
|
|
|
|
if(nprop->defaultarray) {
|
|
|
|
memcpy(values, nprop->defaultarray, prop->totarraylength * sizeof(float));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int i;
|
|
|
|
for(i=0; i < prop->totarraylength; i++)
|
|
|
|
values[i]= nprop->defaultvalue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_IntProperty_hard_min_get(PointerRNA *ptr)
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return ((IntPropertyRNA*)prop)->hardmin;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_IntProperty_hard_max_get(PointerRNA *ptr)
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return ((IntPropertyRNA*)prop)->hardmax;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_IntProperty_soft_min_get(PointerRNA *ptr)
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return ((IntPropertyRNA*)prop)->softmin;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_IntProperty_soft_max_get(PointerRNA *ptr)
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return ((IntPropertyRNA*)prop)->softmax;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_IntProperty_step_get(PointerRNA *ptr)
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return ((IntPropertyRNA*)prop)->step;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
2009-07-26 18:18:14 +00:00
|
|
|
static float rna_FloatProperty_default_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
return ((FloatPropertyRNA*)prop)->defaultvalue;
|
|
|
|
}
|
2008-11-14 18:46:57 +00:00
|
|
|
static float rna_FloatProperty_hard_min_get(PointerRNA *ptr)
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return ((FloatPropertyRNA*)prop)->hardmin;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static float rna_FloatProperty_hard_max_get(PointerRNA *ptr)
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return ((FloatPropertyRNA*)prop)->hardmax;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static float rna_FloatProperty_soft_min_get(PointerRNA *ptr)
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return ((FloatPropertyRNA*)prop)->softmin;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static float rna_FloatProperty_soft_max_get(PointerRNA *ptr)
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return ((FloatPropertyRNA*)prop)->softmax;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static float rna_FloatProperty_step_get(PointerRNA *ptr)
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return ((FloatPropertyRNA*)prop)->step;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_FloatProperty_precision_get(PointerRNA *ptr)
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return ((FloatPropertyRNA*)prop)->precision;
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
2009-07-26 18:18:14 +00:00
|
|
|
static void rna_StringProperty_default_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
strcpy(value, ((StringPropertyRNA*)prop)->defaultvalue);
|
|
|
|
}
|
|
|
|
static int rna_StringProperty_default_length(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
return strlen(((StringPropertyRNA*)prop)->defaultvalue);
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_StringProperty_max_length_get(PointerRNA *ptr)
|
2008-11-14 17:05:25 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
return ((StringPropertyRNA*)prop)->maxlength;
|
2008-11-14 17:05:25 +00:00
|
|
|
}
|
|
|
|
|
2009-07-26 18:18:14 +00:00
|
|
|
static EnumPropertyItem *rna_EnumProperty_default_itemf(bContext *C, PointerRNA *ptr, int *free)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
EnumPropertyRNA *eprop;
|
|
|
|
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
eprop= (EnumPropertyRNA*)prop;
|
|
|
|
|
2009-12-25 09:01:23 +00:00
|
|
|
if( (eprop->itemf == NULL) ||
|
|
|
|
(eprop->itemf == rna_EnumProperty_default_itemf) ||
|
|
|
|
(ptr->type == &RNA_EnumProperty) ||
|
|
|
|
(C == NULL))
|
|
|
|
{
|
2009-07-26 18:18:14 +00:00
|
|
|
return eprop->item;
|
2009-12-25 09:01:23 +00:00
|
|
|
}
|
2009-07-26 18:18:14 +00:00
|
|
|
|
|
|
|
return eprop->itemf(C, ptr, free);
|
|
|
|
}
|
|
|
|
|
2009-12-25 09:01:23 +00:00
|
|
|
/* XXX - not sure this is needed? */
|
2009-07-26 18:18:14 +00:00
|
|
|
static int rna_EnumProperty_default_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
rna_idproperty_check(&prop, ptr);
|
|
|
|
return ((EnumPropertyRNA*)prop)->defaultvalue;
|
|
|
|
}
|
|
|
|
|
2009-07-10 11:36:02 +00:00
|
|
|
static int rna_enum_check_separator(CollectionPropertyIterator *iter, void *data)
|
|
|
|
{
|
|
|
|
EnumPropertyItem *item= (EnumPropertyItem*)data;
|
|
|
|
|
2009-07-13 19:33:59 +00:00
|
|
|
return (item->identifier[0] == 0);
|
2009-07-10 11:36:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
|
|
|
EnumPropertyRNA *eprop;
|
2009-07-13 19:33:59 +00:00
|
|
|
EnumPropertyItem *item= NULL;
|
|
|
|
int totitem, free= 0;
|
|
|
|
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
eprop= (EnumPropertyRNA*)prop;
|
2009-07-13 19:33:59 +00:00
|
|
|
|
|
|
|
RNA_property_enum_items(NULL, ptr, prop, &item, &totitem, &free);
|
|
|
|
rna_iterator_array_begin(iter, (void*)item, sizeof(EnumPropertyItem), totitem, free, rna_enum_check_separator);
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_EnumPropertyItem_identifier_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
|
|
|
strcpy(value, ((EnumPropertyItem*)ptr->data)->identifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_EnumPropertyItem_identifier_length(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return strlen(((EnumPropertyItem*)ptr->data)->identifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_EnumPropertyItem_name_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
|
|
|
strcpy(value, ((EnumPropertyItem*)ptr->data)->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_EnumPropertyItem_name_length(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return strlen(((EnumPropertyItem*)ptr->data)->name);
|
|
|
|
}
|
|
|
|
|
2009-07-08 15:34:41 +00:00
|
|
|
static void rna_EnumPropertyItem_description_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
|
|
|
EnumPropertyItem *eprop= (EnumPropertyItem*)ptr->data;
|
|
|
|
|
|
|
|
if(eprop->description)
|
|
|
|
strcpy(value, eprop->description);
|
|
|
|
else
|
|
|
|
value[0]= '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_EnumPropertyItem_description_length(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
EnumPropertyItem *eprop= (EnumPropertyItem*)ptr->data;
|
|
|
|
|
|
|
|
if(eprop->description)
|
|
|
|
return strlen(eprop->description);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static int rna_EnumPropertyItem_value_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return ((EnumPropertyItem*)ptr->data)->value;
|
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_PointerProperty_fixed_type_get(PointerRNA *ptr)
|
2008-11-14 18:46:57 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2009-03-23 13:24:48 +00:00
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((PointerPropertyRNA*)prop)->type);
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_CollectionProperty_fixed_type_get(PointerRNA *ptr)
|
2008-11-14 18:46:57 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
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 02:23:46 +00:00
|
|
|
rna_idproperty_check(&prop, ptr);
|
2009-11-13 16:08:03 +00:00
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((CollectionPropertyRNA*)prop)->item_type);
|
2008-11-14 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
/* Function */
|
|
|
|
|
|
|
|
static void rna_Function_identifier_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
|
|
|
strcpy(value, ((FunctionRNA*)ptr->data)->identifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_Function_identifier_length(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return strlen(((FunctionRNA*)ptr->data)->identifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Function_description_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
|
|
|
strcpy(value, ((FunctionRNA*)ptr->data)->description);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_Function_description_length(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return strlen(((FunctionRNA*)ptr->data)->description);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Function_parameters_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
rna_iterator_listbase_begin(iter, &((FunctionRNA*)ptr->data)->cont.properties, rna_property_builtin);
|
|
|
|
}
|
|
|
|
|
2009-04-19 13:37:59 +00:00
|
|
|
static int rna_Function_registered_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
FunctionRNA *func= (FunctionRNA*)ptr->data;
|
|
|
|
return func->flag & FUNC_REGISTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_Function_registered_optional_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
FunctionRNA *func= (FunctionRNA*)ptr->data;
|
|
|
|
return func->flag & FUNC_REGISTER_OPTIONAL;
|
|
|
|
}
|
|
|
|
|
2008-12-15 13:46:50 +00:00
|
|
|
/* Blender RNA */
|
|
|
|
|
|
|
|
static void rna_BlenderRNA_structs_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
rna_iterator_listbase_begin(iter, &((BlenderRNA*)ptr->data)->structs, NULL);
|
|
|
|
}
|
|
|
|
|
2010-01-22 14:06:42 +00:00
|
|
|
/* optional, for faster lookups */
|
|
|
|
static int rna_BlenderRNA_structs_length(PointerRNA *ptr, int index)
|
|
|
|
{
|
|
|
|
return BLI_countlist(&((BlenderRNA*)ptr->data)->structs);
|
|
|
|
}
|
|
|
|
static PointerRNA rna_BlenderRNA_structs_lookup_int(PointerRNA *ptr, int index)
|
|
|
|
{
|
|
|
|
StructRNA *srna= BLI_findlink(&((BlenderRNA*)ptr->data)->structs, index);
|
|
|
|
|
|
|
|
if(srna) {
|
|
|
|
PointerRNA r_ptr;
|
|
|
|
RNA_pointer_create(NULL, &RNA_Struct, srna, &r_ptr);
|
|
|
|
return r_ptr;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return PointerRNA_NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static PointerRNA rna_BlenderRNA_structs_lookup_string(PointerRNA *ptr, const char *key)
|
|
|
|
{
|
|
|
|
StructRNA *srna= ((BlenderRNA*)ptr->data)->structs.first;
|
|
|
|
for(; srna; srna=srna->cont.next)
|
|
|
|
if(key[0] == srna->identifier[0] && strcmp(key, srna->identifier)==0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if(srna) {
|
|
|
|
PointerRNA r_ptr;
|
|
|
|
RNA_pointer_create(NULL, &RNA_Struct, srna, &r_ptr);
|
|
|
|
return r_ptr;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return PointerRNA_NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
#else
|
|
|
|
|
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 02:23:46 +00:00
|
|
|
static void rna_def_struct(BlenderRNA *brna)
|
2008-11-14 14:34:19 +00: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 02:23:46 +00:00
|
|
|
StructRNA *srna;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2008-12-19 04:06:24 +00:00
|
|
|
srna= RNA_def_struct(brna, "Struct", NULL);
|
2009-01-10 22:57:33 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Struct Definition", "RNA structure definition");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_RNA);
|
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 02:23:46 +00:00
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
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 02:23:46 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_Struct_name_get", "rna_Struct_name_length", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Name", "Human readable name.");
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
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 02:23:46 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_Struct_identifier_get", "rna_Struct_identifier_length", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting.");
|
2008-12-18 05:28:17 +00:00
|
|
|
RNA_def_struct_name_property(srna, prop);
|
|
|
|
|
2008-12-19 04:06:24 +00:00
|
|
|
prop= RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-12-19 04:06:24 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_Struct_description_get", "rna_Struct_description_length", NULL);
|
2008-12-31 15:02:40 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Description", "Description of the Struct's purpose.");
|
2008-12-19 04:06:24 +00:00
|
|
|
|
2008-12-18 23:34:19 +00:00
|
|
|
prop= RNA_def_property(srna, "base", PROP_POINTER, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-12-15 13:46:50 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Struct");
|
2009-06-07 13:09:18 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_Struct_base_get", NULL, NULL);
|
2008-12-31 13:16:37 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Base", "Struct definition this is derived from.");
|
2008-12-15 13:46:50 +00:00
|
|
|
|
2009-01-10 22:57:33 +00:00
|
|
|
prop= RNA_def_property(srna, "nested", PROP_POINTER, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2009-01-09 16:08:47 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Struct");
|
2009-06-07 13:09:18 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_Struct_nested_get", NULL, NULL);
|
2009-01-10 22:57:33 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Nested", "Struct in which this struct is always nested, and to which it logically belongs.");
|
2009-01-09 16:08:47 +00: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 02:23:46 +00:00
|
|
|
prop= RNA_def_property(srna, "name_property", PROP_POINTER, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
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 02:23:46 +00:00
|
|
|
RNA_def_property_struct_type(prop, "StringProperty");
|
2009-06-07 13:09:18 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_Struct_name_property_get", NULL, NULL);
|
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 02:23:46 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Name Property", "Property that gives the name of the struct.");
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
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 02:23:46 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Property");
|
2009-11-13 16:08:03 +00:00
|
|
|
RNA_def_property_collection_funcs(prop, "rna_Struct_properties_begin", "rna_Struct_properties_next", "rna_iterator_listbase_end", "rna_Struct_properties_get", 0, 0, 0);
|
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 02:23:46 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Properties", "Properties in the struct.");
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "functions", PROP_COLLECTION, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_struct_type(prop, "Function");
|
2009-11-13 16:08:03 +00:00
|
|
|
RNA_def_property_collection_funcs(prop, "rna_Struct_functions_begin", "rna_Struct_functions_next", "rna_iterator_listbase_end", "rna_Struct_functions_get", 0, 0, 0);
|
2009-04-07 00:49:39 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Functions", "");
|
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 02:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_def_property(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
2008-11-14 14:34:19 +00:00
|
|
|
PropertyRNA *prop;
|
2008-11-14 18:46:57 +00:00
|
|
|
static EnumPropertyItem type_items[] = {
|
2009-06-16 00:52:21 +00:00
|
|
|
{PROP_BOOLEAN, "BOOLEAN", 0, "Boolean", ""},
|
|
|
|
{PROP_INT, "INT", 0, "Integer", ""},
|
|
|
|
{PROP_FLOAT, "FLOAT", 0, "Float", ""},
|
|
|
|
{PROP_STRING, "STRING", 0, "String", ""},
|
|
|
|
{PROP_ENUM, "ENUM", 0, "Enumeration", ""},
|
|
|
|
{PROP_POINTER, "POINTER", 0, "Pointer", ""},
|
|
|
|
{PROP_COLLECTION, "COLLECTION", 0, "Collection", ""},
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
2008-11-14 18:46:57 +00:00
|
|
|
static EnumPropertyItem subtype_items[] = {
|
2009-06-16 00:52:21 +00:00
|
|
|
{PROP_NONE, "NONE", 0, "None", ""},
|
|
|
|
{PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""},
|
|
|
|
{PROP_DIRPATH, "DIRECTORY_PATH", 0, "Directory Path", ""},
|
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 21:31:05 +00:00
|
|
|
{PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned Number", ""},
|
|
|
|
{PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""},
|
2009-09-21 21:19:58 +00:00
|
|
|
{PROP_FACTOR, "FACTOR", 0, "Factor", ""},
|
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 21:31:05 +00:00
|
|
|
{PROP_ANGLE, "ANGLE", 0, "Angle", ""},
|
|
|
|
{PROP_TIME, "TIME", 0, "Time", ""},
|
|
|
|
{PROP_DISTANCE, "DISTANCE", 0, "Distance", ""},
|
2009-06-16 00:52:21 +00:00
|
|
|
{PROP_COLOR, "COLOR", 0, "Color", ""},
|
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 21:31:05 +00:00
|
|
|
{PROP_TRANSLATION, "TRANSLATION", 0, "Translation", ""},
|
|
|
|
{PROP_DIRECTION, "DIRECTION", 0, "Direction", ""},
|
2009-06-16 00:52:21 +00:00
|
|
|
{PROP_MATRIX, "MATRIX", 0, "Matrix", ""},
|
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 21:31:05 +00:00
|
|
|
{PROP_EULER, "EULER", 0, "Euler", ""},
|
|
|
|
{PROP_QUATERNION, "QUATERNION", 0, "Quaternion", ""},
|
|
|
|
{PROP_XYZ, "XYZ", 0, "XYZ", ""},
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
{PROP_COLOR_GAMMA, "COLOR_GAMMA", 0, "Gamma Corrected Color", ""},
|
2009-09-09 17:39:19 +00:00
|
|
|
{PROP_LAYER, "LAYER", 0, "Layer", ""},
|
|
|
|
{PROP_LAYER_MEMBER, "LAYER_MEMBERSHIP", 0, "Layer Membership", ""},
|
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 21:31:05 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}};
|
|
|
|
static EnumPropertyItem unit_items[] = {
|
|
|
|
{PROP_UNIT_NONE, "NONE", 0, "None", ""},
|
|
|
|
{PROP_UNIT_LENGTH, "LENGTH", 0, "Length", ""},
|
|
|
|
{PROP_UNIT_AREA, "AREA", 0, "Area", ""},
|
|
|
|
{PROP_UNIT_VOLUME, "VOLUME", 0, "Volume", ""},
|
|
|
|
{PROP_UNIT_ROTATION, "ROTATION", 0, "Rotation", ""},
|
|
|
|
{PROP_UNIT_TIME, "TIME", 0, "Time", ""},
|
|
|
|
{PROP_UNIT_VELOCITY, "VELOCITY", 0, "Velocity", ""},
|
|
|
|
{PROP_UNIT_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""},
|
2009-06-16 00:52:21 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}};
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-12-19 04:06:24 +00:00
|
|
|
srna= RNA_def_struct(brna, "Property", NULL);
|
2009-01-10 22:57:33 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Property Definition", "RNA property definition.");
|
2009-01-01 15:52:51 +00:00
|
|
|
RNA_def_struct_refine_func(srna, "rna_Property_refine");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_RNA);
|
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 02:23:46 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_Property_name_get", "rna_Property_name_length", NULL);
|
2008-11-14 17:05:25 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Name", "Human readable name.");
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
prop= RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_Property_identifier_get", "rna_Property_identifier_length", NULL);
|
2008-11-14 17:05:25 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting.");
|
2008-12-18 07:22:28 +00:00
|
|
|
RNA_def_struct_name_property(srna, prop);
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
prop= RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_Property_description_get", "rna_Property_description_length", NULL);
|
2008-11-14 17:05:25 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Description", "Description of the property for tooltips.");
|
2008-11-14 14:34:19 +00:00
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 14:34:19 +00:00
|
|
|
RNA_def_property_enum_items(prop, type_items);
|
2009-05-28 23:23:47 +00:00
|
|
|
RNA_def_property_enum_funcs(prop, "rna_Property_type_get", NULL, NULL);
|
2008-11-14 17:05:25 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Type", "Data type of the property.");
|
2008-11-14 14:34:19 +00:00
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "subtype", PROP_ENUM, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 14:34:19 +00:00
|
|
|
RNA_def_property_enum_items(prop, subtype_items);
|
2009-05-28 23:23:47 +00:00
|
|
|
RNA_def_property_enum_funcs(prop, "rna_Property_subtype_get", NULL, NULL);
|
2008-11-18 10:57:06 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Subtype", "Semantic interpretation of the property.");
|
2009-01-10 22:57:33 +00:00
|
|
|
|
2009-11-13 17:42:44 +00:00
|
|
|
prop= RNA_def_property(srna, "srna", PROP_POINTER, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_struct_type(prop, "Struct");
|
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_Property_srna_get", NULL, NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Base", "Struct definition used for properties assigned to this item.");
|
|
|
|
|
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 21:31:05 +00:00
|
|
|
prop= RNA_def_property(srna, "unit", PROP_ENUM, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_enum_items(prop, unit_items);
|
|
|
|
RNA_def_property_enum_funcs(prop, "rna_Property_unit_get", NULL, NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Unit", "Type of units for this property.");
|
|
|
|
|
2009-12-25 14:42:00 +00:00
|
|
|
prop= RNA_def_property(srna, "is_readonly", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_readonly_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Read Only", "Property is editable through RNA.");
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "is_required", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_is_required_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Required", "False when this property is an optional argument in an rna function.");
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "is_never_none", PROP_BOOLEAN, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2009-12-25 14:42:00 +00:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_is_never_none_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Never None", "True when this value can't be set to None.");
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2009-08-16 15:46:09 +00:00
|
|
|
prop= RNA_def_property(srna, "use_return", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_use_return_get", NULL);
|
2009-12-25 14:42:00 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Return", "True when this property is a return value from an rna function.");
|
2009-08-16 15:46:09 +00:00
|
|
|
|
2009-04-19 13:37:59 +00:00
|
|
|
prop= RNA_def_property(srna, "registered", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_registered_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Registered", "Property is registerd as part of type registration.");
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "registered_optional", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Property_registered_optional_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Registered Optionally", "Property is optionally registerd as part of type registration.");
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
static void rna_def_function(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
srna= RNA_def_struct(brna, "Function", NULL);
|
|
|
|
RNA_def_struct_ui_text(srna, "Function Definition", "RNA function definition");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_RNA);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_string_funcs(prop, "rna_Function_identifier_get", "rna_Function_identifier_length", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting.");
|
|
|
|
RNA_def_struct_name_property(srna, prop);
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_string_funcs(prop, "rna_Function_description_get", "rna_Function_description_length", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Description", "Description of the Function's purpose.");
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "parameters", PROP_COLLECTION, PROP_NONE);
|
|
|
|
/*RNA_def_property_clear_flag(prop, PROP_EDITABLE);*/
|
|
|
|
RNA_def_property_struct_type(prop, "Property");
|
2009-11-13 16:08:03 +00:00
|
|
|
RNA_def_property_collection_funcs(prop, "rna_Function_parameters_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0);
|
2009-04-07 00:49:39 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Parameters", "Parameters for the function.");
|
2009-04-19 13:37:59 +00:00
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "registered", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Function_registered_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Registered", "Function is registerd as callback as part of type registration.");
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "registered_optional", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Function_registered_optional_get", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Registered Optionally", "Function is optionally registerd as callback part of type registration.");
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_def_number_property(StructRNA *srna, PropertyType type)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-07-26 18:18:14 +00:00
|
|
|
prop= RNA_def_property(srna, "default", type, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_ui_text(prop, "Default", "Default value for this number");
|
|
|
|
|
|
|
|
switch(type) {
|
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 21:31:05 +00:00
|
|
|
case PROP_BOOLEAN:
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_BoolProperty_default_get", NULL);
|
|
|
|
break;
|
|
|
|
case PROP_INT:
|
|
|
|
RNA_def_property_int_funcs(prop, "rna_IntProperty_default_get", NULL, NULL);
|
|
|
|
break;
|
|
|
|
case PROP_FLOAT:
|
|
|
|
RNA_def_property_float_funcs(prop, "rna_FloatProperty_default_get", NULL, NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2009-07-26 18:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "default_array", type, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2009-09-15 10:01:20 +00:00
|
|
|
RNA_def_property_array(prop, RNA_MAX_ARRAY_DIMENSION); /* no fixed default length, important its not 0 though */
|
|
|
|
RNA_def_property_flag(prop, PROP_DYNAMIC);
|
|
|
|
RNA_def_property_dynamic_array_funcs(prop, "rna_NumberProperty_default_array_get_length"); /* same for all types */
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case PROP_BOOLEAN:
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_BoolProperty_default_array_get", NULL);
|
|
|
|
break;
|
|
|
|
case PROP_INT:
|
|
|
|
RNA_def_property_int_funcs(prop, "rna_IntProperty_default_array_get", NULL, NULL);
|
|
|
|
break;
|
|
|
|
case PROP_FLOAT:
|
|
|
|
RNA_def_property_float_funcs(prop, "rna_FloatProperty_default_array_get", NULL, NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
RNA_def_property_ui_text(prop, "Default Array", "Default value for this array");
|
|
|
|
|
2009-07-26 18:18:14 +00:00
|
|
|
|
2008-11-18 10:57:06 +00:00
|
|
|
prop= RNA_def_property(srna, "array_length", PROP_INT, PROP_UNSIGNED);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-24 12:12:24 +00:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_Property_array_length_get", NULL, NULL);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Array Length", "Maximum length of the array, 0 means unlimited.");
|
|
|
|
|
|
|
|
if(type == PROP_BOOLEAN)
|
|
|
|
return;
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "hard_min", type, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-24 12:12:24 +00:00
|
|
|
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_hard_min_get", NULL, NULL);
|
|
|
|
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_hard_min_get", NULL, NULL);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Hard Minimum", "Minimum value used by buttons.");
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "hard_max", type, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-24 12:12:24 +00:00
|
|
|
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_hard_max_get", NULL, NULL);
|
|
|
|
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_hard_max_get", NULL, NULL);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Hard Maximum", "Maximum value used by buttons.");
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "soft_min", type, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-24 12:12:24 +00:00
|
|
|
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_soft_min_get", NULL, NULL);
|
|
|
|
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_soft_min_get", NULL, NULL);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Soft Minimum", "Minimum value used by buttons.");
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "soft_max", type, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-24 12:12:24 +00:00
|
|
|
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_soft_max_get", NULL, NULL);
|
|
|
|
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_soft_max_get", NULL, NULL);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Soft Maximum", "Maximum value used by buttons.");
|
|
|
|
|
2008-11-18 10:57:06 +00:00
|
|
|
prop= RNA_def_property(srna, "step", type, PROP_UNSIGNED);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-24 12:12:24 +00:00
|
|
|
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_step_get", NULL, NULL);
|
|
|
|
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_step_get", NULL, NULL);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Step", "Step size used by number buttons, for floats 1/100th of the step size.");
|
|
|
|
|
|
|
|
if(type == PROP_FLOAT) {
|
2008-11-18 10:57:06 +00:00
|
|
|
prop= RNA_def_property(srna, "precision", PROP_INT, PROP_UNSIGNED);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-24 12:12:24 +00:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_FloatProperty_precision_get", NULL, NULL);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Precision", "Number of digits after the dot used by buttons.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 02:23:46 +00:00
|
|
|
static void rna_def_string_property(StructRNA *srna)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-07-26 18:18:14 +00:00
|
|
|
prop= RNA_def_property(srna, "default", PROP_STRING, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_string_funcs(prop, "rna_StringProperty_default_get", "rna_StringProperty_default_length", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Default", "string default value.");
|
|
|
|
|
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 02:23:46 +00:00
|
|
|
prop= RNA_def_property(srna, "max_length", PROP_INT, PROP_UNSIGNED);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-24 12:12:24 +00:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_StringProperty_max_length_get", NULL, NULL);
|
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 02:23:46 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Maximum Length", "Maximum length of the string, 0 means unlimited.");
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-07-26 18:18:14 +00:00
|
|
|
/* the itemf func is used instead, keep blender happy */
|
|
|
|
static EnumPropertyItem default_dummy_items[] = {
|
|
|
|
{PROP_NONE, "DUMMY", 0, "Dummy", ""},
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "default", PROP_ENUM, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_enum_items(prop, default_dummy_items);
|
|
|
|
RNA_def_property_enum_funcs(prop, "rna_EnumProperty_default_get", NULL, "rna_EnumProperty_default_itemf");
|
|
|
|
RNA_def_property_ui_text(prop, "Default", "Default value for this enum");
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
prop= RNA_def_property(srna, "items", PROP_COLLECTION, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_struct_type(prop, "EnumPropertyItem");
|
2009-11-13 16:08:03 +00:00
|
|
|
RNA_def_property_collection_funcs(prop, "rna_EnumProperty_items_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Items", "Possible values for the property.");
|
|
|
|
|
2008-12-19 04:06:24 +00:00
|
|
|
srna= RNA_def_struct(brna, "EnumPropertyItem", NULL);
|
2009-01-10 22:57:33 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Enum Item Definition", "Definition of a choice in an RNA enum property.");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_RNA);
|
2008-11-14 18:46:57 +00:00
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_EnumPropertyItem_name_get", "rna_EnumPropertyItem_name_length", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Name", "Human readable name.");
|
|
|
|
|
2009-07-08 15:34:41 +00:00
|
|
|
prop= RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_string_funcs(prop, "rna_EnumPropertyItem_description_get", "rna_EnumPropertyItem_description_length", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Description", "Description of the item's purpose.");
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
prop= RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_string_funcs(prop, "rna_EnumPropertyItem_identifier_get", "rna_EnumPropertyItem_identifier_length", NULL);
|
|
|
|
RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting.");
|
2008-12-18 23:34:19 +00:00
|
|
|
RNA_def_struct_name_property(srna, prop);
|
2008-11-14 18:46:57 +00:00
|
|
|
|
2008-11-18 10:57:06 +00:00
|
|
|
prop= RNA_def_property(srna, "value", PROP_INT, PROP_UNSIGNED);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-24 12:12:24 +00:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_EnumPropertyItem_value_get", NULL, NULL);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Value", "Value of the item.");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_def_pointer_property(StructRNA *srna, PropertyType type)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "fixed_type", PROP_POINTER, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Struct");
|
|
|
|
if(type == PROP_POINTER)
|
2009-06-07 13:09:18 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_PointerProperty_fixed_type_get", NULL, NULL);
|
2008-11-14 18:46:57 +00:00
|
|
|
else
|
2009-06-07 13:09:18 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_CollectionProperty_fixed_type_get", NULL, NULL);
|
2008-11-14 18:46:57 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Pointer Type", "Fixed pointer type, empty if variable type.");
|
|
|
|
}
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
void RNA_def_rna(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
2008-12-15 13:46:50 +00:00
|
|
|
PropertyRNA *prop;
|
2008-11-14 14:34:19 +00: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 02:23:46 +00:00
|
|
|
/* Struct*/
|
|
|
|
rna_def_struct(brna);
|
2008-11-14 14:34:19 +00: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 02:23:46 +00:00
|
|
|
/* Property */
|
|
|
|
rna_def_property(brna);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
/* BooleanProperty */
|
2008-12-19 04:06:24 +00:00
|
|
|
srna= RNA_def_struct(brna, "BooleanProperty", "Property");
|
2009-01-10 22:57:33 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Boolean Definition", "RNA boolean property definition.");
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_def_number_property(srna, PROP_BOOLEAN);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
/* IntProperty */
|
2008-12-19 04:06:24 +00:00
|
|
|
srna= RNA_def_struct(brna, "IntProperty", "Property");
|
2009-01-10 22:57:33 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Int Definition", "RNA integer number property definition.");
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_def_number_property(srna, PROP_INT);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
/* FloatProperty */
|
2008-12-19 04:06:24 +00:00
|
|
|
srna= RNA_def_struct(brna, "FloatProperty", "Property");
|
2009-01-10 22:57:33 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Float Definition", "RNA floating pointer number property definition.");
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_def_number_property(srna, PROP_FLOAT);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
/* StringProperty */
|
2008-12-19 04:06:24 +00:00
|
|
|
srna= RNA_def_struct(brna, "StringProperty", "Property");
|
2009-01-10 22:57:33 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "String Definition", "RNA text string property definition.");
|
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 02:23:46 +00:00
|
|
|
rna_def_string_property(srna);
|
2008-11-14 17:05:25 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
/* EnumProperty */
|
2008-12-19 04:06:24 +00:00
|
|
|
srna= RNA_def_struct(brna, "EnumProperty", "Property");
|
2009-01-10 22:57:33 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Enum Definition", "RNA enumeration property definition, to choose from a number of predefined options.");
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_def_enum_property(brna, srna);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
/* PointerProperty */
|
2008-12-19 04:06:24 +00:00
|
|
|
srna= RNA_def_struct(brna, "PointerProperty", "Property");
|
2009-01-10 22:57:33 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Pointer Definition", "RNA pointer property to point to another RNA struct.");
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_def_pointer_property(srna, PROP_POINTER);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
/* CollectionProperty */
|
2008-12-19 04:06:24 +00:00
|
|
|
srna= RNA_def_struct(brna, "CollectionProperty", "Property");
|
2009-01-10 22:57:33 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Collection Definition", "RNA collection property to define lists, arrays and mappings.");
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_def_pointer_property(srna, PROP_COLLECTION);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
/* Function */
|
|
|
|
rna_def_function(brna);
|
2008-12-15 13:46:50 +00:00
|
|
|
|
|
|
|
/* Blender RNA */
|
2008-12-19 04:06:24 +00:00
|
|
|
srna= RNA_def_struct(brna, "BlenderRNA", NULL);
|
2009-01-10 22:57:33 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Blender RNA", "Blender RNA structure definitions.");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_RNA);
|
2008-12-15 13:46:50 +00:00
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "structs", PROP_COLLECTION, PROP_NONE);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-12-15 13:46:50 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Struct");
|
2010-01-22 14:06:42 +00:00
|
|
|
RNA_def_property_collection_funcs(prop, "rna_BlenderRNA_structs_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get",
|
|
|
|
/* included for speed, can be removed */
|
|
|
|
#if 0
|
|
|
|
0,0,0);
|
|
|
|
#else
|
|
|
|
"rna_BlenderRNA_structs_length", "rna_BlenderRNA_structs_lookup_int", "rna_BlenderRNA_structs_lookup_string");
|
|
|
|
#endif
|
|
|
|
|
2008-12-15 13:46:50 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Structs", "");
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|