From cad6ed9bc600e9162cdad2410e405fc7ad716e2e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 14 Aug 2011 11:38:17 +0000 Subject: [PATCH] fix for fix r39388, this added checkboxes to buttons which are not supposed to have them. now only add checkboxes when the background is not emboss - which works for menus but will work in more general cases too. --- .../editors/interface/interface_intern.h | 5 +- .../editors/interface/interface_layout.c | 128 ++++++++---------- 2 files changed, 63 insertions(+), 70 deletions(-) diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 8475090b468..242210e01bb 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -213,7 +213,7 @@ struct uiBut { BIFIconID icon; char lock; - char dt; + char dt; /* drawtype: UI_EMBOSS, UI_EMBOSSN ... etc, copied from the block */ char changed; /* could be made into a single flag */ unsigned char unit_type; /* so buttons can support unit systems which are not RNA */ short modifier_key; @@ -306,7 +306,8 @@ struct uiBlock { void *drawextra_arg2; int flag; - char direction, dt; + char direction; + char dt; /* drawtype: UI_EMBOSS, UI_EMBOSSN ... etc, copied to buttons */ short auto_open; double auto_open_last; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index e6df6a07d52..4810b3fdf54 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -355,65 +355,46 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); /* create buttons */ - if(type == PROP_BOOLEAN) { - if(ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) { - /* special check for layer layout */ - int butw, buth, unit; - int cols= (len >= 20)? 2: 1; - int colbuts= len/(2*cols); - int layer_used= 0; + if(type == PROP_BOOLEAN && ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) { + /* special check for layer layout */ + int butw, buth, unit; + int cols= (len >= 20)? 2: 1; + int colbuts= len/(2*cols); + int layer_used= 0; - uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, 0)); + uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, 0)); - unit= UI_UNIT_X*0.75; - butw= unit; - buth= unit; + unit= UI_UNIT_X*0.75; + butw= unit; + buth= unit; - if(ptr->type == &RNA_Armature) { - bArmature *arm= (bArmature *)ptr->data; - layer_used= arm->layer_used; - } - - for(b=0; bbuttonspacex; - } + if(ptr->type == &RNA_Armature) { + bArmature *arm= (bArmature *)ptr->data; + layer_used= arm->layer_used; } - else { - /* not common, but good to support non layer boolean arrays */ - int *tmparray= MEM_callocN(sizeof(int)*len, "ui_item_array"); - RNA_property_boolean_get_array(ptr, prop, tmparray); + for(b=0; bbuttonspacex; } } else if(subtype == PROP_MATRIX) { @@ -441,35 +422,46 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in uiDefButR_prop(block, BUT_NORMAL, 0, name, x, y, UI_UNIT_X*3, UI_UNIT_Y*3, ptr, prop, 0, 0, 0, -1, -1, NULL); } else { - if(ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA) && !expand) - uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, 0, 0, w, UI_UNIT_Y); + /* note, this block of code is a bit arbitrary and has just been made + * to work with common cases, but may need to be re-worked */ + + /* special case, boolean array in a menu, this could be used in a more generic way too */ + if(ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA) && !expand) { + uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, 0, 0, w, UI_UNIT_Y); + } + else { + int *boolarr= NULL; + + /* even if 'expand' is fale, expanding anyway */ - if(!ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA) || expand) { /* layout for known array subtypes */ - char str[3]; + char str[3]= {'\0'}; + + if(!icon_only) { + if(type != PROP_BOOLEAN) { + str[1]= ':'; + } + } + + /* show checkboxes for rna on a non-emboss block (menu for eg) */ + if(type == PROP_BOOLEAN && ELEM(layout->root->block->dt, UI_EMBOSSN, UI_EMBOSSP)) { + boolarr= MEM_callocN(sizeof(int)*len, "ui_item_array"); + RNA_property_boolean_get_array(ptr, prop, boolarr); + } for(a=0; atype==NUM) but->type= NUMSLI; if(toggle && but->type==OPTION) but->type= TOG; } + + if(boolarr) { + MEM_freeN(boolarr); + } } }