Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-08-11 01:31:05 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-08-11 01:31:05 +0400
commitf6682ab773c91ef0f760efdbe69f1a599cc1ac95 (patch)
tree94cd702de42afc5607e3159b54ee1698d4233347 /source/blender/editors
parent6e5b78a2774b3d10226e3c48e558a9059086e416 (diff)
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.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/anim_ipo_utils.c24
-rw-r--r--source/blender/editors/interface/interface_layout.c41
-rw-r--r--source/blender/editors/space_outliner/outliner.c25
3 files changed, 27 insertions, 63 deletions
diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c
index aecf437a30b..394cc53dda2 100644
--- a/source/blender/editors/animation/anim_ipo_utils.c
+++ b/source/blender/editors/animation/anim_ipo_utils.c
@@ -149,25 +149,13 @@ void getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
/* Array Index - only if applicable */
if (RNA_property_array_length(prop)) {
- static char *vectoritem[4]= {"X ", "Y ", "Z ", "W "};
- static char *quatitem[4]= {"W ", "X ", "Y ", "Z "};
- static char *coloritem[4]= {"R ", "G ", "B ", "A "};
+ char c= RNA_property_array_item_char(prop, fcu->array_index);
- int tot= RNA_property_array_length(prop);
- int propsubtype= RNA_property_subtype(prop);
-
- /* get string to use for array index */
- if ((tot == 4) && (propsubtype == PROP_ROTATION))
- arrayname= quatitem[fcu->array_index];
- else if ( (tot <= 4) && ((propsubtype == PROP_VECTOR) || (propsubtype == PROP_ROTATION)) )
- arrayname= vectoritem[fcu->array_index];
- else if ((tot <= 4) && (propsubtype == PROP_COLOR))
- arrayname= coloritem[fcu->array_index];
- else {
- /* we need to write the index to a temp buffer (in py syntax), as it is a number... */
- sprintf(arrayindbuf, "[%d]", fcu->array_index);
- arrayname= &arrayindbuf[0];
- }
+ /* we need to write the index to a temp buffer (in py syntax) */
+ if(c) sprintf(arrayindbuf, "%c ", c);
+ else sprintf(arrayindbuf, "[%d]", fcu->array_index);
+
+ arrayname= &arrayindbuf[0];
}
else {
/* no array index */
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index b90d930475a..60a043a1394 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -379,31 +379,25 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon
but->type= NUMSLI;
}
}
- else if(len <= 4 && ELEM3(subtype, PROP_ROTATION, PROP_VECTOR, PROP_COLOR)) {
- if(subtype == PROP_COLOR)
+ else {
+ if(ELEM(subtype, PROP_COLOR, PROP_RGB))
uiDefAutoButR(block, ptr, prop, -1, "", 0, 0, 0, w, UI_UNIT_Y);
- if(subtype != PROP_COLOR || expand) {
+ if(!ELEM(subtype, PROP_COLOR, PROP_RGB) || expand) {
/* layout for known array subtypes */
- static char vectoritem[4]= {'X', 'Y', 'Z', 'W'};
- static char quatitem[4]= {'W', 'X', 'Y', 'Z'};
- static char coloritem[4]= {'R', 'G', 'B', 'A'};
char str[3];
for(a=0; a<len; a++) {
- if(len == 4 && subtype == PROP_ROTATION)
- str[0]= quatitem[a];
- else if(subtype == PROP_VECTOR || subtype == PROP_ROTATION)
- str[0]= vectoritem[a];
- else
- str[0]= coloritem[a];
-
- if(type == PROP_BOOLEAN) {
- str[1]= '\0';
- }
- else {
- str[1]= ':';
- str[2]= '\0';
+ str[0]= RNA_property_array_item_char(prop, a);
+
+ if(str[0]) {
+ if(type == PROP_BOOLEAN) {
+ str[1]= '\0';
+ }
+ else {
+ str[1]= ':';
+ str[2]= '\0';
+ }
}
but= uiDefAutoButR(block, ptr, prop, a, str, 0, 0, 0, w, UI_UNIT_Y);
@@ -411,19 +405,12 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon
but->type= NUMSLI;
}
}
- else if(subtype == PROP_COLOR && len == 4) {
+ else if(ELEM(subtype, PROP_COLOR, PROP_RGB) && len == 4) {
but= uiDefAutoButR(block, ptr, prop, 3, "A:", 0, 0, 0, w, UI_UNIT_Y);
if(slider && but->type==NUM)
but->type= NUMSLI;
}
}
- else {
- for(a=0; a<len; a++) {
- but= uiDefAutoButR(block, ptr, prop, a, "", 0, 0, 0, w, UI_UNIT_Y);
- if(slider && but->type==NUM)
- but->type= NUMSLI;
- }
- }
uiBlockSetCurLayout(block, layout);
}
diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c
index 51cc8507ff8..4f5d3f8f736 100644
--- a/source/blender/editors/space_outliner/outliner.c
+++ b/source/blender/editors/space_outliner/outliner.c
@@ -1096,31 +1096,20 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
}
}
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"};
+ char c;
prop= parent->directdata;
- proptype= RNA_property_type(prop);
- propsubtype= RNA_property_subtype(prop);
- tot= RNA_property_array_length(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+1);
- te->flag |= TE_FREE_NAME;
- }
+ c= RNA_property_array_item_char(prop, index);
+
+ te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName");
+ if(c) sprintf(te->name, " %c", c);
+ else sprintf(te->name, " %d", index+1);
+ te->flag |= TE_FREE_NAME;
}
}
else if(type == TSE_KEYMAP) {