slint
slint copied to clipboard
Add an in-out boolean dark-color-scheme property to Palette
This allows applications to force dark/light mode, as well as determine which mode is active.
Another option would be to have an enum instead of a boolean, like enum ColorScheme { Dark, Light, Unknown }, but that's a little weird for the setter.
Can we have a switch in the gallery?
Good idea - done :)
Another option would be to have an enum instead of a boolean, like
enum ColorScheme { Dark, Light, Unknown }, but that's a little weird for the setter.
That was already my suggestion. I think this makes it much more flexible and easier to extend it in the future. There are often now different color schemes e.g. for better accessibility e.g. HighContrast or a scheme for people with green-blue deficiency.
Can we have a switch in the gallery?
Good idea - done :)
Yeah it's a good idea. It enhances the interactivity of the gallery. I had done the same on my initial PR https://github.com/slint-ui/slint/blob/357eb48cbd2eaa198aaa48398fd1b7fb5841fa12/examples/gallery/ui/pages/page.slint#L31
Another option would be to have an enum instead of a boolean, like
enum ColorScheme { Dark, Light, Unknown }, but that's a little weird for the setter.That was already my suggestion. I think this makes it much more flexible and easier to extend it in the future. There are often now different color schemes e.g. for better accessibility e.g. HighContrast or a scheme for people with green-blue deficiency.
Right, I've noticed the same. The main issue I have with Unknown is ... what should happen when it is set? :)
Another option would be to have an enum instead of a boolean, like
enum ColorScheme { Dark, Light, Unknown }, but that's a little weird for the setter.That was already my suggestion. I think this makes it much more flexible and easier to extend it in the future. There are often now different color schemes e.g. for better accessibility e.g. HighContrast or a scheme for people with green-blue deficiency.
Right, I've noticed the same. The main issue I have with
Unknownis ... what should happen when it is set? :)
Do we need Unknown I think if the system does not define a scheme a default fallback should be used e.g. Light.
Fair point :-)
The main issue I have with Unknown is ... what should happen when it is set? :)
I'd say it should then be back to the global desktop or browser setting.
Alright, so there's an enum now. Initially Palette.color-scheme is bound to SlintInternal.color-scheme, so it'll return whatever we detect in the system. Setting Palette.color-scheme to ColorScheme.unknown now makes the styles fall back to SlintInternal.color-scheme, i.e. the system default, but when reading the property it'll return "unknown".