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-03-13 16:38:41 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-03-13 16:38:41 +0300
commit4c3d64116e2c74315afea7b005ffaf320178337f (patch)
tree86d6db3a35fd5847387c2970ba0d160d9f92b0a7 /source/blender/editors/interface/interface_utils.c
parenta4793a3b4ac298a651f7bab0bafd809287647509 (diff)
2.5: UI Layout Engine, initial code.
* As a test, used by: * Object buttons, tried to make it match the mockup. * Text window header. * Text window properties panel. * Panel interaction with view2d is still problematic, need to make this work properly still. * Templates are very basic, the ones there are simple but already can follow the object buttons mockup quite closely. * It's based on a three level system: panels, templates and items. To get an idea of what that means in practice, see: http://wiki.blender.org/index.php/BlenderDev/Blender2.5/UI_LayoutEngine#Panels.2C_Templates_and_Items
Diffstat (limited to 'source/blender/editors/interface/interface_utils.c')
-rw-r--r--source/blender/editors/interface/interface_utils.c57
1 files changed, 34 insertions, 23 deletions
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 58563166847..456eae1463d 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -217,7 +217,7 @@ int UI_GetIconRNA(PointerRNA *ptr)
return ICON_DOT;
}
-uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, char *name, int x1, int y1, int x2, int y2)
+uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, char *name, int icon, int x1, int y1, int x2, int y2)
{
uiBut *but=NULL;
const char *propname= RNA_property_identifier(ptr, prop);
@@ -237,10 +237,12 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
else
value= RNA_property_boolean_get(ptr, prop);
- if(name && strcmp(name, "") == 0)
- name= (value)? "Enabled": "Disabled";
-
- but= uiDefButR(block, TOG, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
+ if(icon && name && strcmp(name, "") == 0)
+ but= uiDefIconButR(block, ICONTOG, 0, icon, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
+ else if(icon)
+ but= uiDefIconTextButR(block, ICONTOG, 0, icon, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
+ else
+ but= uiDefButR(block, TOG, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
break;
}
case PROP_INT:
@@ -267,24 +269,29 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
int icon;
pptr= RNA_property_pointer_get(ptr, prop);
+ descr= (char*)RNA_property_ui_description(ptr, prop);
- if(!pptr.data)
- return NULL;
+ if(!pptr.type)
+ pptr.type= RNA_property_pointer_type(ptr, prop);
icon= UI_GetIconRNA(&pptr);
- nameprop= RNA_struct_name_property(&pptr);
-
- if(nameprop) {
- text= RNA_property_string_get_alloc(&pptr, nameprop, textbuf, sizeof(textbuf));
- 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);
- if(text != textbuf)
- MEM_freeN(text);
+
+ if(pptr.data == NULL) {
+ but= uiDefIconTextBut(block, LABEL, 0, icon, "", x1, y1, x2, y2, NULL, 0, 0, 0, 0, "");
}
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);
+ 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);
+ but= uiDefIconTextBut(block, LABEL, 0, icon, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, descr);
+ }
}
break;
}
@@ -338,8 +345,10 @@ int uiDefAutoButsRNA(uiBlock *block, PointerRNA *ptr)
subtype= RNA_property_subtype(ptr, prop);
- name= (char*)RNA_property_ui_name(ptr, prop);
- uiDefBut(block, LABEL, 0, name, x, y, DEF_BUT_WIDTH, DEF_BUT_HEIGHT-1, NULL, 0, 0, 0, 0, "");
+ if(RNA_property_type(ptr, prop) != PROP_BOOLEAN) {
+ name= (char*)RNA_property_ui_name(ptr, prop);
+ uiDefBut(block, LABEL, 0, name, x, y, DEF_BUT_WIDTH, DEF_BUT_HEIGHT-1, NULL, 0, 0, 0, 0, "");
+ }
uiBlockBeginAlign(block);
@@ -355,7 +364,7 @@ int uiDefAutoButsRNA(uiBlock *block, PointerRNA *ptr)
col= a%size;
row= a/size;
- uiDefAutoButR(block, ptr, prop, a, "", x+butwidth*col, y-row*DEF_BUT_HEIGHT, butwidth, DEF_BUT_HEIGHT-1);
+ uiDefAutoButR(block, ptr, prop, a, "", 0, x+butwidth*col, y-row*DEF_BUT_HEIGHT, butwidth, DEF_BUT_HEIGHT-1);
}
y -= DEF_BUT_HEIGHT*(length/size);
@@ -377,7 +386,7 @@ int uiDefAutoButsRNA(uiBlock *block, PointerRNA *ptr)
else
name= coloritem[a];
- uiDefAutoButR(block, ptr, prop, a, name, x+butwidth*a, y, butwidth, DEF_BUT_HEIGHT-1);
+ uiDefAutoButR(block, ptr, prop, a, name, 0, x+butwidth*a, y, butwidth, DEF_BUT_HEIGHT-1);
}
y -= DEF_BUT_HEIGHT;
}
@@ -386,10 +395,12 @@ int uiDefAutoButsRNA(uiBlock *block, PointerRNA *ptr)
sprintf(namebuf, "%d:", a+1);
name= namebuf;
}
+ else if(RNA_property_type(ptr, prop) == PROP_BOOLEAN)
+ name= (char*)RNA_property_ui_name(ptr, prop);
else
name= "";
- uiDefAutoButR(block, ptr, prop, 0, name, x+DEF_BUT_WIDTH, y, DEF_BUT_WIDTH, DEF_BUT_HEIGHT-1);
+ uiDefAutoButR(block, ptr, prop, 0, name, 0, x+DEF_BUT_WIDTH, y, DEF_BUT_WIDTH, DEF_BUT_HEIGHT-1);
y -= DEF_BUT_HEIGHT;
}