diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-12-15 08:42:23 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-12-15 08:42:23 +0300 |
commit | eb8458b064c5a7553a3bd51c214c9669aaf550f9 (patch) | |
tree | 85063dfae53b799f6bceca854ecb4f338458d833 /source/blender/editors/interface/interface_utils.c | |
parent | acd7b81c2d3fa7828d28c1562fad10663d911783 (diff) |
Centralized operator UI drawing into a new function uiLayoutOperatorButs(),
Operator drawing calls were duplicated in file selector panel, redo panels, redo & dialog popups.
note, uiDefAutoButsRNA's column's argument was misleading, renamed to label_align.
Diffstat (limited to 'source/blender/editors/interface/interface_utils.c')
-rw-r--r-- | source/blender/editors/interface/interface_utils.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 7d3f186d490..b6afe6f63d4 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -26,6 +26,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <assert.h> #include "DNA_object_types.h" @@ -131,35 +132,50 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind return but; } -void uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, int columns) +int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, int (*check_prop)(PropertyRNA *), const char label_align) { uiLayout *split, *col; int flag; - char *name; + const char *name; + int tot= 0; + + assert(ELEM3(label_align, '\0', 'H', 'V')); RNA_STRUCT_BEGIN(ptr, prop) { flag= RNA_property_flag(prop); - if(flag & PROP_HIDDEN) + if(flag & PROP_HIDDEN || (check_prop && check_prop(prop)==FALSE)) continue; - name= (char*)RNA_property_ui_name(prop); + if(label_align != '\0') { + name= RNA_property_ui_name(prop); - if(columns == 1) { - col= uiLayoutColumn(layout, 1); - uiItemL(col, name, 0); - } - else if(columns == 2) { - split = uiLayoutSplit(layout, 0.5f, 0); + if(label_align=='V') { + col= uiLayoutColumn(layout, 1); + uiItemL(col, name, 0); + } + else if(label_align=='H') { + split = uiLayoutSplit(layout, 0.5f, 0); - uiItemL(uiLayoutColumn(split, 0), name, 0); - col= uiLayoutColumn(split, 0); + uiItemL(uiLayoutColumn(split, 0), name, 0); + col= uiLayoutColumn(split, 0); + } + else { + col= NULL; + } + + name= ""; /* name is shown above, empty name for button below */ + } + else { + col= layout; + name= NULL; /* no smart label alignment, show default name with button */ } - else - col= NULL; - uiItemFullR(col, ptr, prop, -1, 0, 0, "", 0); + uiItemFullR(col, ptr, prop, -1, 0, 0, name, 0); + tot++; } RNA_STRUCT_END; + + return tot; } /***************************** ID Utilities *******************************/ |