RNA
* Store RNA collections different in ID properties, using a generic ID property array, using the patch provided by Joe. * Fix bug accessing registered operator properties in the wm from the outliner. * In the outliner, only use the RNA icon for RNA data, and use dot again for unknown icon. * Also, show pointer properties data in the second column, and auto expand two levels when opening them. * Added small RNA_struct_defined_properties function to get only the defined properties without builtin and undefined id properties (for py operators).
This commit is contained in:
@@ -49,7 +49,22 @@ typedef union {
|
||||
} matrix_or_vector;
|
||||
} IDPropertyTemplate;
|
||||
|
||||
/* ----------- Array Type ----------- */
|
||||
/* ----------- Property Array Type ---------- */
|
||||
|
||||
/*note: as a start to move away from the stupid IDP_New function, this type
|
||||
has it's own allocation function.*/
|
||||
IDProperty *IDP_NewIDPArray(const char *name);
|
||||
IDProperty *IDP_CopyIDPArray(IDProperty *array);
|
||||
|
||||
void IDP_FreeIDPArray(IDProperty *prop);
|
||||
|
||||
/* shallow copies item */
|
||||
void IDP_SetIndexArray(struct IDProperty *prop, int index, struct IDProperty *item);
|
||||
struct IDProperty *IDP_GetIndexArray(struct IDProperty *prop, int index);
|
||||
struct IDProperty *IDP_AppendArray(struct IDProperty *prop, struct IDProperty *item);
|
||||
void IDP_ResizeIDPArray(struct IDProperty *prop, int len);
|
||||
|
||||
/* ----------- Numeric Array Type ----------- */
|
||||
/*this function works for strings too!*/
|
||||
void IDP_ResizeArray(struct IDProperty *prop, int newlen);
|
||||
void IDP_FreeArray(struct IDProperty *prop);
|
||||
@@ -152,7 +167,7 @@ Note that you MUST either attach the id property to an id property group with
|
||||
IDP_AddToGroup or MEM_freeN the property, doing anything else might result in
|
||||
a memory leak.
|
||||
*/
|
||||
struct IDProperty *IDP_New(int type, IDPropertyTemplate val, char *name);
|
||||
struct IDProperty *IDP_New(int type, IDPropertyTemplate val, const char *name);
|
||||
\
|
||||
/*NOTE: this will free all child properties of list arrays and groups!
|
||||
Also, note that this does NOT unlink anything! Plus it doesn't free
|
||||
@@ -162,10 +177,11 @@ void IDP_FreeProperty(struct IDProperty *prop);
|
||||
/*Unlinks any struct IDProperty<->ID linkage that might be going on.*/
|
||||
void IDP_UnlinkProperty(struct IDProperty *prop);
|
||||
|
||||
#define IDP_Int(prop) (prop->data.val)
|
||||
#define IDP_Float(prop) (*(float*)&prop->data.val)
|
||||
#define IDP_String(prop) ((char*)prop->data.pointer)
|
||||
#define IDP_Array(prop) (prop->data.pointer)
|
||||
#define IDP_Double(prop) (*(double*)&prop->data.val)
|
||||
#define IDP_Int(prop) ((prop)->data.val)
|
||||
#define IDP_Float(prop) (*(float*)&(prop)->data.val)
|
||||
#define IDP_String(prop) ((char*)(prop)->data.pointer)
|
||||
#define IDP_Array(prop) ((prop)->data.pointer)
|
||||
#define IDP_IDPArray(prop) ((IDProperty*)(prop)->data.pointer)
|
||||
#define IDP_Double(prop) (*(double*)&(prop)->data.val)
|
||||
|
||||
#endif /* _BKE_IDPROP_H */
|
||||
|
||||
@@ -58,9 +58,126 @@ static char idp_size_table[] = {
|
||||
sizeof(double)
|
||||
};
|
||||
|
||||
/* ------------Property Array Type ----------- */
|
||||
#define GETPROP(prop, i) (((IDProperty*)(prop)->data.pointer)+(i))
|
||||
|
||||
/* ----------- Array Type ----------- */
|
||||
/* --------- property array type -------------*/
|
||||
|
||||
/*note: as a start to move away from the stupid IDP_New function, this type
|
||||
has it's own allocation function.*/
|
||||
IDProperty *IDP_NewIDPArray(const char *name)
|
||||
{
|
||||
IDProperty *prop = MEM_callocN(sizeof(IDProperty), "IDProperty prop array");
|
||||
prop->type = IDP_IDPARRAY;
|
||||
prop->len = 0;
|
||||
BLI_strncpy(prop->name, name, MAX_IDPROP_NAME);
|
||||
|
||||
return prop;
|
||||
}
|
||||
|
||||
IDProperty *IDP_CopyIDPArray(IDProperty *array)
|
||||
{
|
||||
IDProperty *narray = MEM_dupallocN(array), *tmp;
|
||||
int i;
|
||||
|
||||
narray->data.pointer = MEM_dupallocN(array->data.pointer);
|
||||
for (i=0; i<narray->len; i++) {
|
||||
/*ok, the copy functions always allocate a new structure,
|
||||
which doesn't work here. instead, simply copy the
|
||||
contents of the new structure into the array cell,
|
||||
then free it. this makes for more maintainable
|
||||
code than simply reimplementing the copy functions
|
||||
in this loop.*/
|
||||
tmp = IDP_CopyProperty(GETPROP(narray, i));
|
||||
memcpy(GETPROP(narray, i), tmp, sizeof(IDProperty));
|
||||
MEM_freeN(tmp);
|
||||
}
|
||||
|
||||
return narray;
|
||||
}
|
||||
|
||||
void IDP_FreeIDPArray(IDProperty *prop)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<prop->len; i++)
|
||||
IDP_FreeProperty(GETPROP(prop, i));
|
||||
|
||||
if(prop->data.pointer)
|
||||
MEM_freeN(prop->data.pointer);
|
||||
}
|
||||
|
||||
/*shallow copies item*/
|
||||
void IDP_SetIndexArray(IDProperty *prop, int index, IDProperty *item)
|
||||
{
|
||||
IDProperty *old = GETPROP(prop, index);
|
||||
if (index >= prop->len || index < 0) return;
|
||||
if (item != old) IDP_FreeProperty(old);
|
||||
|
||||
memcpy(GETPROP(prop, index), item, sizeof(IDProperty));
|
||||
}
|
||||
|
||||
IDProperty *IDP_GetIndexArray(IDProperty *prop, int index)
|
||||
{
|
||||
return GETPROP(prop, index);
|
||||
}
|
||||
|
||||
IDProperty *IDP_AppendArray(IDProperty *prop, IDProperty *item)
|
||||
{
|
||||
IDP_ResizeIDPArray(prop, prop->len+1);
|
||||
IDP_SetIndexArray(prop, prop->len-1, item);
|
||||
return item;
|
||||
}
|
||||
|
||||
void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
|
||||
{
|
||||
void *newarr;
|
||||
int newsize=newlen;
|
||||
|
||||
/*first check if the array buffer size has room*/
|
||||
/*if newlen is 200 chars less then totallen, reallocate anyway*/
|
||||
if (newlen <= prop->totallen && prop->totallen - newlen < 200) {
|
||||
int i;
|
||||
|
||||
for(i=newlen; i<prop->len; i++)
|
||||
IDP_FreeProperty(GETPROP(prop, i));
|
||||
|
||||
prop->len = newlen;
|
||||
return;
|
||||
}
|
||||
|
||||
/* - Note: This code comes from python, here's the corrusponding comment. - */
|
||||
/* This over-allocates proportional to the list size, making room
|
||||
* for additional growth. The over-allocation is mild, but is
|
||||
* enough to give linear-time amortized behavior over a long
|
||||
* sequence of appends() in the presence of a poorly-performing
|
||||
* system realloc().
|
||||
* The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ...
|
||||
*/
|
||||
newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
|
||||
|
||||
newarr = MEM_callocN(sizeof(IDProperty)*newsize, "idproperty array resized");
|
||||
if (newlen >= prop->len) {
|
||||
/* newlen is bigger*/
|
||||
memcpy(newarr, prop->data.pointer, prop->len*sizeof(IDProperty));
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
/* newlen is smaller*/
|
||||
for (i=newlen; i<prop->len; i++) {
|
||||
IDP_FreeProperty(GETPROP(prop, i));
|
||||
}
|
||||
memcpy(newarr, prop->data.pointer, newlen*prop->len*sizeof(IDProperty));
|
||||
}
|
||||
|
||||
if(prop->data.pointer)
|
||||
MEM_freeN(prop->data.pointer);
|
||||
prop->data.pointer = newarr;
|
||||
prop->len = newlen;
|
||||
prop->totallen = newsize;
|
||||
}
|
||||
|
||||
/* ----------- Numerical Array Type ----------- */
|
||||
static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr)
|
||||
{
|
||||
if(prop->subtype != IDP_GROUP)
|
||||
@@ -144,7 +261,7 @@ void IDP_FreeArray(IDProperty *prop)
|
||||
{
|
||||
IDProperty *newp = MEM_callocN(sizeof(IDProperty), "IDProperty array dup");
|
||||
|
||||
strncpy(newp->name, prop->name, MAX_IDPROP_NAME);
|
||||
BLI_strncpy(newp->name, prop->name, MAX_IDPROP_NAME);
|
||||
newp->type = prop->type;
|
||||
newp->flag = prop->flag;
|
||||
newp->data.val = prop->data.val;
|
||||
@@ -234,7 +351,8 @@ void IDP_ConcatString(IDProperty *str1, IDProperty *append)
|
||||
|
||||
void IDP_FreeString(IDProperty *prop)
|
||||
{
|
||||
MEM_freeN(prop->data.pointer);
|
||||
if(prop->data.pointer)
|
||||
MEM_freeN(prop->data.pointer);
|
||||
}
|
||||
|
||||
|
||||
@@ -388,6 +506,7 @@ IDProperty *IDP_CopyProperty(IDProperty *prop)
|
||||
case IDP_GROUP: return IDP_CopyGroup(prop);
|
||||
case IDP_STRING: return IDP_CopyString(prop);
|
||||
case IDP_ARRAY: return IDP_CopyArray(prop);
|
||||
case IDP_IDPARRAY: return IDP_CopyIDPArray(prop);
|
||||
default: return idp_generic_copy(prop);
|
||||
}
|
||||
}
|
||||
@@ -408,7 +527,7 @@ IDProperty *IDP_GetProperties(ID *id, int create_if_needed)
|
||||
}
|
||||
}
|
||||
|
||||
IDProperty *IDP_New(int type, IDPropertyTemplate val, char *name)
|
||||
IDProperty *IDP_New(int type, IDPropertyTemplate val, const char *name)
|
||||
{
|
||||
IDProperty *prop=NULL;
|
||||
|
||||
@@ -431,8 +550,8 @@ IDProperty *IDP_New(int type, IDPropertyTemplate val, char *name)
|
||||
if (val.array.type == IDP_FLOAT || val.array.type == IDP_INT || val.array.type == IDP_DOUBLE || val.array.type == IDP_GROUP) {
|
||||
prop = MEM_callocN(sizeof(IDProperty), "IDProperty array");
|
||||
prop->subtype = val.array.type;
|
||||
prop->data.pointer = MEM_callocN(idp_size_table[val.array.type]*val.array.len, "id property array");
|
||||
idp_resize_group_array(prop, val.array.len, prop->data.pointer);
|
||||
if (val.array.len)
|
||||
prop->data.pointer = MEM_callocN(idp_size_table[val.array.type]*val.array.len, "id property array");
|
||||
prop->len = prop->totallen = val.array.len;
|
||||
break;
|
||||
} else {
|
||||
@@ -471,7 +590,7 @@ IDProperty *IDP_New(int type, IDPropertyTemplate val, char *name)
|
||||
}
|
||||
|
||||
prop->type = type;
|
||||
strncpy(prop->name, name, MAX_IDPROP_NAME);
|
||||
BLI_strncpy(prop->name, name, MAX_IDPROP_NAME);
|
||||
|
||||
/*security null byte*/
|
||||
prop->name[MAX_IDPROP_NAME-1] = 0;
|
||||
@@ -494,6 +613,9 @@ void IDP_FreeProperty(IDProperty *prop)
|
||||
case IDP_GROUP:
|
||||
IDP_FreeGroup(prop);
|
||||
break;
|
||||
case IDP_IDPARRAY:
|
||||
IDP_FreeIDPArray(prop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1346,6 +1346,24 @@ static void test_pointer_array(FileData *fd, void **mat)
|
||||
void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, FileData *fd);
|
||||
void IDP_LibLinkProperty(IDProperty *prop, int switch_endian, FileData *fd);
|
||||
|
||||
static void IDP_DirectLinkIDPArray(IDProperty *prop, int switch_endian, FileData *fd)
|
||||
{
|
||||
IDProperty **array;
|
||||
int i;
|
||||
|
||||
/*since we didn't save the extra buffer, set totallen to len.*/
|
||||
prop->totallen = prop->len;
|
||||
prop->data.pointer = newdataadr(fd, prop->data.pointer);
|
||||
|
||||
if (switch_endian) {
|
||||
test_pointer_array(fd, prop->data.pointer);
|
||||
array= (IDProperty**) prop->data.pointer;
|
||||
|
||||
for(i=0; i<prop->len; i++)
|
||||
IDP_DirectLinkProperty(array[i], switch_endian, fd);
|
||||
}
|
||||
}
|
||||
|
||||
static void IDP_DirectLinkArray(IDProperty *prop, int switch_endian, FileData *fd)
|
||||
{
|
||||
IDProperty **array;
|
||||
@@ -1407,6 +1425,9 @@ void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, FileData *fd)
|
||||
case IDP_ARRAY:
|
||||
IDP_DirectLinkArray(prop, switch_endian, fd);
|
||||
break;
|
||||
case IDP_IDPARRAY:
|
||||
IDP_DirectLinkIDPArray(prop, switch_endian, fd);
|
||||
break;
|
||||
case IDP_DOUBLE:
|
||||
/*erg, stupid doubles. since I'm storing them
|
||||
in the same field as int val; val2 in the
|
||||
|
||||
@@ -391,7 +391,7 @@ static void IDP_WriteArray(IDProperty *prop, void *wd)
|
||||
if (prop->data.pointer) {
|
||||
writedata(wd, DATA, MEM_allocN_len(prop->data.pointer), prop->data.pointer);
|
||||
|
||||
if(prop->type == IDP_GROUP) {
|
||||
if(prop->subtype == IDP_GROUP) {
|
||||
IDProperty **array= prop->data.pointer;
|
||||
int a;
|
||||
|
||||
@@ -401,6 +401,20 @@ static void IDP_WriteArray(IDProperty *prop, void *wd)
|
||||
}
|
||||
}
|
||||
|
||||
static void IDP_WriteIDPArray(IDProperty *prop, void *wd)
|
||||
{
|
||||
/*REMEMBER to set totalen to len in the linking code!!*/
|
||||
if (prop->data.pointer) {
|
||||
IDProperty **array = prop->data.pointer;
|
||||
int a;
|
||||
|
||||
writedata(wd, DATA, MEM_allocN_len(prop->data.pointer), prop->data.pointer);
|
||||
|
||||
for(a=0; a<prop->len; a++)
|
||||
IDP_WriteProperty(array[a], wd);
|
||||
}
|
||||
}
|
||||
|
||||
static void IDP_WriteString(IDProperty *prop, void *wd)
|
||||
{
|
||||
/*REMEMBER to set totalen to len in the linking code!!*/
|
||||
@@ -429,6 +443,9 @@ void IDP_WriteProperty_OnlyData(IDProperty *prop, void *wd)
|
||||
case IDP_ARRAY:
|
||||
IDP_WriteArray(prop, wd);
|
||||
break;
|
||||
case IDP_IDPARRAY:
|
||||
IDP_WriteIDPArray(prop, wd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1014,8 +1014,10 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
|
||||
iterprop= RNA_struct_iterator_property(ptr);
|
||||
tot= RNA_property_collection_length(ptr, iterprop);
|
||||
|
||||
if(!parent)
|
||||
tselem->flag &= ~TSE_CLOSED;
|
||||
/* auto open these cases */
|
||||
if(!parent || (RNA_property_type(&parent->rnaptr, parent->directdata)) == PROP_POINTER)
|
||||
if(!tselem->used)
|
||||
tselem->flag &= ~TSE_CLOSED;
|
||||
|
||||
if(!(tselem->flag & TSE_CLOSED)) {
|
||||
for(a=0; a<tot; a++)
|
||||
@@ -3137,6 +3139,96 @@ void outliner_operation_menu(Scene *scene, ARegion *ar, SpaceOops *soops)
|
||||
|
||||
/* ***************** DRAW *************** */
|
||||
|
||||
static int tselem_rna_icon(PointerRNA *ptr)
|
||||
{
|
||||
StructRNA *rnatype= ptr->type;
|
||||
|
||||
if(rnatype == &RNA_Scene)
|
||||
return ICON_SCENE_DEHLT;
|
||||
else if(rnatype == &RNA_World)
|
||||
return ICON_WORLD;
|
||||
else if(rnatype == &RNA_Object)
|
||||
return ICON_OBJECT;
|
||||
else if(rnatype == &RNA_Mesh)
|
||||
return ICON_MESH;
|
||||
else if(rnatype == &RNA_MVert)
|
||||
return ICON_VERTEXSEL;
|
||||
else if(rnatype == &RNA_MEdge)
|
||||
return ICON_EDGESEL;
|
||||
else if(rnatype == &RNA_MFace)
|
||||
return ICON_FACESEL;
|
||||
else if(rnatype == &RNA_MTFace)
|
||||
return ICON_FACESEL_HLT;
|
||||
else if(rnatype == &RNA_MVertGroup)
|
||||
return ICON_VGROUP;
|
||||
else if(rnatype == &RNA_Curve)
|
||||
return ICON_CURVE;
|
||||
else if(rnatype == &RNA_MetaBall)
|
||||
return ICON_MBALL;
|
||||
else if(rnatype == &RNA_MetaElement)
|
||||
return ICON_OUTLINER_DATA_META;
|
||||
else if(rnatype == &RNA_Lattice)
|
||||
return ICON_LATTICE;
|
||||
else if(rnatype == &RNA_Armature)
|
||||
return ICON_ARMATURE;
|
||||
else if(rnatype == &RNA_Bone)
|
||||
return ICON_BONE_DEHLT;
|
||||
else if(rnatype == &RNA_Camera)
|
||||
return ICON_CAMERA;
|
||||
else if(rnatype == &RNA_Lamp)
|
||||
return ICON_LAMP;
|
||||
else if(rnatype == &RNA_Group)
|
||||
return ICON_GROUP;
|
||||
/*else if(rnatype == &RNA_Particle)
|
||||
return ICON_PARTICLES);*/
|
||||
else if(rnatype == &RNA_Material)
|
||||
return ICON_MATERIAL;
|
||||
/*else if(rnatype == &RNA_Texture)
|
||||
return ICON_TEXTURE);*/
|
||||
else if(rnatype == &RNA_Image)
|
||||
return ICON_TEXTURE;
|
||||
else if(rnatype == &RNA_Screen)
|
||||
return ICON_SPLITSCREEN;
|
||||
else if(rnatype == &RNA_NodeTree)
|
||||
return ICON_NODE;
|
||||
/*else if(rnatype == &RNA_Text)
|
||||
return ICON_TEXT);*/
|
||||
else if(rnatype == &RNA_Sound)
|
||||
return ICON_SOUND;
|
||||
else if(rnatype == &RNA_Brush)
|
||||
return ICON_TPAINT_HLT;
|
||||
else if(rnatype == &RNA_Library)
|
||||
return ICON_LIBRARY_DEHLT;
|
||||
/*else if(rnatype == &RNA_Action)
|
||||
return ICON_ACTION);*/
|
||||
else if(rnatype == &RNA_Ipo)
|
||||
return ICON_IPO_DEHLT;
|
||||
else if(rnatype == &RNA_Key)
|
||||
return ICON_SHAPEKEY;
|
||||
else if(rnatype == &RNA_Main)
|
||||
return ICON_BLENDER;
|
||||
else if(rnatype == &RNA_Struct)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_Property)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_BooleanProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_IntProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_FloatProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_EnumProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_EnumPropertyItem)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_PointerProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_CollectionProperty)
|
||||
return ICON_RNA;
|
||||
else
|
||||
return ICON_DOT;
|
||||
}
|
||||
|
||||
static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElement *te)
|
||||
{
|
||||
if(tselem->type) {
|
||||
@@ -3241,77 +3333,7 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
|
||||
UI_icon_draw(x, y, ICON_OBJECT);
|
||||
break;
|
||||
case TSE_RNA_STRUCT:
|
||||
{
|
||||
PointerRNA *ptr= &te->rnaptr;
|
||||
const char *ident = RNA_struct_identifier(ptr);
|
||||
|
||||
if (strcmp(ident, "Scene") == 0)
|
||||
UI_icon_draw(x, y, ICON_SCENE_DEHLT);
|
||||
else if (strcmp(ident, "World") == 0)
|
||||
UI_icon_draw(x, y, ICON_WORLD);
|
||||
else if (strcmp(ident, "Object") == 0)
|
||||
UI_icon_draw(x, y, ICON_OBJECT);
|
||||
else if (strcmp(ident, "Mesh") == 0)
|
||||
UI_icon_draw(x, y, ICON_MESH);
|
||||
else if (strcmp(ident, "MVert") == 0)
|
||||
UI_icon_draw(x, y, ICON_VERTEXSEL);
|
||||
else if (strcmp(ident, "MEdge") == 0)
|
||||
UI_icon_draw(x, y, ICON_EDGESEL);
|
||||
else if (strcmp(ident, "MFace") == 0)
|
||||
UI_icon_draw(x, y, ICON_FACESEL);
|
||||
else if (strcmp(ident, "MTFace") == 0)
|
||||
UI_icon_draw(x, y, ICON_FACESEL_HLT);
|
||||
else if (strcmp(ident, "MVertGroup") == 0)
|
||||
UI_icon_draw(x, y, ICON_VGROUP);
|
||||
else if (strcmp(ident, "Curve") == 0)
|
||||
UI_icon_draw(x, y, ICON_CURVE);
|
||||
else if (strcmp(ident, "MetaBall") == 0)
|
||||
UI_icon_draw(x, y, ICON_MBALL);
|
||||
else if (strcmp(ident, "MetaElement") == 0)
|
||||
UI_icon_draw(x, y, ICON_OUTLINER_DATA_META);
|
||||
else if (strcmp(ident, "Lattice") == 0)
|
||||
UI_icon_draw(x, y, ICON_LATTICE);
|
||||
else if (strcmp(ident, "Armature") == 0)
|
||||
UI_icon_draw(x, y, ICON_ARMATURE);
|
||||
else if (strcmp(ident, "Bone") == 0)
|
||||
UI_icon_draw(x, y, ICON_BONE_DEHLT);
|
||||
else if (strcmp(ident, "Camera") == 0)
|
||||
UI_icon_draw(x, y, ICON_CAMERA);
|
||||
else if (strcmp(ident, "Lamp") == 0)
|
||||
UI_icon_draw(x, y, ICON_LAMP);
|
||||
else if (strcmp(ident, "Group") == 0)
|
||||
UI_icon_draw(x, y, ICON_GROUP);
|
||||
else if (strcmp(ident, "Particle") == 0)
|
||||
UI_icon_draw(x, y, ICON_PARTICLES);
|
||||
else if (strcmp(ident, "Material") == 0)
|
||||
UI_icon_draw(x, y, ICON_MATERIAL);
|
||||
else if (strcmp(ident, "Texture") == 0)
|
||||
UI_icon_draw(x, y, ICON_TEXTURE);
|
||||
else if (strcmp(ident, "Image") == 0)
|
||||
UI_icon_draw(x, y, ICON_TEXTURE);
|
||||
else if (strcmp(ident, "Screen") == 0)
|
||||
UI_icon_draw(x, y, ICON_SPLITSCREEN);
|
||||
else if (strcmp(ident, "NodeTree") == 0)
|
||||
UI_icon_draw(x, y, ICON_NODE);
|
||||
else if (strcmp(ident, "Text") == 0)
|
||||
UI_icon_draw(x, y, ICON_TEXT);
|
||||
else if (strcmp(ident, "Sound") == 0)
|
||||
UI_icon_draw(x, y, ICON_SOUND);
|
||||
else if (strcmp(ident, "Brush") == 0)
|
||||
UI_icon_draw(x, y, ICON_TPAINT_HLT);
|
||||
else if (strcmp(ident, "Library") == 0)
|
||||
UI_icon_draw(x, y, ICON_LIBRARY_DEHLT);
|
||||
else if (strcmp(ident, "Action") == 0)
|
||||
UI_icon_draw(x, y, ICON_ACTION);
|
||||
else if (strcmp(ident, "Ipo") == 0)
|
||||
UI_icon_draw(x, y, ICON_IPO_DEHLT);
|
||||
else if (strcmp(ident, "Key") == 0)
|
||||
UI_icon_draw(x, y, ICON_SHAPEKEY);
|
||||
else if (strcmp(ident, "Main") == 0)
|
||||
UI_icon_draw(x, y, ICON_BLENDER);
|
||||
else
|
||||
UI_icon_draw(x, y, ICON_RNA);
|
||||
}
|
||||
UI_icon_draw(x, y, tselem_rna_icon(&te->rnaptr));
|
||||
break;
|
||||
default:
|
||||
UI_icon_draw(x, y, ICON_DOT); break;
|
||||
@@ -4080,6 +4102,32 @@ static uiBut *outliner_draw_rnabut(uiBlock *block, PointerRNA *ptr, PropertyRNA
|
||||
case PROP_STRING:
|
||||
but= uiDefButR(block, TEX, 0, "", x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
|
||||
break;
|
||||
case PROP_POINTER: {
|
||||
PointerRNA pptr;
|
||||
PropertyRNA *nameprop;
|
||||
char *text, *descr, textbuf[256];
|
||||
int icon;
|
||||
|
||||
RNA_property_pointer_get(ptr, prop, &pptr);
|
||||
|
||||
if(!pptr.data)
|
||||
return NULL;
|
||||
|
||||
icon= tselem_rna_icon(&pptr);
|
||||
nameprop= RNA_struct_name_property(&pptr);
|
||||
|
||||
if(nameprop) {
|
||||
text= RNA_property_string_get_alloc(&pptr, nameprop, textbuf, sizeof(textbuf));
|
||||
but= uiDefIconTextBut(block, LABEL, 0, icon, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, descr);
|
||||
if(text != textbuf)
|
||||
MEM_freeN(text);
|
||||
}
|
||||
else {
|
||||
text= (char*)RNA_struct_ui_name(&pptr);
|
||||
descr= (char*)RNA_property_ui_description(&pptr, prop);
|
||||
but= uiDefIconTextBut(block, LABEL, 0, icon, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, descr);
|
||||
}
|
||||
}
|
||||
default:
|
||||
but= NULL;
|
||||
break;
|
||||
@@ -4105,7 +4153,8 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
|
||||
ptr= &te->rnaptr;
|
||||
prop= te->directdata;
|
||||
|
||||
outliner_draw_rnabut(block, ptr, prop, -1, xstart, te->ys, OL_RNA_COL_SIZEX, OL_H-1);
|
||||
if(!(RNA_property_type(ptr, prop) == PROP_POINTER && (tselem->flag & TSE_CLOSED)==0))
|
||||
outliner_draw_rnabut(block, ptr, prop, -1, xstart, te->ys, OL_RNA_COL_SIZEX, OL_H-1);
|
||||
}
|
||||
else if(tselem->type == TSE_RNA_ARRAY_ELEM) {
|
||||
ptr= &te->rnaptr;
|
||||
|
||||
@@ -78,7 +78,8 @@ typedef struct IDProperty {
|
||||
some cleanup of blenkernel, most likely.*/
|
||||
#define IDP_ID 7
|
||||
#define IDP_DOUBLE 8
|
||||
#define IDP_NUMTYPES 9
|
||||
#define IDP_IDPARRAY 9
|
||||
#define IDP_NUMTYPES 10
|
||||
|
||||
/* add any future new id property types here.*/
|
||||
|
||||
|
||||
@@ -234,6 +234,7 @@ PropertyRNA *RNA_struct_iterator_property(PointerRNA *ptr);
|
||||
int RNA_struct_is_ID(PointerRNA *ptr);
|
||||
|
||||
PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier);
|
||||
const struct ListBase *RNA_struct_defined_properties(StructRNA *srna);
|
||||
|
||||
/* Properties
|
||||
*
|
||||
|
||||
@@ -140,12 +140,12 @@ static int rna_idproperty_verify_valid(PropertyRNA *prop, IDProperty *idprop)
|
||||
* to have a certain array length you can count on that staying so */
|
||||
|
||||
switch(idprop->type) {
|
||||
case IDP_IDPARRAY:
|
||||
if(prop->type != PROP_COLLECTION)
|
||||
return 0;
|
||||
break;
|
||||
case IDP_ARRAY:
|
||||
if(idprop->subtype == IDP_GROUP) {
|
||||
if(prop->type != PROP_COLLECTION)
|
||||
return 0;
|
||||
}
|
||||
else if(prop->arraylength != idprop->len)
|
||||
if(prop->arraylength != idprop->len)
|
||||
return 0;
|
||||
|
||||
if(idprop->subtype == IDP_FLOAT && prop->type != PROP_FLOAT)
|
||||
@@ -287,6 +287,11 @@ PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
|
||||
return prop;
|
||||
}
|
||||
|
||||
const struct ListBase *RNA_struct_defined_properties(StructRNA *srna)
|
||||
{
|
||||
return &srna->properties;
|
||||
}
|
||||
|
||||
/* Property Information */
|
||||
|
||||
const char *RNA_property_identifier(PointerRNA *ptr, PropertyRNA *prop)
|
||||
@@ -744,7 +749,7 @@ void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, int index,
|
||||
idprop= IDP_New(IDP_ARRAY, val, (char*)prop->identifier);
|
||||
IDP_AddToGroup(group, idprop);
|
||||
memcpy(idprop->data.pointer, fprop->defaultarray, sizeof(float)*prop->arraylength);
|
||||
((float*)idprop->data.pointer)[index]= value;
|
||||
((float*)IDP_Array(idprop))[index]= value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -950,7 +955,7 @@ static void rna_property_collection_get_idp(CollectionPropertyIterator *iter)
|
||||
{
|
||||
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)iter->prop;
|
||||
|
||||
iter->ptr.data= rna_iterator_array_dereference_get(iter);
|
||||
iter->ptr.data= rna_iterator_array_get(iter);
|
||||
iter->ptr.type= cprop->structtype;
|
||||
rna_pointer_inherit_id(cprop->structtype, &iter->parent, &iter->ptr);
|
||||
}
|
||||
@@ -964,9 +969,9 @@ void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, Collectio
|
||||
iter->prop= prop;
|
||||
|
||||
if(idprop)
|
||||
rna_iterator_array_begin(iter, IDP_Array(idprop), sizeof(void*), idprop->len, NULL);
|
||||
rna_iterator_array_begin(iter, IDP_IDPArray(idprop), sizeof(IDProperty), idprop->len, NULL);
|
||||
else
|
||||
rna_iterator_array_begin(iter, NULL, sizeof(void*), 0, NULL);
|
||||
rna_iterator_array_begin(iter, NULL, sizeof(IDProperty), 0, NULL);
|
||||
|
||||
if(iter->valid)
|
||||
rna_property_collection_get_idp(iter);
|
||||
@@ -1055,19 +1060,29 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA
|
||||
IDProperty *idprop;
|
||||
|
||||
if((idprop=rna_idproperty_check(&prop, ptr))) {
|
||||
IDP_ResizeArray(idprop, idprop->len+1);
|
||||
IDPropertyTemplate val;
|
||||
IDProperty *item;
|
||||
val.i= 0;
|
||||
|
||||
item= IDP_New(IDP_GROUP, val, "");
|
||||
IDP_AppendArray(idprop, item);
|
||||
IDP_FreeProperty(item);
|
||||
MEM_freeN(item);
|
||||
}
|
||||
else if(prop->flag & PROP_IDPROPERTY) {
|
||||
IDProperty *group, *item;
|
||||
IDPropertyTemplate val;
|
||||
IDProperty *group;
|
||||
|
||||
val.array.len= 1;
|
||||
val.array.type= IDP_GROUP;
|
||||
val.i= 0;
|
||||
|
||||
group= rna_idproperties_get(ptr->type, ptr->data, 1);
|
||||
if(group) {
|
||||
idprop= IDP_New(IDP_ARRAY, val, (char*)prop->identifier);
|
||||
idprop= IDP_NewIDPArray(prop->identifier);
|
||||
IDP_AddToGroup(group, idprop);
|
||||
|
||||
item= IDP_New(IDP_GROUP, val, "");
|
||||
IDP_AppendArray(idprop, item);
|
||||
IDP_FreeProperty(item);
|
||||
MEM_freeN(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1076,9 +1091,8 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA
|
||||
if(r_ptr) {
|
||||
if(idprop) {
|
||||
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
||||
IDProperty **array= (IDProperty**)IDP_Array(idprop);
|
||||
|
||||
r_ptr->data= array[idprop->len-1];
|
||||
r_ptr->data= IDP_GetIndexArray(idprop, idprop->len-1);
|
||||
r_ptr->type= cprop->structtype;
|
||||
rna_pointer_inherit_id(NULL, ptr, r_ptr);
|
||||
}
|
||||
@@ -1092,7 +1106,7 @@ void RNA_property_collection_clear(PointerRNA *ptr, PropertyRNA *prop)
|
||||
IDProperty *idprop;
|
||||
|
||||
if((idprop=rna_idproperty_check(&prop, ptr)))
|
||||
IDP_FreeArray(idprop);
|
||||
IDP_ResizeIDPArray(idprop, 0);
|
||||
}
|
||||
|
||||
int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr)
|
||||
@@ -1949,3 +1963,4 @@ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop)
|
||||
BLI_dynstr_free(dynstr);
|
||||
return cstring;
|
||||
}
|
||||
|
||||
|
||||
@@ -426,7 +426,7 @@ static void rna_def_struct(BlenderRNA *brna)
|
||||
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
|
||||
RNA_def_property_struct_type(prop, "Struct");
|
||||
RNA_def_property_pointer_funcs(prop, "rna_Struct_base_get", NULL, NULL);
|
||||
RNA_def_property_ui_text(prop, "base", "Struct definition this is derived from.");
|
||||
RNA_def_property_ui_text(prop, "Base", "Struct definition this is derived from.");
|
||||
|
||||
prop= RNA_def_property(srna, "name_property", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
|
||||
|
||||
@@ -36,11 +36,12 @@
|
||||
static wmOperator *rna_OperatorProperties_find_operator(PointerRNA *ptr)
|
||||
{
|
||||
wmWindowManager *wm= ptr->id.data;
|
||||
IDProperty *properties= *(IDProperty**)ptr->data;
|
||||
wmOperator *op;
|
||||
|
||||
if(wm)
|
||||
for(op=wm->operators.first; op; op=op->next)
|
||||
if(op->properties == ptr->data)
|
||||
if(op->properties == properties)
|
||||
return op;
|
||||
|
||||
return NULL;
|
||||
@@ -68,6 +69,12 @@ static int rna_Operator_name_length(PointerRNA *ptr)
|
||||
return strlen(op->type->name);
|
||||
}
|
||||
|
||||
static void *rna_Operator_properties_get(PointerRNA *ptr)
|
||||
{
|
||||
wmOperator *op= (wmOperator*)ptr->data;
|
||||
return &op->properties;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void rna_def_operator(BlenderRNA *brna)
|
||||
@@ -88,12 +95,11 @@ static void rna_def_operator(BlenderRNA *brna)
|
||||
prop= RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_struct_type(prop, "OperatorProperties");
|
||||
RNA_def_property_ui_text(prop, "Properties", "");
|
||||
RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL);
|
||||
|
||||
srna= RNA_def_struct(brna, "OperatorProperties", NULL);
|
||||
RNA_def_struct_ui_text(srna, "Operator Properties", "DOC_BROKEN");
|
||||
RNA_def_struct_funcs(srna, NULL, "rna_OperatorProperties_refine");
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void rna_def_operator_utils(BlenderRNA *brna)
|
||||
|
||||
@@ -56,9 +56,6 @@ void WM_operator_free(wmOperator *op)
|
||||
{
|
||||
if(op->properties) {
|
||||
IDP_FreeProperty(op->properties);
|
||||
|
||||
/* This need change, when the idprop code only
|
||||
* need call IDP_FreeProperty. (check BKE_idprop.h) */
|
||||
MEM_freeN(op->properties);
|
||||
op->properties= NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user