UI: Support mouse over highlighting for superimposed icons

E.g. the 'x' icons or eyedropper icons in text buttons. They didn't use
to have any mouse over feedback, now we dim the icon until hovered.
This kind of feedback helps users see that the icons are interactive,
and if they are within their interaction hotspot.
This commit is contained in:
2020-09-18 20:10:40 +02:00
parent a6a0cbcd74
commit aacf8d75f5
4 changed files with 75 additions and 2 deletions

View File

@@ -4194,6 +4194,31 @@ static bool ui_do_but_extra_operator_icon(bContext *C,
return false;
}
static void ui_do_but_extra_operator_icons_mousemove(uiBut *but,
uiHandleButtonData *data,
const wmEvent *event)
{
uiButExtraOpIcon *old_highlighted = NULL;
/* Unset highlighting of all first. */
LISTBASE_FOREACH (uiButExtraOpIcon *, op_icon, &but->extra_op_icons) {
if (op_icon->highlighted) {
old_highlighted = op_icon;
}
op_icon->highlighted = false;
}
uiButExtraOpIcon *hovered = ui_but_extra_operator_icon_mouse_over_get(but, data, event);
if (hovered) {
hovered->highlighted = true;
}
if (old_highlighted != hovered) {
ED_region_tag_redraw_no_rebuild(data->region);
}
}
#ifdef USE_DRAG_TOGGLE
/* Shared by any button that supports drag-toggle. */
static bool ui_do_but_ANY_drag_toggle(
@@ -8709,6 +8734,9 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
button_tooltip_timer_reset(C, but);
}
/* Update extra icons states. */
ui_do_but_extra_operator_icons_mousemove(but, data, event);
break;
}
case TIMER: {