RFR: 8301302: Platform preferences API [v3]
John Hendrikx
jhendrikx at openjdk.org
Mon Jul 24 17:45:37 UTC 2023
On Sun, 9 Apr 2023 17:33:42 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:
> In general, platform preferences correspond to OS-level settings and are updated dynamically. Third-party themes might integrate platform preferences into their look and feel, which is often what users expect to see. But consider a scenario where an application uses a third-party theme that adapts to the OS appearance, but the application author only wants to support a dark appearance (independent from the OS appearance).
>
> For this scenario, platform preferences should be overridable from application code. I've considered several potential approaches:
Would an approach similar to how Stylesheets do it be useful here? A property of a control can be overridden programmatically as well as set by CSS. In either case, the getter returns the current value (overridden or set by CSS). When set to a non-null value, the value takes precedence over CSS, and when set to `null` the CSS provided value takes over again.
With the preferences Map, this could work similar perhaps; set a key to whatever you want with put, and restore it to its original value by setting it to null.
> I think I've come around to the idea of dropping the `override` method in favor of `put`. However, I don't like the idea of using `put("key", null)` to reset an overridden mapping to its default value. Having "reset" be its own operation seems to work quite well, though:
I'm a lot happier with this API. I wasn't sure about using `put("key", null)` either -- I was trying to compare it with how properties that can also be styled with CSS work, so we could use a consistent mechanism. But after some testing, I got the impression that CSS doesn't always respect programmatically set values, and still overwrites such values when pseudo classes are involved.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1014#issuecomment-1501206250
PR Comment: https://git.openjdk.org/jfx/pull/1014#issuecomment-1532490625
More information about the openjfx-dev
mailing list