更新启动按钮分隔符颜色 (#5087)

This commit is contained in:
neveler
2026-01-01 21:40:28 +08:00
committed by GitHub
parent fe0515ed28
commit 7c0faf2143
2 changed files with 33 additions and 34 deletions

View File

@@ -39,7 +39,6 @@ import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.TextFlow; import javafx.scene.text.TextFlow;
import javafx.util.Duration; import javafx.util.Duration;
import org.jackhuang.hmcl.Metadata; import org.jackhuang.hmcl.Metadata;
@@ -207,10 +206,8 @@ public final class MainPage extends StackPane implements DecoratorPage {
updatePane.getChildren().setAll(hBox, closeUpdateButton); updatePane.getChildren().setAll(hBox, closeUpdateButton);
} }
StackPane launchPane = new StackPane(); HBox launchPane = new HBox();
launchPane.getStyleClass().add("launch-pane"); launchPane.getStyleClass().add("launch-pane");
launchPane.setMaxWidth(230);
launchPane.setMaxHeight(55);
FXUtils.onScroll(launchPane, versions, list -> { FXUtils.onScroll(launchPane, versions, list -> {
String currentId = getCurrentGame(); String currentId = getCurrentGame();
return Lang.indexWhere(list, instance -> instance.getId().equals(currentId)); return Lang.indexWhere(list, instance -> instance.getId().equals(currentId));
@@ -219,16 +216,11 @@ public final class MainPage extends StackPane implements DecoratorPage {
StackPane.setAlignment(launchPane, Pos.BOTTOM_RIGHT); StackPane.setAlignment(launchPane, Pos.BOTTOM_RIGHT);
{ {
JFXButton launchButton = new JFXButton(); JFXButton launchButton = new JFXButton();
launchButton.setPrefWidth(230); launchButton.getStyleClass().add("launch-button");
launchButton.setPrefHeight(55);
//launchButton.setButtonType(JFXButton.ButtonType.RAISED);
launchButton.setDefaultButton(true); launchButton.setDefaultButton(true);
launchButton.setClip(new Rectangle(-100, -100, 310, 200));
{ {
VBox graphic = new VBox(); VBox graphic = new VBox();
graphic.setAlignment(Pos.CENTER); graphic.setAlignment(Pos.CENTER);
graphic.setTranslateX(-7);
graphic.setMaxWidth(200);
Label launchLabel = new Label(); Label launchLabel = new Label();
launchLabel.setStyle("-fx-font-size: 16px;"); launchLabel.setStyle("-fx-font-size: 16px;");
Label currentLabel = new Label(); Label currentLabel = new Label();
@@ -261,26 +253,11 @@ public final class MainPage extends StackPane implements DecoratorPage {
launchButton.setGraphic(graphic); launchButton.setGraphic(graphic);
} }
Rectangle separator = new Rectangle();
separator.setWidth(1);
separator.setHeight(57);
separator.setTranslateX(95);
separator.setMouseTransparent(true);
menuButton = new JFXButton(); menuButton = new JFXButton();
menuButton.setPrefHeight(55); menuButton.getStyleClass().add("menu-button");
menuButton.setPrefWidth(230);
//menuButton.setButtonType(JFXButton.ButtonType.RAISED);
menuButton.setStyle("-fx-font-size: 15px;");
menuButton.setOnAction(e -> onMenu()); menuButton.setOnAction(e -> onMenu());
menuButton.setClip(new Rectangle(211, -100, 100, 200));
StackPane graphic = new StackPane();
Node svg = SVG.ARROW_DROP_UP.createIcon(30);
StackPane.setAlignment(svg, Pos.CENTER_RIGHT);
graphic.getChildren().setAll(svg);
graphic.setTranslateX(6);
FXUtils.installFastTooltip(menuButton, i18n("version.switch")); FXUtils.installFastTooltip(menuButton, i18n("version.switch"));
menuButton.setGraphic(graphic); menuButton.setGraphic(SVG.ARROW_DROP_UP.createIcon(30));
EventHandler<MouseEvent> secondaryClickHandle = event -> { EventHandler<MouseEvent> secondaryClickHandle = event -> {
if (event.getButton() == MouseButton.SECONDARY && event.getClickCount() == 1) { if (event.getButton() == MouseButton.SECONDARY && event.getClickCount() == 1) {
@@ -291,7 +268,7 @@ public final class MainPage extends StackPane implements DecoratorPage {
launchButton.addEventHandler(MouseEvent.MOUSE_CLICKED, secondaryClickHandle); launchButton.addEventHandler(MouseEvent.MOUSE_CLICKED, secondaryClickHandle);
menuButton.addEventHandler(MouseEvent.MOUSE_CLICKED, secondaryClickHandle); menuButton.addEventHandler(MouseEvent.MOUSE_CLICKED, secondaryClickHandle);
launchPane.getChildren().setAll(launchButton, separator, menuButton); launchPane.getChildren().setAll(launchButton, menuButton);
} }
getChildren().addAll(updatePane, launchPane); getChildren().addAll(updatePane, launchPane);

View File

@@ -421,18 +421,44 @@
* * * *
******************************************************************************/ ******************************************************************************/
.launch-pane {
-fx-max-height: 57px;
-fx-min-height: 57px;
-fx-max-width: 230px;
-fx-min-width: 230px;
}
.launch-pane > .jfx-button { .launch-pane > .jfx-button {
-fx-translate-y: 1px;
-fx-max-height: 55px;
-fx-min-height: 55px;
-fx-background-color: -monet-primary-container; -fx-background-color: -monet-primary-container;
-fx-cursor: hand; -fx-cursor: hand;
} }
.launch-pane > .jfx-button.launch-button {
-fx-max-width: 207px;
-fx-min-width: 207px;
-fx-border-width: 0 3px 0 0;
-fx-border-color: -monet-on-surface-variant;
-fx-background-radius: 4px 0 0 4px;
}
.launch-pane > .jfx-button.menu-button {
-fx-max-width: 20px;
-fx-min-width: 20px;
-fx-font-size: 15px;
-fx-background-radius: 0 4px 4px 0;
}
.launch-pane > .jfx-button > StackPane > .jfx-rippler { .launch-pane > .jfx-button > StackPane > .jfx-rippler {
-jfx-rippler-fill: -monet-on-primary-container; -jfx-rippler-fill: -monet-on-primary-container;
-jfx-mask-type: CIRCLE; -jfx-mask-type: CIRCLE;
-fx-padding: 0.0; -fx-padding: 0;
} }
.launch-pane > .jfx-button, .jfx-button * { .launch-pane > .jfx-button,
.launch-pane > .jfx-button * {
-fx-text-fill: -monet-on-primary-container; -fx-text-fill: -monet-on-primary-container;
-fx-font-size: 14px; -fx-font-size: 14px;
} }
@@ -441,10 +467,6 @@
-fx-fill: -monet-on-primary-container; -fx-fill: -monet-on-primary-container;
} }
.launch-pane > Rectangle {
-fx-fill: -monet-primary-container;
}
/******************************************************************************* /*******************************************************************************
* * * *
* JFX Tab Pane * * JFX Tab Pane *