Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Force refresh of theme and stylesheets when swatch color changes #781

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

jperedadnr
Copy link
Collaborator

Issue

Fixes #764

When the swatch color property changes, the list of external stylesheets applied to the current theme changes too, so the editorController needs to make another call to retrieve those, if any (for instance, when the Gluon plugin is present), and refresh content/preview/... accordingly

Progress

@jperedadnr jperedadnr changed the title Force refresh of theme and stylesheets when swatch color changes fix: Force refresh of theme and stylesheets when swatch color changes Oct 28, 2024
Comment on lines +589 to +590
setTheme(null);
setTheme(currentTheme);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is setting the theme to null required?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EditorController has themeProperty with a default theme. When the theme changes, it refresh the scene graph from the invalidated() method, and there are a bunch of listeners in different places (5 so far) attached to themeProperty() that react accordingly.

For instance, in ContentPaneController we have:

editorController.themeProperty().addListener((ov, t, t1) -> themeDidChange());

that ultimately calls EditorPlatform::getStylesheetsForTheme, that brings in the Gluon plugin stylesheets and the updated swatch color stylesheet.

The easy way to trigger all those listeners is to force an invalidation of editorController.themeProperty(), and that's easily done with setting null and restoring the current theme.

@jperedadnr jperedadnr merged commit 72791a2 into gluonhq:master Oct 30, 2024
3 checks passed
@jperedadnr jperedadnr deleted the 764-swatch branch October 30, 2024 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changing swatch color doesn't update content/preview after #748
3 participants