UI: Highlight Selected Enum #111074
|
@ -4286,6 +4286,7 @@ static void ui_def_but_rna__menu(bContext * /*C*/, uiLayout *layout, void *but_p
|
|||
uiBlock *block = uiLayoutGetBlock(layout);
|
||||
uiPopupBlockHandle *handle = block->handle;
|
||||
uiBut *but = (uiBut *)but_p;
|
||||
const int current_value = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
|
||||
|
||||
/* see comment in ui_item_enum_expand, re: `uiname`. */
|
||||
const EnumPropertyItem *item_array;
|
||||
|
@ -4431,38 +4432,43 @@ static void ui_def_but_rna__menu(bContext * /*C*/, uiLayout *layout, void *but_p
|
|||
icon = ICON_BLANK1;
|
||||
}
|
||||
|
||||
uiBut *item_but;
|
||||
if (icon) {
|
||||
uiDefIconTextButI(block,
|
||||
UI_BTYPE_BUT_MENU,
|
||||
B_NOP,
|
||||
icon,
|
||||
item->name,
|
||||
0,
|
||||
0,
|
||||
UI_UNIT_X * 5,
|
||||
UI_UNIT_Y,
|
||||
&handle->retvalue,
|
||||
item->value,
|
||||
0.0,
|
||||
0,
|
||||
-1,
|
||||
item->description);
|
||||
item_but = uiDefIconTextButI(block,
|
||||
UI_BTYPE_BUT_MENU,
|
||||
B_NOP,
|
||||
icon,
|
||||
item->name,
|
||||
0,
|
||||
0,
|
||||
UI_UNIT_X * 5,
|
||||
UI_UNIT_Y,
|
||||
&handle->retvalue,
|
||||
item->value,
|
||||
0.0,
|
||||
0,
|
||||
-1,
|
||||
item->description);
|
||||
}
|
||||
else {
|
||||
uiDefButI(block,
|
||||
UI_BTYPE_BUT_MENU,
|
||||
B_NOP,
|
||||
item->name,
|
||||
0,
|
||||
0,
|
||||
UI_UNIT_X * 5,
|
||||
UI_UNIT_X,
|
||||
&handle->retvalue,
|
||||
item->value,
|
||||
0.0,
|
||||
0,
|
||||
-1,
|
||||
item->description);
|
||||
item_but = uiDefButI(block,
|
||||
UI_BTYPE_BUT_MENU,
|
||||
B_NOP,
|
||||
item->name,
|
||||
0,
|
||||
0,
|
||||
UI_UNIT_X * 5,
|
||||
UI_UNIT_X,
|
||||
&handle->retvalue,
|
||||
item->value,
|
||||
0.0,
|
||||
0,
|
||||
-1,
|
||||
item->description);
|
||||
}
|
||||
item_but->flag |= UI_BUT_LIST_ITEM;
|
||||
if (item->value == current_value) {
|
||||
item_but->flag |= UI_BUT_ACTIVE_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2727,27 +2727,36 @@ static void widget_state_menu_item(uiWidgetType *wt,
|
|||
{
|
||||
wt->wcol = *(wt->wcol_theme);
|
||||
|
||||
/* active and disabled (not so common) */
|
||||
if ((state->but_flag & UI_BUT_DISABLED) && (state->but_flag & UI_ACTIVE)) {
|
||||
/* draw the backdrop at low alpha, helps navigating with keys
|
||||
* when disabled items are active */
|
||||
/* Hovering over disabled item. */
|
||||
wt->wcol.text[3] = 128;
|
||||
color_blend_v3_v3(wt->wcol.inner, wt->wcol.text, 0.5f);
|
||||
wt->wcol.inner[3] = 64;
|
||||
}
|
||||
else {
|
||||
/* regular active */
|
||||
if (state->but_flag & UI_ACTIVE) {
|
||||
copy_v3_v3_uchar(wt->wcol.text, wt->wcol.text_sel);
|
||||
}
|
||||
else if (state->but_flag & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
|
||||
/* regular disabled */
|
||||
color_blend_v3_v3(wt->wcol.text, wt->wcol.inner, 0.5f);
|
||||
}
|
||||
|
||||
if (state->but_flag & UI_ACTIVE) {
|
||||
copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel);
|
||||
}
|
||||
else if (state->but_flag & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
|
||||
/* Regular disabled. */
|
||||
color_blend_v3_v3(wt->wcol.text, wt->wcol.inner, 0.5f);
|
||||
}
|
||||
else if ((state->but_flag & UI_BUT_LIST_ITEM) &&
|
||||
state->but_flag & (UI_BUT_ACTIVE_DEFAULT | UI_SELECT))
|
||||
{
|
||||
/* Currently-selected list item. */
|
||||
copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel);
|
||||
copy_v4_v4_uchar(wt->wcol.text, wt->wcol.text_sel);
|
||||
}
|
||||
else if ((state->but_flag & (UI_SELECT | UI_BUT_ICON_PREVIEW)) ==
|
||||
(UI_SELECT | UI_BUT_ICON_PREVIEW))
|
||||
{
|
||||
/* Currently-selected list or menu item that is large icon preview. */
|
||||
copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel);
|
||||
copy_v4_v4_uchar(wt->wcol.text, wt->wcol.text_sel);
|
||||
}
|
||||
else if (state->but_flag & UI_ACTIVE) {
|
||||
/* Regular hover. */
|
||||
color_blend_v3_v3(wt->wcol.inner, wt->wcol.text, 0.2f);
|
||||
copy_v3_v3_uchar(wt->wcol.text, wt->wcol.text_sel);
|
||||
wt->wcol.inner[3] = 255;
|
||||
wt->wcol.text[3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue