diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 9f8a04fa90b..4f9393fb862 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -811,7 +811,13 @@ static void ui_is_but_sel(uiBut *but) break; case ROW: case LISTROW: - if(value == but->hardmax) push= 1; + /* support for rna enum buts */ + if(but->rnaprop && (RNA_property_flag(but->rnaprop) & PROP_ENUM_FLAG)) { + if((int)value & (int)but->hardmax) push= 1; + } + else { + if(value == but->hardmax) push= 1; + } break; case COL: push= 2; @@ -1355,7 +1361,14 @@ void ui_set_but_val(uiBut *but, double value) RNA_property_float_set(&but->rnapoin, prop, value); break; case PROP_ENUM: - RNA_property_enum_set(&but->rnapoin, prop, value); + if(RNA_property_flag(prop) & PROP_ENUM_FLAG) { + int ivalue= (int)value; + ivalue ^= RNA_property_enum_get(&but->rnapoin, prop); /* toggle for enum/flag buttons */ + RNA_property_enum_set(&but->rnapoin, prop, ivalue); + } + else { + RNA_property_enum_set(&but->rnapoin, prop, value); + } break; default: break; diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index d5f6b089544..3873c5c9092 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -103,7 +103,7 @@ typedef enum { #define UI_PANEL_MINY 70 /* uiBut->flag */ -#define UI_SELECT 1 +#define UI_SELECT 1 /* use when the button is pressed */ #define UI_MOUSE_OVER 2 #define UI_ACTIVE 4 #define UI_HAS_ICON 8 diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 1d98b1f22c1..e268120fa07 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -917,8 +917,15 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index if(layout->root->type == UI_LAYOUT_MENU) { if(type == PROP_BOOLEAN) icon= (RNA_property_boolean_get(ptr, prop))? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; - else if(type == PROP_ENUM && index == RNA_ENUM_VALUE) - icon= (RNA_property_enum_get(ptr, prop) == value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; + else if(type == PROP_ENUM && index == RNA_ENUM_VALUE) { + int enum_value= RNA_property_enum_get(ptr, prop); + if(RNA_property_flag(prop) & PROP_ENUM_FLAG) { + icon= (enum_value & value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; + } + else { + icon= (enum_value == value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; + } + } } slider= (flag & UI_ITEM_R_SLIDER); @@ -948,7 +955,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index uiDefButR(block, ROW, 0, name, 0, 0, w, h, ptr, identifier, -1, 0, value, -1, -1, NULL); } /* expanded enum */ - else if(type == PROP_ENUM && expand) + else if(type == PROP_ENUM && (expand || RNA_property_flag(prop) & PROP_ENUM_FLAG)) ui_item_enum_expand(layout, block, ptr, prop, name, 0, 0, w, h, icon_only); /* property with separate label */ else if(type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) {