slint icon indicating copy to clipboard operation
slint copied to clipboard

Add an in-out boolean dark-color-scheme property to Palette

Open tronical opened this issue 1 year ago • 8 comments

This allows applications to force dark/light mode, as well as determine which mode is active.

tronical avatar Feb 27 '24 13:02 tronical

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.

tronical avatar Feb 27 '24 13:02 tronical

Can we have a switch in the gallery?

Good idea - done :)

tronical avatar Feb 27 '24 14:02 tronical

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.

FloVanGH avatar Mar 04 '24 06:03 FloVanGH

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

FloVanGH avatar Mar 04 '24 06:03 FloVanGH

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? :)

tronical avatar Mar 04 '24 07:03 tronical

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? :)

Do we need Unknown I think if the system does not define a scheme a default fallback should be used e.g. Light.

FloVanGH avatar Mar 04 '24 10:03 FloVanGH

Fair point :-)

tronical avatar Mar 04 '24 10:03 tronical

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.

ogoffart avatar Mar 05 '24 08:03 ogoffart

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".

tronical avatar Mar 25 '24 20:03 tronical