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>2008-12-16 10:55:43 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-12-16 10:55:43 +0300
commit998e682fc310aa325e54dfcd7c0a9708803ee790 (patch)
tree23b8bc0f9c71b21333356bcc6525de886e0e2d91 /source/blender/editors/space_outliner
parent99575d31ff65500b67d05361aef79cf1f8c333f7 (diff)
UI: added the following functions to create buttons for RNA properties and for
operators. RNA property buttons will automatically fill in the label, min/max, etc if they are not specified. Operator menu buttons will look up the key combination in the handlers and add it automatically. uiDefButR, uiDefIconButR, uiDefIconTextButR uiDefButO, uiDefIconButO, uiDefIconTextButO uiDefButO takes a context pointer to do the key lookup, don't really like this..
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index c98ec6de4e7..cb0b29089b7 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -244,6 +244,66 @@ static void rna_collection_but(CellRNA *cell, rcti *rct, uiBlock *block)
uiButSetFunc(but, rna_pointer_cb, cell->prop, SET_INT_IN_POINTER(cell->index));
}
+static uiBut *rna_auto_but(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, int x1, int y1, int x2, int y2)
+{
+ uiBut *but;
+ const char *propname= RNA_property_identifier(ptr, prop);
+
+ switch(RNA_property_type(ptr, prop)) {
+ case PROP_BOOLEAN: {
+ int value, length;
+
+ length= RNA_property_array_length(ptr, prop);
+
+ if(length)
+ value= RNA_property_boolean_get_array(ptr, prop, index);
+ else
+ value= RNA_property_boolean_get(ptr, prop);
+
+ but= uiDefButR(block, TOG, 0, (value)? "True": "False", x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
+ break;
+ }
+ case PROP_INT:
+ case PROP_FLOAT:
+ but= uiDefButR(block, NUM, 0, "", x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
+ break;
+ case PROP_ENUM:
+ but= uiDefButR(block, MENU, 0, NULL, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
+ break;
+ 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 name[256]= "", *nameptr= name;
+
+ RNA_property_pointer_get(ptr, prop, &pptr);
+
+ if(pptr.data) {
+ nameprop= RNA_struct_name_property(&pptr);
+ if(pptr.type && nameprop)
+ nameptr= RNA_property_string_get_alloc(&pptr, nameprop, name, sizeof(name));
+ else
+ strcpy(nameptr, "->");
+ }
+
+ but= uiDefButR(block, BUT, 0, nameptr, x1, y1, x2, y2, ptr, propname, index, 0, 0, 0, 0, NULL);
+ uiButSetFlag(but, UI_TEXT_LEFT);
+
+ if(nameptr != name)
+ MEM_freeN(nameptr);
+
+ break;
+ }
+ default:
+ but= NULL;
+ break;
+ }
+
+ return but;
+}
+
static void rna_but(CellRNA *cell, rcti *rct, uiBlock *block)
{
uiBut *but;
@@ -265,7 +325,7 @@ static void rna_but(CellRNA *cell, rcti *rct, uiBlock *block)
index= (arraylength)? cell->index: 0;
if(index >= 0) {
- but= uiDefRNABut(block, 0, &cell->ptr, prop, index, rct->xmin, rct->ymin, rct->xmax-rct->xmin, rct->ymax-rct->ymin);
+ but= rna_auto_but(block, &cell->ptr, prop, index, rct->xmin, rct->ymin, rct->xmax-rct->xmin, rct->ymax-rct->ymin);
if(type == PROP_POINTER)
uiButSetFunc(but, rna_pointer_cb, prop, SET_INT_IN_POINTER(0));