Page MenuHome

UI: Blender 101: Mouse Hover Highlight
Needs ReviewPublic

Authored by Harley Acheson (harley) on Sep 17 2021, 10:42 PM.

Details

Summary

As requested in T90025, this adds a subtle mouse hover highlight when
selecting items in the Monkey 101 Template.


This patch adds a subtle mouse hover highlight for UIList items and preview tile elements.

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Sep 17 2021, 10:42 PM
Harley Acheson (harley) created this revision.

Code wise looks ok. Will let @Dalai Felinto (dfelinto) do the review on functionality.

Working as expected. I wonder if Julian has anything to add. I know he had some thoughts on how to do that.
Also isn't there any existing theme color/setting to use instead of the hardcoded 0.1f?

Working as expected. I wonder if Julian has anything to add. I know he had some thoughts on how to do that.
Also isn't there any existing theme color/setting to use instead of the hardcoded 0.1f?

No, all the theme colors are all really strong and we don’t have a separate setting for the strength of the hover highlight. This dumb, hard-coded 0.1 is pretty equivalent to the other dumb, hard-coded calculations elsewhere for that.

Julian Eisel (Severin) requested changes to this revision.Sep 20 2021, 3:39 PM

The highlight is super strong for me.

Is that intentional? We should generally keep mouse-hover feedback subtle.

This revision now requires changes to proceed.Sep 20 2021, 3:39 PM

@Julian Eisel (Severin) - The highlight is super strong for me… Is that intentional?

No, I could find not other places to test this besides inside that 101 template. Your example should help. Thanks!

@Julian Eisel (Severin) - The highlight is super strong for me.

It made sense. That widget does not draw a background under normal circumstances so we can't really mix with any of its theme colors. Instead now just using a low-opacity version of the text color - works in your example and in 101.

Hi @Harley Acheson (harley), by the way the widget preview tile should use the UI List colors, not the regular colors. It is not something caused by this patch, but it is related (it can be addressed indepedently).

As for this patch, it would be nice to also tackle the regular UI List items like UV, ShapeKeys, ... not only the tiles.

Julian Eisel (Severin) accepted this revision.EditedSep 21 2021, 12:30 PM

To use the UI list theme colors, the UI_BLOCK_LIST_ITEM flag needs to be set for the UI_BTYPE_PREVIEW_TILE. I experimented with that yesterday, because then we could let the normal widget_state() handle the state related theme colors. This would also enable mouse-hover highlighting for regular UI lists. But there were some issues that I don't have the time to debug (and we'd also have to version patch theme colors).
I'm fine with this simple solution.

This revision is now accepted and ready to land.Sep 21 2021, 12:30 PM

@Dalai Felinto (dfelinto) - the widget preview tile should use the UI List colors, not the regular colors

This version now uses List Item coloring for preview tiles.

it would be nice to also tackle the regular UI List items like UV, ShapeKeys, ... not only the tiles.

This version shows hover highlight for regular list items too:

Better treatment of UIList items that are already selected.

This seems to work fine on dark themes & light themes and inside the Monkey app.

Harley Acheson (harley) edited the summary of this revision. (Show Details)

Updated to current state of master.

Just tested it and it works great! Can we get it in?

Just tested it and it works great! Can we get it in?

Yes, but this (unfortunately) needs a second LGTM from @Julian Eisel (Severin) since changes were made after he approved it.

The only thing missing about this patch (UI-wise), is that when hovering widgets inside the row, the row should stay highlighted.

Currently, the list item loses the hover effect when hovering over widgets inside the row like sliders or properties/operators.

This revision now requires review to proceed.Jan 4 2022, 8:29 AM
Julian Eisel (Severin) requested changes to this revision.Jan 4 2022, 3:34 PM

The only thing missing about this patch (UI-wise), is that when hovering widgets inside the row, the row should stay highlighted.

Currently, the list item loses the hover effect when hovering over widgets inside the row like sliders or properties/operators.

This is a problem that should be addressed. I've done so already for the new tree-views, see ui_handle_tree_hover(). Not really nice but our UI code doesn't support this better. Not worth the extra hassles.

This revision now requires changes to proceed.Jan 4 2022, 3:34 PM

@Julian Eisel (Severin) - I've done so already for the new tree-views, see ui_handle_tree_hover()

I've tried that, without success.

Following your pattern should be even easier since ui_region_handler already correctly identifies hovered lists. So it is just a matter of adding UI_ACTIVE to the hovered row. This revision does so but you see it doesn't give the desired result. I can see that row getting the flag but it doesn't display as such.

Checking this together with D13858: UI: Unify drawing style of UILists and Tree row buttons., which adds highlights to list rows. I think that patch is the better solution, since it actually lets the list-row highlight, whereas this patch only adds a highlight to UI_WTYPE_PREVIEW_TILE which just is what we happen to draw on top of the list-row in this case.
It has the same issue with hovering nested buttons, so that's something to investigate still.

@Julian Eisel (Severin) - whereas this patch only adds a highlight to UI_WTYPE_PREVIEW_TILE...

No, this patch also highlights regular list-rows, now including hovering over nested buttons.

Updated to the current state of master.

Updated to the current state of master.

Updated to the current state of master.