From 9ff2442789c76083220f9b2de21d1cb7c0bbc5ca Mon Sep 17 00:00:00 2001 From: huanghongxun Date: Fri, 23 Feb 2018 17:40:32 +0800 Subject: [PATCH] Foreground text fill auto detected --- .../org/jackhuang/hmcl/setting/Theme.java | 24 +++++++++- .../org/jackhuang/hmcl/ui/AccountItem.java | 5 +- .../hmcl/ui/AuthlibInjectorServerItem.java | 3 +- .../java/org/jackhuang/hmcl/ui/Decorator.java | 10 ++++ .../jackhuang/hmcl/ui/LeftPaneController.java | 5 +- .../java/org/jackhuang/hmcl/ui/ModItem.java | 3 +- .../main/java/org/jackhuang/hmcl/ui/SVG.java | 48 ++++++++++--------- .../org/jackhuang/hmcl/ui/VersionItem.java | 9 ++-- .../hmcl/ui/construct/ComponentListCell.java | 3 +- .../jackhuang/hmcl/ui/construct/FileItem.java | 3 +- .../hmcl/ui/construct/ImagePickerItem.java | 3 +- .../hmcl/ui/construct/MessageDialogPane.java | 11 +++-- .../hmcl/ui/construct/MultiFileItem.java | 3 +- HMCL/src/main/resources/assets/css/custom.css | 2 +- .../main/resources/assets/fxml/decorator.fxml | 22 ++------- .../hmcl/game/CompatibilityRule.java | 2 +- .../hmcl/game/DefaultGameRepository.java | 3 +- .../java/org/jackhuang/hmcl/game/Version.java | 6 +-- 18 files changed, 99 insertions(+), 66 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/setting/Theme.java b/HMCL/src/main/java/org/jackhuang/hmcl/setting/Theme.java index e445e5fdd..a5dd4a8aa 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/setting/Theme.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/setting/Theme.java @@ -17,6 +17,8 @@ */ package org.jackhuang.hmcl.setting; +import javafx.beans.binding.Bindings; +import javafx.beans.binding.ObjectBinding; import javafx.scene.paint.Color; import org.jackhuang.hmcl.util.FileUtils; import org.jackhuang.hmcl.util.IOUtils; @@ -57,12 +59,22 @@ public class Theme { return name.startsWith("#"); } + public boolean isLight() { + return Color.web(color).grayscale().getRed() >= 0.5; + } + + public Color getForegroundColor() { + return isLight() ? Color.BLACK : Color.WHITE; + } + public String[] getStylesheets() { String name = isCustom() ? BLUE.getName() : this.name; String css = Theme.class.getResource("/assets/css/" + name + ".css").toExternalForm(); try { File temp = File.createTempFile("hmcl", ".css"); - FileUtils.writeText(temp, IOUtils.readFullyAsString(Theme.class.getResourceAsStream("/assets/css/custom.css")).replace("%base-color%", color)); + FileUtils.writeText(temp, IOUtils.readFullyAsString(Theme.class.getResourceAsStream("/assets/css/custom.css")) + .replace("%base-color%", color) + .replace("%font-color%", getColorDisplayName(getForegroundColor()))); css = temp.toURI().toString(); } catch (IOException e) { Logging.LOG.log(Level.SEVERE, "Unable to create theme stylesheet", e); @@ -104,5 +116,15 @@ public class Theme { return c != null ? String.format("#%02x%02x%02x", Math.round(c.getRed() * 255.0D), Math.round(c.getGreen() * 255.0D), Math.round(c.getBlue() * 255.0D)).toUpperCase() : null; } + public static ObjectBinding foregroundFillBinding() { + return Bindings.createObjectBinding(() -> Settings.INSTANCE.getTheme().getForegroundColor(), Settings.INSTANCE.themeProperty()); + } + public static ObjectBinding blackFillBinding() { + return Bindings.createObjectBinding(() -> Color.BLACK); + } + + public static ObjectBinding whiteFillBinding() { + return Bindings.createObjectBinding(() -> Color.WHITE); + } } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/AccountItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/AccountItem.java index a26e529a6..57c0db788 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/AccountItem.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/AccountItem.java @@ -41,6 +41,7 @@ import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount; import org.jackhuang.hmcl.game.AccountHelper; import org.jackhuang.hmcl.setting.Accounts; import org.jackhuang.hmcl.setting.Settings; +import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.task.Schedulers; import org.jackhuang.hmcl.task.Task; @@ -73,8 +74,8 @@ public final class AccountItem extends StackPane { setEffect(new DropShadow(BlurType.GAUSSIAN, Color.rgb(0, 0, 0, 0.26), 5.0, 0.12, -0.5, 1.0)); chkSelected.setToggleGroup(toggleGroup); - btnDelete.setGraphic(SVG.delete("black", 15, 15)); - btnRefresh.setGraphic(SVG.refresh("black", 15, 15)); + btnDelete.setGraphic(SVG.delete(Theme.blackFillBinding(), 15, 15)); + btnRefresh.setGraphic(SVG.refresh(Theme.blackFillBinding(), 15, 15)); // create image view icon.translateYProperty().bind(Bindings.createDoubleBinding(() -> header.getBoundsInParent().getHeight() - icon.getHeight() / 2 - 16, header.boundsInParentProperty(), icon.heightProperty())); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/AuthlibInjectorServerItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/AuthlibInjectorServerItem.java index dd327fd6e..09df2e5fb 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/AuthlibInjectorServerItem.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/AuthlibInjectorServerItem.java @@ -24,6 +24,7 @@ import javafx.scene.control.Label; import javafx.scene.layout.BorderPane; import javafx.scene.layout.VBox; import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServerInfo; +import org.jackhuang.hmcl.setting.Theme; import java.util.function.Consumer; @@ -48,7 +49,7 @@ public final class AuthlibInjectorServerItem extends BorderPane { right.setOnMouseClicked(e -> deleteCallback.accept(this)); right.getStyleClass().add("toggle-icon4"); BorderPane.setAlignment(right, Pos.CENTER); - right.setGraphic(SVG.close("black", 15, 15)); + right.setGraphic(SVG.close(Theme.blackFillBinding(), 15, 15)); setRight(right); setStyle("-fx-background-radius: 2; -fx-background-color: white; -fx-padding: 8;"); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Decorator.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Decorator.java index bfd8ede29..530d36377 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Decorator.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Decorator.java @@ -48,6 +48,7 @@ import javafx.stage.StageStyle; import org.jackhuang.hmcl.Main; import org.jackhuang.hmcl.setting.EnumBackgroundImage; import org.jackhuang.hmcl.setting.Settings; +import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.ui.animation.AnimationProducer; import org.jackhuang.hmcl.ui.animation.ContainerAnimations; import org.jackhuang.hmcl.ui.animation.TransitionHandler; @@ -150,6 +151,15 @@ public final class Decorator extends StackPane implements TaskExecutorDialogWiza btnMin.setGraphic(minus); btnMax.setGraphic(resizeMax); + close.fillProperty().bind(Theme.foregroundFillBinding()); + minus.fillProperty().bind(Theme.foregroundFillBinding()); + resizeMax.fillProperty().bind(Theme.foregroundFillBinding()); + resizeMin.fillProperty().bind(Theme.foregroundFillBinding()); + + refreshNavButton.setGraphic(SVG.refresh(Theme.foregroundFillBinding(), 15, 15)); + closeNavButton.setGraphic(SVG.close(Theme.foregroundFillBinding(), 15, 15)); + backNavButton.setGraphic(SVG.back(Theme.foregroundFillBinding(), 15, 15)); + lblTitle.setText(title); buttonsContainer.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY))); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java index e93dfc4a3..b67caaf05 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java @@ -39,6 +39,7 @@ import org.jackhuang.hmcl.mod.UnsupportedModpackException; import org.jackhuang.hmcl.setting.Profile; import org.jackhuang.hmcl.setting.Profiles; import org.jackhuang.hmcl.setting.Settings; +import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.task.Schedulers; import org.jackhuang.hmcl.task.Task; import org.jackhuang.hmcl.ui.construct.AdvancedListBox; @@ -65,14 +66,14 @@ public final class LeftPaneController { accountItem.setOnSettingsButtonClicked(() -> Controllers.navigate(new AccountsPage())); })) .startCategory(Main.i18n("launcher").toUpperCase()) - .add(Lang.apply(new IconedItem(SVG.gear("black", 20, 20), Main.i18n("settings.launcher")), iconedItem -> { + .add(Lang.apply(new IconedItem(SVG.gear(Theme.blackFillBinding(), 20, 20), Main.i18n("settings.launcher")), iconedItem -> { iconedItem.prefWidthProperty().bind(leftPane.widthProperty()); iconedItem.setOnMouseClicked(e -> Controllers.navigate(Controllers.getSettingsPage())); })) .add(new ClassTitle(Lang.apply(new BorderPane(), borderPane -> { borderPane.setLeft(Lang.apply(new VBox(), vBox -> vBox.getChildren().setAll(new Text(Main.i18n("profile.title").toUpperCase())))); JFXButton addProfileButton = new JFXButton(); - addProfileButton.setGraphic(SVG.plus("black", 10, 10)); + addProfileButton.setGraphic(SVG.plus(Theme.blackFillBinding(), 10, 10)); addProfileButton.getStyleClass().add("toggle-icon-tiny"); addProfileButton.setOnMouseClicked(e -> Controllers.getDecorator().showPage(new ProfilePage(null))); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/ModItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/ModItem.java index d85b5e06b..6c16b627b 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/ModItem.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/ModItem.java @@ -24,6 +24,7 @@ import javafx.geometry.Pos; import javafx.scene.layout.BorderPane; import org.jackhuang.hmcl.Main; import org.jackhuang.hmcl.mod.ModInfo; +import org.jackhuang.hmcl.setting.Theme; import java.util.function.Consumer; @@ -43,7 +44,7 @@ public final class ModItem extends BorderPane { btnRemove.setOnMouseClicked(e -> deleteCallback.accept(this)); btnRemove.getStyleClass().add("toggle-icon4"); BorderPane.setAlignment(btnRemove, Pos.CENTER); - btnRemove.setGraphic(SVG.close("black", 15, 15)); + btnRemove.setGraphic(SVG.close(Theme.blackFillBinding(), 15, 15)); setRight(btnRemove); setStyle("-fx-background-radius: 2; -fx-background-color: white; -fx-padding: 8;"); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/SVG.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/SVG.java index f1b7d08b8..65f15b6f3 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/SVG.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/SVG.java @@ -17,19 +17,21 @@ */ package org.jackhuang.hmcl.ui; +import javafx.beans.binding.ObjectBinding; import javafx.scene.Group; import javafx.scene.Node; +import javafx.scene.paint.Paint; import javafx.scene.shape.SVGPath; public final class SVG { private SVG() { } - private static Node createSVGPath(String d, String fill, double width, double height) { + private static Node createSVGPath(String d, ObjectBinding fill, double width, double height) { SVGPath path = new SVGPath(); path.getStyleClass().add("svg"); path.setContent(d); - path.setStyle("-fx-fill: " + fill + ";"); + path.fillProperty().bind(fill); Group svg = new Group(path); double scale = Math.min(width / svg.getBoundsInParent().getWidth(), height / svg.getBoundsInParent().getHeight()); @@ -41,87 +43,87 @@ public final class SVG { // default fill: white, width: 20, height 20 - public static Node gear(String fill, double width, double height) { + public static Node gear(ObjectBinding fill, double width, double height) { return createSVGPath("M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z", fill, width, height); } - public static Node back(String fill, double width, double height) { + public static Node back(ObjectBinding fill, double width, double height) { return createSVGPath("M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z", fill, width, height); } - public static Node close(String fill, double width, double height) { + public static Node close(ObjectBinding fill, double width, double height) { return createSVGPath("M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z", fill, width, height); } - public static Node dotsVertical(String fill, double width, double height) { + public static Node dotsVertical(ObjectBinding fill, double width, double height) { return createSVGPath("M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z", fill, width, height); } - public static Node delete(String fill, double width, double height) { + public static Node delete(ObjectBinding fill, double width, double height) { return createSVGPath("M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z", fill, width, height); } - public static Node accountEdit(String fill, double width, double height) { + public static Node accountEdit(ObjectBinding fill, double width, double height) { return createSVGPath("M21.7,13.35L20.7,14.35L18.65,12.3L19.65,11.3C19.86,11.09 20.21,11.09 20.42,11.3L21.7,12.58C21.91,12.79 21.91,13.14 21.7,13.35M12,18.94L18.06,12.88L20.11,14.93L14.06,21H12V18.94M12,14C7.58,14 4,15.79 4,18V20H10V18.11L14,14.11C13.34,14.03 12.67,14 12,14M12,4A4,4 0 0,0 8,8A4,4 0 0,0 12,12A4,4 0 0,0 16,8A4,4 0 0,0 12,4Z", fill, width, height); } - public static Node expand(String fill, double width, double height) { + public static Node expand(ObjectBinding fill, double width, double height) { return createSVGPath("M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z", fill, width, height); } - public static Node collapse(String fill, double width, double height) { + public static Node collapse(ObjectBinding fill, double width, double height) { return createSVGPath("M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z", fill, width, height); } - public static Node navigate(String fill, double width, double height) { + public static Node navigate(ObjectBinding fill, double width, double height) { return createSVGPath("M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z", fill, width, height); } - public static Node launch(String fill, double width, double height) { + public static Node launch(ObjectBinding fill, double width, double height) { return createSVGPath("M1008 6.286q18.857 13.714 15.429 36.571l-146.286 877.714q-2.857 16.571-18.286 25.714-8 4.571-17.714 4.571-6.286 0-13.714-2.857l-258.857-105.714-138.286 168.571q-10.286 13.143-28 13.143-7.429 0-12.571-2.286-10.857-4-17.429-13.429t-6.571-20.857v-199.429l493.714-605.143-610.857 528.571-225.714-92.571q-21.143-8-22.857-31.429-1.143-22.857 18.286-33.714l950.857-548.571q8.571-5.143 18.286-5.14311.429 0 20.571 6.286z", fill, width, height); } - public static Node script(String fill, double width, double height) { + public static Node script(ObjectBinding fill, double width, double height) { return createSVGPath("M14,20A2,2 0 0,0 16,18V5H9A1,1 0 0,0 8,6V16H5V5A3,3 0 0,1 8,2H19A3,3 0 0,1 22,5V6H18V18L18,19A3,3 0 0,1 15,22H5A3,3 0 0,1 2,19V18H12A2,2 0 0,0 14,20Z", fill, width, height); } - public static Node pencil(String fill, double width, double height) { + public static Node pencil(ObjectBinding fill, double width, double height) { return createSVGPath("M20.71,4.04C21.1,3.65 21.1,3 20.71,2.63L18.37,0.29C18,-0.1 17.35,-0.1 16.96,0.29L15,2.25L18.75,6M17.75,7L14,3.25L4,13.25V17H7.75L17.75,7Z", fill, width, height); } - public static Node refresh(String fill, double width, double height) { + public static Node refresh(ObjectBinding fill, double width, double height) { return createSVGPath("M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z", fill, width, height); } - public static Node folderOpen(String fill, double width, double height) { + public static Node folderOpen(ObjectBinding fill, double width, double height) { return createSVGPath("M19,20H4C2.89,20 2,19.1 2,18V6C2,4.89 2.89,4 4,4H10L12,6H19A2,2 0 0,1 21,8H21L4,8V18L6.14,10H23.21L20.93,18.5C20.7,19.37 19.92,20 19,20Z", fill, width, height); } - public static Node update(String fill, double width, double height) { + public static Node update(ObjectBinding fill, double width, double height) { return createSVGPath("M21,10.12H14.22L16.96,7.3C14.23,4.6 9.81,4.5 7.08,7.2C4.35,9.91 4.35,14.28 7.08,17C9.81,19.7 14.23,19.7 16.96,17C18.32,15.65 19,14.08 19,12.1H21C21,14.08 20.12,16.65 18.36,18.39C14.85,21.87 9.15,21.87 5.64,18.39C2.14,14.92 2.11,9.28 5.62,5.81C9.13,2.34 14.76,2.34 18.27,5.81L21,3V10.12M12.5,8V12.25L16,14.33L15.28,15.54L11,13V8H12.5Z", fill, width, height); } - public static Node closeCircle(String fill, double width, double height) { + public static Node closeCircle(ObjectBinding fill, double width, double height) { return createSVGPath("M12,2C17.53,2 22,6.47 22,12C22,17.53 17.53,22 12,22C6.47,22 2,17.53 2,12C2,6.47 6.47,2 12,2M15.59,7L12,10.59L8.41,7L7,8.41L10.59,12L7,15.59L8.41,17L12,13.41L15.59,17L17,15.59L13.41,12L17,8.41L15.59,7Z", fill, width, height); } - public static Node checkCircle(String fill, double width, double height) { + public static Node checkCircle(ObjectBinding fill, double width, double height) { return createSVGPath("M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M11,16.5L18,9.5L16.59,8.09L11,13.67L7.91,10.59L6.5,12L11,16.5Z", fill, width, height); } - public static Node infoCircle(String fill, double width, double height) { + public static Node infoCircle(ObjectBinding fill, double width, double height) { return createSVGPath("M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z", fill, width, height); } - public static Node helpCircle(String fill, double width, double height) { + public static Node helpCircle(ObjectBinding fill, double width, double height) { return createSVGPath("M15.07,11.25L14.17,12.17C13.45,12.89 13,13.5 13,15H11V14.5C11,13.39 11.45,12.39 12.17,11.67L13.41,10.41C13.78,10.05 14,9.55 14,9C14,7.89 13.1,7 12,7A2,2 0 0,0 10,9H8A4,4 0 0,1 12,5A4,4 0 0,1 16,9C16,9.88 15.64,10.67 15.07,11.25M13,19H11V17H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z", fill, width, height); } - public static Node alert(String fill, double width, double height) { + public static Node alert(ObjectBinding fill, double width, double height) { return createSVGPath("M13,14H11V10H13M13,18H11V16H13M1,21H23L12,2L1,21Z", fill, width, height); } - public static Node plus(String fill, double width, double height) { + public static Node plus(ObjectBinding fill, double width, double height) { return createSVGPath("M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z", fill, width, height); } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/VersionItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/VersionItem.java index d9f6018bd..f18996d27 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/VersionItem.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/VersionItem.java @@ -33,6 +33,7 @@ import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import org.jackhuang.hmcl.Main; +import org.jackhuang.hmcl.setting.Theme; import java.util.Optional; @@ -67,10 +68,10 @@ public final class VersionItem extends StackPane { public VersionItem() { FXUtils.loadFXML(this, "/assets/fxml/version-item.fxml"); setEffect(new DropShadow(BlurType.GAUSSIAN, Color.rgb(0, 0, 0, 0.26), 5.0, 0.12, -1.0, 1.0)); - btnSettings.setGraphic(SVG.gear("black", 15, 15)); - btnUpdate.setGraphic(SVG.update("black", 15, 15)); - btnLaunch.setGraphic(SVG.launch("black", 15, 15)); - btnScript.setGraphic(SVG.script("black", 15, 15)); + btnSettings.setGraphic(SVG.gear(Theme.blackFillBinding(), 15, 15)); + btnUpdate.setGraphic(SVG.update(Theme.blackFillBinding(), 15, 15)); + btnLaunch.setGraphic(SVG.launch(Theme.blackFillBinding(), 15, 15)); + btnScript.setGraphic(SVG.script(Theme.blackFillBinding(), 15, 15)); FXUtils.installTooltip(btnSettings, Main.i18n("version.settings")); FXUtils.installTooltip(btnUpdate, Main.i18n("version.update")); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/ComponentListCell.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/ComponentListCell.java index bae1fe04b..71d39a077 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/ComponentListCell.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/ComponentListCell.java @@ -31,6 +31,7 @@ import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.shape.Rectangle; import javafx.util.Duration; +import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.SVG; @@ -77,7 +78,7 @@ public class ComponentListCell extends StackPane { StackPane groupNode = new StackPane(); groupNode.getStyleClass().add("options-list-item-header"); - Node expandIcon = SVG.expand("black", 10, 10); + Node expandIcon = SVG.expand(Theme.blackFillBinding(), 10, 10); JFXButton expandButton = new JFXButton(); expandButton.setGraphic(expandIcon); expandButton.getStyleClass().add("options-list-item-expand-button"); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/FileItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/FileItem.java index 6b64924c2..0bbfa6bb9 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/FileItem.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/FileItem.java @@ -27,6 +27,7 @@ import javafx.scene.layout.BorderPane; import javafx.scene.layout.VBox; import javafx.stage.DirectoryChooser; import org.jackhuang.hmcl.Main; +import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.ui.Controllers; import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.SVG; @@ -50,7 +51,7 @@ public class FileItem extends BorderPane { setLeft(left); JFXButton right = new JFXButton(); - right.setGraphic(SVG.pencil("black", 15, 15)); + right.setGraphic(SVG.pencil(Theme.blackFillBinding(), 15, 15)); right.getStyleClass().add("toggle-icon4"); right.setOnMouseClicked(e -> onExplore()); FXUtils.installTooltip(right, Main.i18n("button.edit")); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/ImagePickerItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/ImagePickerItem.java index 29fab5f77..ee6932e65 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/ImagePickerItem.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/ImagePickerItem.java @@ -16,6 +16,7 @@ import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import org.jackhuang.hmcl.Main; +import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.SVG; @@ -36,7 +37,7 @@ public final class ImagePickerItem extends BorderPane { imageView.setPreserveRatio(true); selectButton = new JFXButton(); - selectButton.setGraphic(SVG.pencil("black", 15, 15)); + selectButton.setGraphic(SVG.pencil(Theme.blackFillBinding(), 15, 15)); selectButton.onMouseClickedProperty().bind(onSelectButtonClicked); selectButton.getStyleClass().add("toggle-icon4"); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/MessageDialogPane.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/MessageDialogPane.java index bb787278e..340b4e6ea 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/MessageDialogPane.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/MessageDialogPane.java @@ -24,6 +24,7 @@ import javafx.scene.control.Label; import javafx.scene.layout.HBox; import javafx.scene.layout.StackPane; import org.jackhuang.hmcl.Main; +import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.SVG; @@ -62,19 +63,19 @@ public final class MessageDialogPane extends StackPane { switch (type) { case MessageBox.INFORMATION_MESSAGE: - graphic.setGraphic(SVG.infoCircle("black", 40, 40)); + graphic.setGraphic(SVG.infoCircle(Theme.blackFillBinding(), 40, 40)); break; case MessageBox.ERROR_MESSAGE: - graphic.setGraphic(SVG.closeCircle("black", 40, 40)); + graphic.setGraphic(SVG.closeCircle(Theme.blackFillBinding(), 40, 40)); break; case MessageBox.FINE_MESSAGE: - graphic.setGraphic(SVG.checkCircle("black", 40, 40)); + graphic.setGraphic(SVG.checkCircle(Theme.blackFillBinding(), 40, 40)); break; case MessageBox.WARNING_MESSAGE: - graphic.setGraphic(SVG.alert("black", 40, 40)); + graphic.setGraphic(SVG.alert(Theme.blackFillBinding(), 40, 40)); break; case MessageBox.QUESTION_MESSAGE: - graphic.setGraphic(SVG.helpCircle("black", 40, 40)); + graphic.setGraphic(SVG.helpCircle(Theme.blackFillBinding(), 40, 40)); break; default: throw new IllegalArgumentException("Unrecognized message box message type " + type); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/MultiFileItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/MultiFileItem.java index 896aab2ed..c37fdc6ac 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/MultiFileItem.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/MultiFileItem.java @@ -39,6 +39,7 @@ import javafx.scene.layout.VBox; import javafx.stage.DirectoryChooser; import javafx.stage.FileChooser; import org.jackhuang.hmcl.Main; +import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.ui.Controllers; import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.SVG; @@ -69,7 +70,7 @@ public class MultiFileItem extends ComponentList { BorderPane.setAlignment(txtCustom, Pos.CENTER_RIGHT); - btnSelect.setGraphic(SVG.folderOpen("black", 15, 15)); + btnSelect.setGraphic(SVG.folderOpen(Theme.blackFillBinding(), 15, 15)); btnSelect.setOnMouseClicked(e -> { if (isDirectory()) { DirectoryChooser chooser = new DirectoryChooser(); diff --git a/HMCL/src/main/resources/assets/css/custom.css b/HMCL/src/main/resources/assets/css/custom.css index cbf891256..df4d7e856 100644 --- a/HMCL/src/main/resources/assets/css/custom.css +++ b/HMCL/src/main/resources/assets/css/custom.css @@ -1,5 +1,5 @@ .root { -fx-base-color: %base-color%; -fx-base-check-color: derive(-fx-base-color, 30%); - -fx-base-text-fill: white; + -fx-base-text-fill: %font-color%; } \ No newline at end of file diff --git a/HMCL/src/main/resources/assets/fxml/decorator.fxml b/HMCL/src/main/resources/assets/fxml/decorator.fxml index 098a30f7a..5bce78d2b 100644 --- a/HMCL/src/main/resources/assets/fxml/decorator.fxml +++ b/HMCL/src/main/resources/assets/fxml/decorator.fxml @@ -68,7 +68,7 @@