Given the goal of this function, I'm not sure it can get more optimal
than this even with specialized data structures like KD-trees. The
problem is that we want all widgets that are hovered, not just some, and
that makes nearest neighbor useless.
The main optimizations here are simple:
- Group up all the render data we need in a single vec to help cache.
- Precompute the rect's extents to make the contains check at most 4
comparisons.
This had a noticable effect on the "wiggle the mouse frantically"
performance, where Gooey isn't actually repainting but is routing mouse
events.
Asserting condition on PercentBetween, Color lerping now works
correctly according to testing with gray shades, but due to rounding
errors, no unit test is being checked in at the moment.
I noticed that the new default theme settings were causing the "wrong"
text color to be picked. After reviewing why the contrast values were
the way they were, I reasoned that the less lightness, the less the
ColorSource contrast matters. So I've applied a multiplication of the
average ligntess between the two colors being compared.
Introducing two new colors:
- ColorTheme::color_dim, for dimmed/disabled primary colors
- SurfaceTheme::opaque_widget, for buttons.
In material design, a button's background color uses the Highest
Container role, which seems incorrect because then buttons wouldn't have
a different color when placed inside of the highest level container.
Rather than remove a container level, I added one more tone using the
neutral variant.
Other changes are just gut feelings to have a slightly richer dark
theme. I feel like material is a little muddy in dark mode.
I started making more changes, and I lost track of what was merge
related and what wasn't, so I committed the merge with what was staged,
but it probably didn't compile.
This is the remaining changes to get things back to a state I'm happy
with, mostly tweaking the constrast behavior.