diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/IconedItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/IconedItem.java index 3ed7583a1..b915aed44 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/IconedItem.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/IconedItem.java @@ -26,19 +26,20 @@ public class IconedItem extends RipplerContainer { private Label label; - public IconedItem(Node icon, String text, String styleClass) { - this(icon, styleClass); + public IconedItem(Node icon, String text) { + this(icon); label.setText(text); } - public IconedItem(Node icon, String styleClass) { - super(createHBox(icon, styleClass)); + public IconedItem(Node icon) { + super(createHBox(icon)); label = ((Label) lookup("#label")); + getStyleClass().setAll("iconed-item"); } - private static HBox createHBox(Node icon, String styleClass) { + private static HBox createHBox(Node icon) { HBox hBox = new HBox(); - hBox.getStyleClass().setAll(styleClass); + hBox.getStyleClass().setAll("iconed-item-container"); icon.setMouseTransparent(true); Label textLabel = new Label(); textLabel.setId("label"); @@ -50,9 +51,4 @@ public class IconedItem extends RipplerContainer { public Label getLabel() { return label; } - - public IconedItem setClickedAction(Runnable r) { - setOnMouseClicked(e -> r.run()); - return this; - } } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/IconedMenuItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/IconedMenuItem.java new file mode 100644 index 000000000..79bf2b4e6 --- /dev/null +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/IconedMenuItem.java @@ -0,0 +1,30 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2017 huangyuhui + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ +package org.jackhuang.hmcl.ui.construct; + +import javafx.scene.Node; + +public class IconedMenuItem extends IconedItem { + + public IconedMenuItem(Node node, String text, Runnable action) { + super(node, text); + + getStyleClass().setAll("iconed-menu-item"); + setOnMouseClicked(e -> action.run()); + } +} diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListItemSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListItemSkin.java index bc42550f5..64565be9b 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListItemSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListItemSkin.java @@ -35,6 +35,7 @@ import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.SVG; import org.jackhuang.hmcl.ui.construct.IconedItem; +import org.jackhuang.hmcl.ui.construct.IconedMenuItem; import org.jackhuang.hmcl.ui.construct.TwoLineListItem; import java.util.function.Consumer; @@ -91,13 +92,13 @@ public class GameListItemSkin extends SkinBase { }; menu.getChildren().setAll( - new IconedItem(limitWidth.apply(SVG.gear(Theme.blackFillBinding(), 14, 14)), i18n("settings"), "menu-iconed-item").setClickedAction(wrap.apply(skinnable::modifyGameSettings)), - new IconedItem(limitWidth.apply(SVG.pencil(Theme.blackFillBinding(), 14, 14)), i18n("version.manage.rename"), "menu-iconed-item").setClickedAction(wrap.apply(skinnable::rename)), - new IconedItem(limitWidth.apply(SVG.delete(Theme.blackFillBinding(), 14, 14)), i18n("version.manage.remove"), "menu-iconed-item").setClickedAction(wrap.apply(skinnable::remove)), - new IconedItem(limitWidth.apply(SVG.export(Theme.blackFillBinding(), 14, 14)), i18n("modpack.export"), "menu-iconed-item").setClickedAction(wrap.apply(skinnable::export)), - new IconedItem(limitWidth.apply(SVG.folderOpen(Theme.blackFillBinding(), 14, 14)), i18n("folder.game"), "menu-iconed-item").setClickedAction(wrap.apply(skinnable::browse)), - new IconedItem(limitWidth.apply(SVG.launch(Theme.blackFillBinding(), 14, 14)), i18n("version.launch"), "menu-iconed-item").setClickedAction(wrap.apply(skinnable::launch)), - new IconedItem(limitWidth.apply(SVG.script(Theme.blackFillBinding(), 14, 14)), i18n("version.launch_script"), "menu-iconed-item").setClickedAction(wrap.apply(skinnable::generateLaunchScript))); + new IconedMenuItem(limitWidth.apply(SVG.gear(Theme.blackFillBinding(), 14, 14)), i18n("settings"), wrap.apply(skinnable::modifyGameSettings)), + new IconedMenuItem(limitWidth.apply(SVG.pencil(Theme.blackFillBinding(), 14, 14)), i18n("version.manage.rename"), wrap.apply(skinnable::rename)), + new IconedMenuItem(limitWidth.apply(SVG.delete(Theme.blackFillBinding(), 14, 14)), i18n("version.manage.remove"), wrap.apply(skinnable::remove)), + new IconedMenuItem(limitWidth.apply(SVG.export(Theme.blackFillBinding(), 14, 14)), i18n("modpack.export"), wrap.apply(skinnable::export)), + new IconedMenuItem(limitWidth.apply(SVG.folderOpen(Theme.blackFillBinding(), 14, 14)), i18n("folder.game"), wrap.apply(skinnable::browse)), + new IconedMenuItem(limitWidth.apply(SVG.launch(Theme.blackFillBinding(), 14, 14)), i18n("version.launch"), wrap.apply(skinnable::launch)), + new IconedMenuItem(limitWidth.apply(SVG.script(Theme.blackFillBinding(), 14, 14)), i18n("version.launch_script"), wrap.apply(skinnable::generateLaunchScript))); HBox right = new HBox(); right.setAlignment(Pos.CENTER_RIGHT); diff --git a/HMCL/src/main/resources/assets/css/root.css b/HMCL/src/main/resources/assets/css/root.css index cbb47bcb2..72f7e5fcc 100644 --- a/HMCL/src/main/resources/assets/css/root.css +++ b/HMCL/src/main/resources/assets/css/root.css @@ -59,14 +59,14 @@ -fx-padding: 20 0 20 0; } -.iconed-item { +.iconed-item .iconed-item-container { -fx-padding: 10 16 10 16; -fx-spacing: 10; -fx-font-size: 14; -fx-alignment: CENTER_LEFT; } -.menu-iconed-item { +.iconed-menu-item .iconed-item-container { -fx-padding: 10 16 10 16; -fx-spacing: 10; -fx-font-size: 12;