diff options
author | Julian Eisel <julian@blender.org> | 2020-09-18 21:10:40 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-09-18 21:38:45 +0300 |
commit | aacf8d75f5cbf8db5ac6feec7e49eac7c296ad96 (patch) | |
tree | 1df7b52bd70ce8350f6bfd2eb6b5f5f289c4a189 /source/blender/editors/interface/interface_handlers.c | |
parent | a6a0cbcd7492bd8087b6df659c365482614b13e2 (diff) |
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.
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index eb0d18956d9..a5e275c27b5 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -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: { |