Platform preferences API
John Hendrikx
john.hendrikx at gmail.com
Mon Jul 24 07:43:31 UTC 2023
I think Appearance is exactly correct as it is. It encodes a
fundamental binary aspect of visual presentations that all themes,
styles, displays, posters, prints, etc. must choose between: do I
present text on a light background (and so the text is dark), or do I
present text on a dark background (and so text is light)? There are no
other choices without text becoming unreadable, and there never will be.
So IMHO, the enum is correct, and will never need to extended. Encoding
more than one dimension into an enum should be avoided in favor of
another enum at all times, so encoding something like contrast into it
would not be a sensible move.
--John
On 24/07/2023 01:46, Michael Strauß wrote:
> I'd like to wrap up the discussion around the new `Appearance`
> enumeration proposed for the Platform Preferences API:
>
> public enum javafx.application.Appearance {
> LIGHT, DARK
> }
>
> When viewed with the goal of eventually supporting style themes, this
> might seem a bit limiting at first. Obvious questions are:
> 1. Can you have more modes than light or dark? What about blue or purple mode?
> 2. Can you have variations of these modes? For example: high-contrast
> light and high-contrast dark.
> 3. Should "appearance" include other aspects, for example rounded vs.
> non-rounded window corners, or title bar tint.
>
> I think the answer to all of these questions is: no. `Appearance`
> represents the binary light/dark mode distinction that most operating
> systems have settled on. If, at some point in the future, operating
> systems support additional modes, we can always consider adding more
> enumeration constants.
>
> This doesn't mean that JavaFX applications and style themes are
> limited to only supporting one light and one dark theme. A theme might
> have different variations for each appearance, or it might not use the
> platform's appearance information at all and use other sources of
> information. The question we need to solve is whether we should
> anticipate all of these future requirements and bake them into the
> Platform Preferences API (answer: no).
>
> As proposed, the `Appearance` information provided by the Platform
> Preferences API fits nicely with the upcoming Stage Appearance
> feature. This allows users to simply bind the two properties to sync
> up stage appearance with platform appearance:
>
> stage.appearanceProperty().bind(
> Application.getPreferences().appearanceProperty());
>
> Basically, we're taking the light/dark information that we've received
> from the OS and forwarding this information to the windowing system to
> indicate whether we'd like to have light or dark window decorations
> (which are the only two options to choose from).
>
> I think this information is useful for JavaFX applications on its own,
> and doesn't need to wait for the Stage Appearance feature.
More information about the openjfx-dev
mailing list