Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: Remove platform theme url from stylesheets, #761

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ public static Theme valueOf(String themeName) {
// no-op
}

public static boolean isPlatformThemeStylesheetURL(String stylesheetURL) {
// Return USER_AGENT css, which is Modena for fx 8.0
return stylesheetURL != null && stylesheetURL.equals(Theme.MODENA.getStylesheetURLs().getFirst());
}

public static String getPlatformThemeStylesheetURL() {
// Return USER_AGENT css, which is Modena for fx 8.0
return Theme.MODENA.getStylesheetURLs().getFirst();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ private void themeDidChange() {
final EditorPlatform.Theme theme = getEditorController().getTheme();
List<String> themeStylesheets = new ArrayList<>(EditorPlatform.getStylesheetsForTheme(theme));
themeStylesheets.addAll(theme.getStylesheetURLs());
workspaceController.setThemeStyleSheet(themeStylesheets, theme);
workspaceController.setThemeStylesheet(themeStylesheets, theme);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,18 @@ public List<String> getThemeStyleSheets() {
return Collections.unmodifiableList(themeStylesheets);
}

public void setThemeStyleSheet(List<String> themeStyleSheets, EditorPlatform.Theme theme) {
assert themeStyleSheets != null;
public void setThemeStylesheet(List<String> themeStylesheets, EditorPlatform.Theme theme) {
assert themeStylesheets != null;
assert theme != null;
List<String> stylesheets = new ArrayList<>(EditorPlatform.getStylesheetsForTheme(theme));
stylesheets.addAll(themeStyleSheets);
contentSubScene.setUserAgentStylesheet(stylesheets.getFirst());
themeStylesheets.stream()
.filter(s -> !EditorPlatform.isPlatformThemeStylesheetURL(s))
.forEach(stylesheets::add);
contentSubScene.setUserAgentStylesheet(stylesheets.stream().findFirst().orElse(null));

ObservableList<String> currentStyleSheets = FXCollections.observableArrayList(stylesheets);
themeStylesheets.clear();
themeStylesheets.addAll(currentStyleSheets);
ObservableList<String> currentStylesheets = FXCollections.observableArrayList(stylesheets);
this.themeStylesheets.clear();
this.themeStylesheets.addAll(currentStylesheets);
contentGroupApplyCss();

// Update scenegraph layout, etc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ public void run() {

Object sceneGraphRoot = clone.getDisplayNodeOrSceneGraphRoot();
themeStyleSheetsList = new ArrayList<>(EditorPlatform.getStylesheetsForTheme(editorController.getTheme()));
themeStyleSheetsList.addAll(editorControllerTheme.getStylesheetURLs());
editorControllerTheme.getStylesheetURLs().stream()
.filter(s -> !EditorPlatform.isPlatformThemeStylesheetURL(s))
.forEach(themeStyleSheetsList::add);

if (sceneGraphRoot instanceof Parent) {
((Parent) sceneGraphRoot).setId(NID_PREVIEW_ROOT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.util.TreeMap;
import java.util.TreeSet;

import com.oracle.javafx.scenebuilder.kit.editor.EditorPlatform;
import javafx.beans.property.ReadOnlyProperty;
import javafx.collections.FXCollections;
import javafx.css.CssMetaData;
Expand Down Expand Up @@ -151,10 +152,12 @@ public static boolean isThemeClass(Theme theme, String styleClass) {

public static List<String> getThemeStyleClasses(Theme theme) {
Set<String> themeClasses = new HashSet<>();
theme.getStylesheetURLs().forEach(themeStyleSheet -> {
URL resource = Button.class.getResource("/" + themeStyleSheet);
themeClasses.addAll(getStyleClasses(resource));
});
theme.getStylesheetURLs().stream()
.filter(s -> !EditorPlatform.isPlatformThemeStylesheetURL(s))
.forEach(themeStyleSheet -> {
URL resource = Button.class.getResource("/" + themeStyleSheet);
themeClasses.addAll(getStyleClasses(resource));
});
return new ArrayList<>(themeClasses);
}

Expand Down