jfxtras-styles icon indicating copy to clipboard operation
jfxtras-styles copied to clipboard

Make JMetros stylesheet be an user agent stylesheet

Open dukke opened this issue 5 years ago • 4 comments

Since JMetro is as of now a regular author stylesheet, unlike Modena, it will overwrite any styling set in code, including FXML (which is code).

If JMetro starts being an user agent stylesheet it will behave just like Modena.

This might be a considerable work, we need to add every Modena defined style that's not currently being defined in JMetro to the JMetro CSS stylesheet.

Users of JMetro are advised, for the time being, to do all the styling in CSS. Add they're own stylesheets that overwrite JMetro CSS after applying JMetro.

If anyone wants to step in and do this they're much welcome. I won't be doing this in the foreseeable future as there are several things currently on my plate.

dukke avatar May 14 '19 02:05 dukke

A quick way to do this might be to add the modena stylesheet first when applying the JMetro theme. And then after add the JMetro stylesheets.

dukke avatar Jul 07 '19 21:07 dukke

I think maybe this should also be a setting: enable/disable JMetro as an user agent stylesheet.

dukke avatar Jul 07 '19 21:07 dukke

Isn't this as simple as copying everything from moderna.css to jmetro.css and then call this method?

Application.setUserAgentStylesheet("jmetro.css");

There is just one minor problem that this public method cannot accept multiple css files, so all the jmetro css files need to be combined into a single css file.

runiter avatar Apr 30 '23 15:04 runiter

Hi @runiter

You've answered yourself 🙂

Not so simple as setUserAgentStylesheet only accepts 1 stylesheet and JMetro has various stylesheets. The best way would be to convince the JavaFX team to add API so that you can provide more than 1 stylesheet to be used as a userAgentStylesheet.

Combining JMetro into a single stylesheet has these disadvantages: 1 - maintenance problem. You would have 1 huge stylesheet with thousands of lines. It's already an issue as it is now, and this would make it much more problematic. 2 - Dark and Light style definitions are defined in 2 separate stylesheets which are added/removed according to what style you choose (Dark or Light)

Possible solutions: 1 - Possibly have a gradle task that copies everything into a single stylesheet before compiling/releasing 2 - Have all definitions in a single stylesheet (which would be maintenance problem as I already explained) and just the variables for dark or light style be defined in a Scene stylesheet

None of these solutions would be ideal. The best, I think, as I said, would be for JavaFX to have an API that supports setting more than 1 stylesheet as user agent stylesheets.

Thanks!

dukke avatar May 01 '23 11:05 dukke