[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18183] branches/blender2.5/blender/source /blender: RNA
Brecht Van Lommel
brecht at blender.org
Tue Dec 30 22:28:28 CET 2008
Revision: 18183
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18183
Author: blendix
Date: 2008-12-30 22:28:27 +0100 (Tue, 30 Dec 2008)
Log Message:
-----------
RNA
* The RNA viewer is now more integrated with the outliner, as
a "Datablocks" view, with a tree structure.
* Still some issues to be solved with persistence, and also
memory usage is problematic when expanding a million vertices
in a mesh for example, though it will not build closed parts
of the tree.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/blenkernel/intern/context.c
branches/blender2.5/blender/source/blender/editors/interface/interface.c
branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
branches/blender2.5/blender/source/blender/editors/space_outliner/outliner.c
branches/blender2.5/blender/source/blender/editors/space_outliner/outliner_header.c
branches/blender2.5/blender/source/blender/editors/space_outliner/outliner_intern.h
branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
branches/blender2.5/blender/source/blender/makesdna/DNA_space_types.h
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_files.c
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/context.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/context.c 2008-12-30 21:25:56 UTC (rev 18182)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/context.c 2008-12-30 21:28:27 UTC (rev 18183)
@@ -239,12 +239,12 @@
}
if(!done && recursion < 2 && C->wm.region) {
C->data.recursion= 2;
- if(C->wm.region->type->context)
+ if(C->wm.region->type && C->wm.region->type->context)
done= C->wm.region->type->context(C, member, result);
}
if(!done && recursion < 3 && C->wm.area) {
C->data.recursion= 3;
- if(C->wm.area->type->context)
+ if(C->wm.area->type && C->wm.area->type->context)
done= C->wm.area->type->context(C, member, result);
}
if(!done && recursion < 4 && C->wm.screen) {
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c 2008-12-30 21:25:56 UTC (rev 18182)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c 2008-12-30 21:28:27 UTC (rev 18183)
@@ -1021,20 +1021,35 @@
/* for buttons pointing to color for example */
void ui_get_but_vectorf(uiBut *but, float *vec)
{
- void *poin;
- int pointype;
+ PropertyRNA *prop;
+ int a, tot;
- poin= (but->editvec)? (void*)but->editvec: but->poin;
- pointype= (but->editvec)? FLO: but->pointype;
+ if(but->editvec) {
+ VECCOPY(vec, but->editvec);
+ return;
+ }
- if(!but->editvec && pointype == CHA) {
- char *cp= (char *)poin;
+ if(but->rnaprop) {
+ prop= but->rnaprop;
+
+ vec[0]= vec[1]= vec[2]= 0.0f;
+
+ if(RNA_property_type(&but->rnapoin, prop) == PROP_FLOAT) {
+ tot= RNA_property_array_length(&but->rnapoin, prop);
+ tot= MIN2(tot, 3);
+
+ for(a=0; a<tot; a++)
+ vec[a]= RNA_property_float_get_array(&but->rnapoin, prop, a);
+ }
+ }
+ else if(but->pointype == CHA) {
+ char *cp= (char *)but->poin;
vec[0]= ((float)cp[0])/255.0;
vec[1]= ((float)cp[1])/255.0;
vec[2]= ((float)cp[2])/255.0;
}
- else if(pointype == FLO) {
- float *fp= (float *)poin;
+ else if(but->pointype == FLO) {
+ float *fp= (float *)but->poin;
VECCOPY(vec, fp);
}
}
@@ -1042,20 +1057,33 @@
/* for buttons pointing to color for example */
void ui_set_but_vectorf(uiBut *but, float *vec)
{
- void *poin;
- int pointype;
+ PropertyRNA *prop;
+ int a, tot;
- poin= (but->editvec)? (void*)but->editvec: but->poin;
- pointype= (but->editvec)? FLO: but->pointype;
+ if(but->editvec) {
+ VECCOPY(but->editvec, vec);
+ return;
+ }
- if(!but->editvec && but->pointype == CHA) {
- char *cp= (char *)poin;
+ if(but->rnaprop) {
+ prop= but->rnaprop;
+
+ if(RNA_property_type(&but->rnapoin, prop) == PROP_FLOAT) {
+ tot= RNA_property_array_length(&but->rnapoin, prop);
+ tot= MIN2(tot, 3);
+
+ for(a=0; a<tot; a++)
+ RNA_property_float_set_array(&but->rnapoin, prop, a, vec[a]);
+ }
+ }
+ else if(but->pointype == CHA) {
+ char *cp= (char *)but->poin;
cp[0]= (char)(0.5 +vec[0]*255.0);
cp[1]= (char)(0.5 +vec[1]*255.0);
cp[2]= (char)(0.5 +vec[2]*255.0);
}
- else if( but->pointype == FLO ) {
- float *fp= (float *)poin;
+ else if(but->pointype == FLO) {
+ float *fp= (float *)but->poin;
VECCOPY(fp, vec);
}
}
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c 2008-12-30 21:25:56 UTC (rev 18182)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c 2008-12-30 21:28:27 UTC (rev 18183)
@@ -2370,21 +2370,14 @@
static void ui_draw_but_COL(uiBut *but)
{
- float *fp;
+ float col[3];
char colr, colg, colb;
- if( but->pointype==FLO ) {
- fp= (float *)but->poin;
- colr= floor(255.0*fp[0]+0.5);
- colg= floor(255.0*fp[1]+0.5);
- colb= floor(255.0*fp[2]+0.5);
- }
- else {
- char *cp= (char *)but->poin;
- colr= cp[0];
- colg= cp[1];
- colb= cp[2];
- }
+ ui_get_but_vectorf(but, col);
+
+ colr= floor(255.0*col[0]+0.5);
+ colg= floor(255.0*col[1]+0.5);
+ colb= floor(255.0*col[2]+0.5);
/* exception... hrms, but can't simply use the emboss callback for this now. */
/* this button type needs review, and nice integration with rest of API here */
Modified: branches/blender2.5/blender/source/blender/editors/space_outliner/outliner.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_outliner/outliner.c 2008-12-30 21:25:56 UTC (rev 18182)
+++ branches/blender2.5/blender/source/blender/editors/space_outliner/outliner.c 2008-12-30 21:28:27 UTC (rev 18183)
@@ -95,6 +95,8 @@
#include "UI_view2d.h"
#include "UI_text.h"
+#include "RNA_access.h"
+
#include "ED_object.h"
#include "outliner_intern.h"
@@ -113,8 +115,12 @@
#define OL_TOG_RESTRICT_SELECTX 36
#define OL_TOG_RESTRICT_RENDERX 18
-#define OL_TOGW OL_TOG_RESTRICT_VIEWX
+#define OL_TOGW OL_TOG_RESTRICT_VIEWX
+#define OL_RNA_COLX 300
+#define OL_RNA_COL_SIZEX 150
+#define OL_RNA_COL_SPACEX 50
+
#define TS_CHUNK 128
#define TREESTORE(a) ((a)?soops->treestore->data+(a)->store_index:NULL)
@@ -150,7 +156,8 @@
/* each element used once, for ID blocks with more users to have each a treestore */
for(a=0, tselem= ts->data; a<ts->usedelem; a++, tselem++) tselem->used= 0;
- /* cleanup only after reading file or undo step */
+ /* cleanup only after reading file or undo step, and always for
+ * RNA datablocks view in order to save memory */
if(soops->storeflag & SO_TREESTORE_CLEANUP) {
for(a=0, tselem= ts->data; a<ts->usedelem; a++, tselem++) {
@@ -243,6 +250,8 @@
outliner_free_tree(&te->subtree);
BLI_remlink(lb, te);
+
+ if(te->flag & TE_FREE_NAME) MEM_freeN(te->name);
MEM_freeN(te);
}
}
@@ -273,6 +282,24 @@
}
}
+static void outliner_rna_width(SpaceOops *soops, ListBase *lb, int *w, int startx)
+{
+ TreeElement *te= lb->first;
+ while(te) {
+ TreeStoreElem *tselem= TREESTORE(te);
+ /*if(te->xend) {
+ if(te->xend > *w)
+ *w = te->xend;
+ }*/
+ if(startx+100 > *w)
+ *w = startx+100;
+
+ if((tselem->flag & TSE_CLOSED)==0)
+ outliner_rna_width(soops, &te->subtree, w, startx+OL_X);
+ te= te->next;
+ }
+}
+
static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index)
{
TreeElement *te= lb->first, *tes;
@@ -551,7 +578,9 @@
te->parent= parent;
te->index= index; // for data arays
- if((type!=TSE_SEQUENCE) && (type != TSE_SEQ_STRIP) && (type != TSE_SEQUENCE_DUP)) {
+ if(ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP));
+ else if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM));
+ else {
te->name= id->name+2; // default, can be overridden by Library or non-ID data
te->idcode= GS(id->name);
}
@@ -959,6 +988,118 @@
te->directdata= seq;
te->name= seq->strip->stripdata->name;
}
+ else if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) {
+ PointerRNA pptr, propptr, *ptr= (PointerRNA*)idv;
+ PropertyRNA *prop, *iterprop, *nameprop;
+ PropertyType proptype;
+ PropertySubType propsubtype;
+ int a, tot;
+
+ /* we do lazy build, for speed and to avoid infinite recusion */
+
+ if(ptr->data == NULL) {
+ te->name= "<null>";
+ }
+ else if(type == TSE_RNA_STRUCT) {
+ /* struct */
+ nameprop= RNA_struct_name_property(ptr);
+
+ if(nameprop) {
+ te->name= RNA_property_string_get_alloc(ptr, nameprop, NULL, 0);
+ te->flag |= TE_FREE_NAME;
+ }
+ else
+ te->name= (char*)RNA_struct_ui_name(ptr);
+
+ iterprop= RNA_struct_iterator_property(ptr);
+ tot= RNA_property_collection_length(ptr, iterprop);
+
+ if(!parent)
+ tselem->flag &= ~TSE_CLOSED;
+
+ if(!(tselem->flag & TSE_CLOSED)) {
+ for(a=0; a<tot; a++)
+ outliner_add_element(soops, &te->subtree, (void*)ptr, te, TSE_RNA_PROPERTY, a);
+ }
+ else if(tot)
+ te->flag |= TE_LAZY_CLOSED;
+
+ te->rnaptr= *ptr;
+ }
+ else if(type == TSE_RNA_PROPERTY) {
+ /* property */
+ iterprop= RNA_struct_iterator_property(ptr);
+ RNA_property_collection_lookup_int(ptr, iterprop, index, &propptr);
+
+ prop= propptr.data;
+ proptype= RNA_property_type(ptr, prop);
+
+ te->name= (char*)RNA_property_ui_name(ptr, prop);
+ te->directdata= prop;
+ te->rnaptr= *ptr;
+
+ if(proptype == PROP_POINTER) {
+ RNA_property_pointer_get(ptr, prop, &pptr);
+
+ if(pptr.data) {
+ if(!(tselem->flag & TSE_CLOSED))
+ outliner_add_element(soops, &te->subtree, (void*)&pptr, te, TSE_RNA_STRUCT, -1);
+ else
+ te->flag |= TE_LAZY_CLOSED;
+ }
+ }
+ else if(proptype == PROP_COLLECTION) {
+ tot= RNA_property_collection_length(ptr, prop);
+
+ if(!(tselem->flag & TSE_CLOSED)) {
+ for(a=0; a<tot; a++) {
+ RNA_property_collection_lookup_int(ptr, prop, a, &pptr);
+ outliner_add_element(soops, &te->subtree, (void*)&pptr, te, TSE_RNA_STRUCT, -1);
+ }
+ }
+ else if(tot)
+ te->flag |= TE_LAZY_CLOSED;
+ }
+ else if(ELEM3(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) {
+ tot= RNA_property_array_length(ptr, prop);
+
+ if(!(tselem->flag & TSE_CLOSED)) {
+ for(a=0; a<tot; a++)
+ outliner_add_element(soops, &te->subtree, (void*)ptr, te, TSE_RNA_ARRAY_ELEM, a);
+ }
+ else if(tot)
+ te->flag |= TE_LAZY_CLOSED;
+ }
+ }
+ else if(type == TSE_RNA_ARRAY_ELEM) {
+ /* array property element */
+ static char *vectoritem[4]= {" x", " y", " z", " w"};
+ static char *quatitem[4]= {" w", " x", " y", " z"};
+ static char *coloritem[4]= {" r", " g", " b", " a"};
+
+ prop= parent->directdata;
+ proptype= RNA_property_type(ptr, prop);
+ propsubtype= RNA_property_subtype(ptr, prop);
+ tot= RNA_property_array_length(ptr, prop);
+
+ te->directdata= prop;
+ te->rnaptr= *ptr;
+ te->index= index;
+
+ if(tot == 4 && propsubtype == PROP_ROTATION)
+ te->name= quatitem[index];
+ else if(tot <= 4 && (propsubtype == PROP_VECTOR || propsubtype == PROP_ROTATION))
+ te->name= vectoritem[index];
+ else if(tot <= 4 && propsubtype == PROP_COLOR)
+ te->name= coloritem[index];
+ else {
+ te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName");
+ sprintf(te->name, " %d", index);
+ te->flag |= TE_FREE_NAME;
+ }
+ }
+ }
+
return te;
}
@@ -1043,7 +1184,7 @@
}
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list