From 47a4a0eaf50e22c00c2bf1a56156c21194a80cdd Mon Sep 17 00:00:00 2001 From: huangyuhui Date: Mon, 12 Feb 2018 23:23:39 +0800 Subject: [PATCH] Add profile button move to category title --- .../org/jackhuang/hmcl/ui/AccountsPage.java | 1 + .../java/org/jackhuang/hmcl/ui/Decorator.java | 7 +---- .../jackhuang/hmcl/ui/LeftPaneController.java | 23 +++++++++++----- .../main/java/org/jackhuang/hmcl/ui/SVG.java | 12 ++++++--- .../ui/{ => construct}/AdvancedListBox.java | 3 ++- .../hmcl/ui/{ => construct}/ClassTitle.java | 17 +++++++----- .../hmcl/ui/construct/MessageDialogPane.java | 8 +++--- .../hmcl/ui/construct/TaskListPane.java | 4 --- .../assets/css/jfoenix-main-demo.css | 26 ++++++++++++++++++- .../main/resources/assets/fxml/decorator.fxml | 9 +------ 10 files changed, 69 insertions(+), 41 deletions(-) rename HMCL/src/main/java/org/jackhuang/hmcl/ui/{ => construct}/AdvancedListBox.java (97%) rename HMCL/src/main/java/org/jackhuang/hmcl/ui/{ => construct}/ClassTitle.java (81%) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/AccountsPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/AccountsPage.java index b37767ced..ce98d5e95 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/AccountsPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/AccountsPage.java @@ -44,6 +44,7 @@ import org.jackhuang.hmcl.setting.Accounts; import org.jackhuang.hmcl.setting.Settings; import org.jackhuang.hmcl.task.Schedulers; import org.jackhuang.hmcl.task.Task; +import org.jackhuang.hmcl.ui.construct.AdvancedListBox; import org.jackhuang.hmcl.ui.construct.IconedItem; import org.jackhuang.hmcl.ui.construct.Validator; import org.jackhuang.hmcl.ui.wizard.DecoratorPage; 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 5330b6c31..78f32cc12 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Decorator.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Decorator.java @@ -47,6 +47,7 @@ import org.jackhuang.hmcl.Main; import org.jackhuang.hmcl.ui.animation.AnimationProducer; import org.jackhuang.hmcl.ui.animation.ContainerAnimations; import org.jackhuang.hmcl.ui.animation.TransitionHandler; +import org.jackhuang.hmcl.ui.construct.AdvancedListBox; import org.jackhuang.hmcl.ui.construct.TaskExecutorDialogWizardDisplayer; import org.jackhuang.hmcl.ui.wizard.*; import org.jackhuang.hmcl.util.Lang; @@ -97,8 +98,6 @@ public final class Decorator extends StackPane implements TaskExecutorDialogWiza @FXML private JFXButton refreshMenuButton; @FXML - private JFXButton addMenuButton; - @FXML private Label titleLabel; @FXML private Label lblTitle; @@ -547,10 +546,6 @@ public final class Decorator extends StackPane implements TaskExecutorDialogWiza return dialog; } - public JFXButton getAddMenuButton() { - return addMenuButton; - } - public AdvancedListBox getLeftPane() { return leftPane; } 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 e36a62936..fd7eb0494 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java @@ -18,13 +18,15 @@ package org.jackhuang.hmcl.ui; import com.jfoenix.concurrency.JFXUtilities; +import com.jfoenix.controls.JFXButton; import javafx.application.Platform; import javafx.scene.Node; import javafx.scene.image.Image; +import javafx.scene.layout.BorderPane; import javafx.scene.layout.VBox; import javafx.scene.paint.Paint; +import javafx.scene.text.Text; import org.jackhuang.hmcl.Main; -import org.jackhuang.hmcl.auth.Account; import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount; import org.jackhuang.hmcl.event.EventBus; import org.jackhuang.hmcl.event.ProfileChangedEvent; @@ -40,9 +42,10 @@ import org.jackhuang.hmcl.setting.Profile; import org.jackhuang.hmcl.setting.Settings; import org.jackhuang.hmcl.task.Schedulers; import org.jackhuang.hmcl.task.Task; +import org.jackhuang.hmcl.ui.construct.AdvancedListBox; +import org.jackhuang.hmcl.ui.construct.ClassTitle; import org.jackhuang.hmcl.ui.construct.IconedItem; import org.jackhuang.hmcl.ui.construct.RipplerContainer; -import org.jackhuang.hmcl.ui.construct.TaskExecutorDialogPane; import org.jackhuang.hmcl.util.Lang; import org.jackhuang.hmcl.util.Pair; @@ -68,17 +71,23 @@ public final class LeftPaneController { iconedItem.prefWidthProperty().bind(leftPane.widthProperty()); iconedItem.setOnMouseClicked(e -> Controllers.navigate(Controllers.getSettingsPage())); })) - .startCategory(Main.i18n("profile.title").toUpperCase()) + .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.getStyleClass().add("toggle-icon-tiny"); + addProfileButton.setOnMouseClicked(e -> + Controllers.getDecorator().showPage(new ProfilePage(null))); + borderPane.setRight(addProfileButton); + }))) .add(profilePane); EventBus.EVENT_BUS.channel(ProfileLoadingEvent.class).register(this::onProfilesLoading); EventBus.EVENT_BUS.channel(ProfileChangedEvent.class).register(this::onProfileChanged); EventBus.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(this::onRefreshedVersions); - Controllers.getDecorator().getAddMenuButton().setOnMouseClicked(e -> - Controllers.getDecorator().showPage(new ProfilePage(null)) - ); - FXUtils.onChangeAndOperate(Settings.INSTANCE.selectedAccountProperty(), it -> { if (it == null) { accountItem.setVersionName(Main.i18n("account.missing")); 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 8646bb551..2c9c23d45 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/SVG.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/SVG.java @@ -101,19 +101,19 @@ public final class SVG { 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 close_circle(String fill, double width, double height) { + public static Node closeCircle(String 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 check_circle(String fill, double width, double height) { + public static Node checkCircle(String 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 info_circle(String fill, double width, double height) { + public static Node infoCircle(String 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 help_circle(String fill, double width, double height) { + public static Node helpCircle(String 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); } @@ -121,4 +121,8 @@ public final class SVG { return createSVGPath("M13,14H11V10H13M13,18H11V16H13M1,21H23L12,2L1,21Z", fill, width, height); } + public static Node plus(String fill, double width, double height) { + return createSVGPath("M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z", fill, width, height); + } + } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/AdvancedListBox.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/AdvancedListBox.java similarity index 97% rename from HMCL/src/main/java/org/jackhuang/hmcl/ui/AdvancedListBox.java rename to HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/AdvancedListBox.java index ca89dd02c..5c4d63420 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/AdvancedListBox.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/AdvancedListBox.java @@ -15,7 +15,7 @@ * 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; +package org.jackhuang.hmcl.ui.construct; import javafx.collections.ObservableList; import javafx.scene.Node; @@ -23,6 +23,7 @@ import javafx.scene.control.ScrollPane; import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; +import org.jackhuang.hmcl.ui.FXUtils; public class AdvancedListBox extends ScrollPane { private final VBox container = new VBox(); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/ClassTitle.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/ClassTitle.java similarity index 81% rename from HMCL/src/main/java/org/jackhuang/hmcl/ui/ClassTitle.java rename to HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/ClassTitle.java index 109732871..cbf39b02f 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/ClassTitle.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/ClassTitle.java @@ -15,8 +15,9 @@ * 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; +package org.jackhuang.hmcl.ui.construct; +import javafx.scene.Node; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; @@ -27,13 +28,17 @@ import javafx.scene.text.Text; * @author huangyuhui */ public class ClassTitle extends StackPane { - private final String text; + private final Node content; public ClassTitle(String text) { - this.text = text; + this(new Text(text)); + } + + public ClassTitle(Node content) { + this.content = content; VBox vbox = new VBox(); - vbox.getChildren().addAll(new Text(text)); + vbox.getChildren().addAll(content); Rectangle rectangle = new Rectangle(); rectangle.widthProperty().bind(vbox.widthProperty()); rectangle.setHeight(1.0); @@ -43,7 +48,7 @@ public class ClassTitle extends StackPane { getStyleClass().add("class-title"); } - public String getText() { - return text; + public Node getContent() { + return content; } } 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 b79357301..6421049b9 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 @@ -62,19 +62,19 @@ public final class MessageDialogPane extends StackPane { switch (type) { case MessageBox.INFORMATION_MESSAGE: - graphic.setGraphic(SVG.info_circle("black", 40, 40)); + graphic.setGraphic(SVG.infoCircle("black", 40, 40)); break; case MessageBox.ERROR_MESSAGE: - graphic.setGraphic(SVG.close_circle("black", 40, 40)); + graphic.setGraphic(SVG.closeCircle("black", 40, 40)); break; case MessageBox.FINE_MESSAGE: - graphic.setGraphic(SVG.check_circle("black", 40, 40)); + graphic.setGraphic(SVG.checkCircle("black", 40, 40)); break; case MessageBox.WARNING_MESSAGE: graphic.setGraphic(SVG.alert("black", 40, 40)); break; case MessageBox.QUESTION_MESSAGE: - graphic.setGraphic(SVG.help_circle("black", 40, 40)); + graphic.setGraphic(SVG.helpCircle("black", 40, 40)); break; } } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TaskListPane.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TaskListPane.java index 69246ba57..056f94344 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TaskListPane.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TaskListPane.java @@ -21,7 +21,6 @@ import com.jfoenix.controls.JFXProgressBar; import javafx.application.Platform; import javafx.scene.control.Label; import javafx.scene.layout.BorderPane; -import javafx.scene.layout.Region; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import org.jackhuang.hmcl.Main; @@ -36,15 +35,12 @@ import org.jackhuang.hmcl.mod.CurseCompletionTask; import org.jackhuang.hmcl.mod.CurseInstallTask; import org.jackhuang.hmcl.mod.MinecraftInstanceTask; import org.jackhuang.hmcl.mod.MultiMCModpackInstallTask; -import org.jackhuang.hmcl.task.FileDownloadTask; import org.jackhuang.hmcl.task.Task; import org.jackhuang.hmcl.task.TaskExecutor; import org.jackhuang.hmcl.task.TaskListener; -import org.jackhuang.hmcl.ui.AdvancedListBox; import java.util.HashMap; import java.util.Map; -import java.util.Optional; public final class TaskListPane extends StackPane { private final AdvancedListBox listBox = new AdvancedListBox(); diff --git a/HMCL/src/main/resources/assets/css/jfoenix-main-demo.css b/HMCL/src/main/resources/assets/css/jfoenix-main-demo.css index 51a7a50c7..ab0bec4fd 100644 --- a/HMCL/src/main/resources/assets/css/jfoenix-main-demo.css +++ b/HMCL/src/main/resources/assets/css/jfoenix-main-demo.css @@ -791,7 +791,31 @@ } .toggle-icon4 .jfx-rippler { - -jfx-rippler-fill: #0F9D58; + -jfx-rippler-fill: rgba(66.0, 133.0, 244.0, 0.29885056614875793); + -jfx-mask-type: CIRCLE; +} + +.toggle-icon-tiny { + -fx-toggle-icon-tiny-size: 15px; + -fx-pref-width: -fx-toggle-icon-tiny-size; + -fx-max-width: -fx-toggle-icon-tiny-size; + -fx-min-width: -fx-toggle-icon-tiny-size; + -fx-pref-height: -fx-toggle-icon-tiny-size; + -fx-max-height: -fx-toggle-icon-tiny-size; + -fx-min-height: -fx-toggle-icon-tiny-size; + -fx-background-radius: 25px; + -fx-background-color: transparent; + -jfx-toggle-color: rgba(128, 128, 255, 0.2); + -jfx-untoggle-color: transparent; +} + +.toggle-icon-tiny .icon { + -fx-fill: rgb(204.0, 204.0, 51.0); + -fx-padding: 5.0; +} + +.toggle-icon-tiny .jfx-rippler { + -jfx-rippler-fill: rgba(66.0, 133.0, 244.0, 0.29885056614875793); -jfx-mask-type: CIRCLE; } diff --git a/HMCL/src/main/resources/assets/fxml/decorator.fxml b/HMCL/src/main/resources/assets/fxml/decorator.fxml index 406d378c7..c5883149e 100644 --- a/HMCL/src/main/resources/assets/fxml/decorator.fxml +++ b/HMCL/src/main/resources/assets/fxml/decorator.fxml @@ -5,7 +5,7 @@ - + - - - - - - -