RFR: 8301302: Platform preferences API [v3]
Michael Strauß
mstrauss at openjdk.org
Thu Feb 2 19:54:33 UTC 2023
> **Note:** please also read [this document](https://gist.github.com/mstr2/9f46f92c98d3c86aa6a0b4224a9a6548) to learn about how the platform preferences API interacts with the proposed `StyleTheme` and `Stage.appearance` features.
>
> Platform preferences are the preferred UI settings of the operating system. For example, on Windows this includes the color values identified by the `Windows.UI.ViewManagement.UIColorType` enumeration; on macOS this includes the system color values of the `NSColor` class.
>
> Exposing these dynamic values to JavaFX applications allows developers to create themes that can integrate seamlessly with the color scheme of the operating system.
>
> Platform preferences are exposed as an `ObservableMap` of platform-specific key-value pairs, which means that the preferences available on Windows are different from macOS or Linux. JavaFX provides a small, curated list of preferences that are available on most platforms, and are therefore exposed with a platform-independent API:
>
>
> public interface Preferences extends ObservableMap<String, Object> {
> // Platform-independent API
> ReadOnlyObjectProperty<Appearance> appearanceProperty();
> ReadOnlyObjectProperty<Color> backgroundColorProperty();
> ReadOnlyObjectProperty<Color> foregroundColorProperty();
> ReadOnlyObjectProperty<Color> accentColorProperty();
>
> // Convenience methods to retrieve platform-specific values from the map
> Optional<Integer> getInteger(String key);
> Optional<Double> getDouble(String key);
> Optional<String> getString(String key);
> Optional<Boolean> getBoolean(String key);
> Optional<Color> getColor(String key);
> }
>
>
> The platform appearance is defined by the new `javafx.stage.Appearance` enumeration:
>
>
> public enum Appearance {
> LIGHT,
> DARK
> }
>
>
> An instance of the `Preferences` interface can be retrieved by calling `Platform.getPreferences()`.
Michael Strauß has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 31 commits:
- Merge branch 'master' into feature/platform-preferences
- Use Optional for convenience methods in Preferences
- refactored PlatformPreferencesImpl
- javadoc
- Added appearance and convenience platform properties
- Removed StyleTheme implementation
- update javadoc
- update javadoc
- Rename Application.styleTheme to userAgentStyleTheme
- Changed GTK preference keys
- ... and 21 more: https://git.openjdk.org/jfx/compare/e1f7d0c4...3728cdf0
-------------
Changes: https://git.openjdk.org/jfx/pull/1014/files
Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1014&range=02
Stats: 2412 lines in 28 files changed: 2312 ins; 58 del; 42 mod
Patch: https://git.openjdk.org/jfx/pull/1014.diff
Fetch: git fetch https://git.openjdk.org/jfx pull/1014/head:pull/1014
PR: https://git.openjdk.org/jfx/pull/1014
More information about the openjfx-dev
mailing list