Platform preferences API
Michael Strauß
michaelstrau2 at gmail.com
Sun Jul 23 23:46:39 UTC 2023
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