Closed sevoku closed 4 years ago
I'd like to suggest a slightly different approach to avoid the event subscription. Have a global counter that is increased when there is a change in the global styles. Store a copy of the current value of the counter in the themed image when it is created. Before rendering an image, check if the counter changed since last draw, and in that case resort the images before rendering.
GetImage is optimized for performace and therefore just loops over the images and selects the first best matching one based on given styles. The result is not predictable if the image list is not sorted and several alternatives match different global and explicit styles. Since we want to prioritize explicit styles first, we need to make sure that we don't select an image with a given global style but without an explicit match first. The simplest approach without slowing down rendering by a sophisticated lookup is to sort images matching global styles last, so that GetImage would always select an alternative with an explicit rather than a global style.
High contrast Mode Example from MonoDevelop
We use two problematic/conflicting styles:
sel
for icons rendered if a control is in selected statecontrast
icon alternatives used when a high contrast shell theme is activeThe
sel
mode is always explicitely requested if the control state changes, while thecontrast
style is global.Given we have these two icons for the different modes:
icon~sel.png
icon~contrast.png
It is not well defined which one would be rendered, if both styles are set. Currently this depends only on the order in which the icon alternatives have been loaded from disk. With this change we'll always select the explicit and not the global style, which is
sel
in this case.without the fix:
with the fix: