mkpaz / atlantafx

Modern JavaFX CSS theme collection with additional controls.
https://mkpaz.github.io/atlantafx
MIT License
840 stars 66 forks source link

Dialog scene is not fully styled #46

Closed RealThanhpv closed 1 year ago

RealThanhpv commented 1 year ago

This is really great lib.

Customize accent color is not applied to dialog scene. I think it should, right?

Screen Shot 2023-03-11 at 9 30 37 AM
mkpaz commented 1 year ago

Thanks! It's a Sampler issue. I think custom pseudo class that changes accent color is added to the main stage root container, so modal stages do not inherit its state.

RealThanhpv commented 1 year ago

I think any scene can be registered to the ThemeManager so that It styles multiple scene as an application may have multiple scenes. And also a public method to style a scene without being registered. I think it is good to make it as a public util.

mkpaz commented 1 year ago

Theme API supposed to be a temporary solution as I expected this PR (https://github.com/openjdk/jfx/pull/511) should be delivered by JFX20. But considering this very long discussion and the last update I suppose it won't be merged this year. As much as I don't like the whole over-engineering around this, I don't want to re-invent the wheel too, because any API I'd publish will obsolete immediately after core API changes.

palexdev commented 1 year ago

@mkpaz is right. Theming a JavaFX app is quite cumbersome right now, would be great to have that proposed API The easiest fix I found while tinkering with the sampler is to activate the pseudo class directly on the Alert pane, fortunately it's easy to retrieve the current color from the ThemeManager

However, there's one thing I'm missing, I'm trying to figure out how are you styling the dialogs. I tried commenting the Application.setUserAgentStylesheet(Objects.requireNonNull(theme.getUserAgentStylesheet())); line in the ThemeManger, but Alerts will still be styled. So, how are you doing it? Alerts/Dialogs/Popups and such are separate Scenes, they do not inherit stylesheets from the main Window, do they? If this is true then, to style a Scene a solution like the one suggested above would be required, the Theme should be added on any separate Window/Scene. This is not desirable tough as it could be quite heavy on performance What am I missing?