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.
This commit is contained in:
@@ -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);
|
||||
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);
|
||||
}
|
||||
else {
|
||||
col= NULL;
|
||||
}
|
||||
|
||||
name= ""; /* name is shown above, empty name for button below */
|
||||
}
|
||||
else if(columns == 2) {
|
||||
split = uiLayoutSplit(layout, 0.5f, 0);
|
||||
|
||||
uiItemL(uiLayoutColumn(split, 0), name, 0);
|
||||
col= uiLayoutColumn(split, 0);
|
||||
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 *******************************/
|
||||
|
||||
Reference in New Issue
Block a user