Skip to content

Commit

Permalink
Force refresh of theme and stylesheets when swatch color changes (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
jperedadnr authored Oct 30, 2024
1 parent 2a13273 commit 72791a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2343,6 +2343,8 @@ public boolean canPerform() {
@Override
public void perform() {
GluonEditorController.getInstance().setGluonSwatch(gluonSwatch);
// After swatch changes, force theme update to refresh the content
documentWindowController.getEditorController().refreshTheme();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,16 @@ public ObservableValue<Theme> themeProperty() {
return themeProperty;
}

/**
* Refresh the theme and related stylesheets in different
* places (content, preview, ...)
*/
public void refreshTheme() {
EditorPlatform.Theme currentTheme = getTheme();
setTheme(null);
setTheme(currentTheme);
}

/**
*
* @return the list of scene style sheet used by this editor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,9 @@ private void themeDidChange() {
if (contentGroup != null) {
final EditorPlatform.Theme theme = getEditorController().getTheme();
List<String> themeStylesheets = new ArrayList<>(EditorPlatform.getStylesheetsForTheme(theme));
themeStylesheets.addAll(theme.getStylesheetURLs());
if (theme != null) {
themeStylesheets.addAll(theme.getStylesheetURLs());
}
workspaceController.setThemeStylesheet(themeStylesheets, theme);
}
}
Expand Down

0 comments on commit 72791a2

Please sign in to comment.