Maybe others will chime in regarding the thin vs. rich API discussion. Regarding the extensibility of themes:
If Modena and Caspian were public API, you could extend those themes simply by subclassing: public class CustomTheme extends Modena { private final ObservableList<String> allStylesheets = FXCollections.observableArrayList(); private final ObservableList<String> customStylesheets = FXCollections.observableArrayList(); public CustomTheme(Map<String, String> properties) { super(properties); // Add custom stylesheets here customStylesheets.add("com/example/custom.css"); // Combine with Modena stylesheets allStylesheets = new ListBinding<>() { { bind(super.getStylesheets(), customStylesheets); } @Override protected ObservableList<String> computeValue() { return FXCollections.concat( super.getStylesheets(), customStylesheets); } }; } @Override public ObservableList<String> getStylesheets() { return allStylesheets; } } Am Di., 25. Mai 2021 um 13:06 Uhr schrieb Pedro Duque Vieira <pedro.duquevie...@gmail.com>: > > Again thanks for bringing this up into discussion and for taking the time to > file a PR, etc. I like the idea of having better support for themes. > > Regarding your first point: > 1 - To keep it simple we can discard the idea of having an API to be able to > check what are the OS settings for dark/light, accent color, etc, for now. I > think that this can be a separate discussion. > We could simply start by having an API that a theme has to implement > (probably an interface that the theme has to implement like what I think > happens with your proposed API). That API has properties: dark/light style, > accent color, etc. Each theme can decide to respond or not to changes in > those properties hence decide whether or not to support these features. > > Regarding the second point: > 2 - Not sure I explained myself well. > What I meant was that right now, and it happens to all themes I know of, > theme creators decide to extend the Modena theme. What I mean by "extend" is > that they add stylesheets to the Scene/Parent (without being user agent > stylesheets). This means they simply build on top of the rules in Modena > which is much easier/better but also means that the rules they define in > their stylesheets will trump any rules defined by the theme users in their > FXMLs, stylesheets (depending on specificity of their rules in their > stylesheets), code... > I think this can be confusing and not ideal for users of these themes, and I > find most of the time theme users don't even know about JavaFX user agent > stylesheets feature vs Scene/Parent stylesheets and what that implies. > What I would propose is to have an API, perhaps in this theme interface, that > toggles whether the theme, theme creators are creating will be a user agent > stylesheet or a regular stylesheet. The advantage would be that if it is a > user agent stylesheet developers won't need to copy all Modena definitions > into their theme stylesheets, they can simply toggle this boolean to say what > kind of stylesheet they want their theme to be. > > Thanks,