Skip to content

Commit 7c0faf2

Browse files
authored
更新启动按钮分隔符颜色 (#5087)
1 parent fe0515e commit 7c0faf2

File tree

2 files changed

+33
-34
lines changed

2 files changed

+33
-34
lines changed

HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import javafx.scene.layout.HBox;
4040
import javafx.scene.layout.StackPane;
4141
import javafx.scene.layout.VBox;
42-
import javafx.scene.shape.Rectangle;
4342
import javafx.scene.text.TextFlow;
4443
import javafx.util.Duration;
4544
import org.jackhuang.hmcl.Metadata;
@@ -207,10 +206,8 @@ public final class MainPage extends StackPane implements DecoratorPage {
207206
updatePane.getChildren().setAll(hBox, closeUpdateButton);
208207
}
209208

210-
StackPane launchPane = new StackPane();
209+
HBox launchPane = new HBox();
211210
launchPane.getStyleClass().add("launch-pane");
212-
launchPane.setMaxWidth(230);
213-
launchPane.setMaxHeight(55);
214211
FXUtils.onScroll(launchPane, versions, list -> {
215212
String currentId = getCurrentGame();
216213
return Lang.indexWhere(list, instance -> instance.getId().equals(currentId));
@@ -219,16 +216,11 @@ public final class MainPage extends StackPane implements DecoratorPage {
219216
StackPane.setAlignment(launchPane, Pos.BOTTOM_RIGHT);
220217
{
221218
JFXButton launchButton = new JFXButton();
222-
launchButton.setPrefWidth(230);
223-
launchButton.setPrefHeight(55);
224-
//launchButton.setButtonType(JFXButton.ButtonType.RAISED);
219+
launchButton.getStyleClass().add("launch-button");
225220
launchButton.setDefaultButton(true);
226-
launchButton.setClip(new Rectangle(-100, -100, 310, 200));
227221
{
228222
VBox graphic = new VBox();
229223
graphic.setAlignment(Pos.CENTER);
230-
graphic.setTranslateX(-7);
231-
graphic.setMaxWidth(200);
232224
Label launchLabel = new Label();
233225
launchLabel.setStyle("-fx-font-size: 16px;");
234226
Label currentLabel = new Label();
@@ -261,26 +253,11 @@ public void accept(String currentGame) {
261253
launchButton.setGraphic(graphic);
262254
}
263255

264-
Rectangle separator = new Rectangle();
265-
separator.setWidth(1);
266-
separator.setHeight(57);
267-
separator.setTranslateX(95);
268-
separator.setMouseTransparent(true);
269-
270256
menuButton = new JFXButton();
271-
menuButton.setPrefHeight(55);
272-
menuButton.setPrefWidth(230);
273-
//menuButton.setButtonType(JFXButton.ButtonType.RAISED);
274-
menuButton.setStyle("-fx-font-size: 15px;");
257+
menuButton.getStyleClass().add("menu-button");
275258
menuButton.setOnAction(e -> onMenu());
276-
menuButton.setClip(new Rectangle(211, -100, 100, 200));
277-
StackPane graphic = new StackPane();
278-
Node svg = SVG.ARROW_DROP_UP.createIcon(30);
279-
StackPane.setAlignment(svg, Pos.CENTER_RIGHT);
280-
graphic.getChildren().setAll(svg);
281-
graphic.setTranslateX(6);
282259
FXUtils.installFastTooltip(menuButton, i18n("version.switch"));
283-
menuButton.setGraphic(graphic);
260+
menuButton.setGraphic(SVG.ARROW_DROP_UP.createIcon(30));
284261

285262
EventHandler<MouseEvent> secondaryClickHandle = event -> {
286263
if (event.getButton() == MouseButton.SECONDARY && event.getClickCount() == 1) {
@@ -291,7 +268,7 @@ public void accept(String currentGame) {
291268
launchButton.addEventHandler(MouseEvent.MOUSE_CLICKED, secondaryClickHandle);
292269
menuButton.addEventHandler(MouseEvent.MOUSE_CLICKED, secondaryClickHandle);
293270

294-
launchPane.getChildren().setAll(launchButton, separator, menuButton);
271+
launchPane.getChildren().setAll(launchButton, menuButton);
295272
}
296273

297274
getChildren().addAll(updatePane, launchPane);

HMCL/src/main/resources/assets/css/root.css

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,18 +421,44 @@
421421
* *
422422
******************************************************************************/
423423

424+
.launch-pane {
425+
-fx-max-height: 57px;
426+
-fx-min-height: 57px;
427+
-fx-max-width: 230px;
428+
-fx-min-width: 230px;
429+
}
430+
424431
.launch-pane > .jfx-button {
432+
-fx-translate-y: 1px;
433+
-fx-max-height: 55px;
434+
-fx-min-height: 55px;
425435
-fx-background-color: -monet-primary-container;
426436
-fx-cursor: hand;
427437
}
428438

439+
.launch-pane > .jfx-button.launch-button {
440+
-fx-max-width: 207px;
441+
-fx-min-width: 207px;
442+
-fx-border-width: 0 3px 0 0;
443+
-fx-border-color: -monet-on-surface-variant;
444+
-fx-background-radius: 4px 0 0 4px;
445+
}
446+
447+
.launch-pane > .jfx-button.menu-button {
448+
-fx-max-width: 20px;
449+
-fx-min-width: 20px;
450+
-fx-font-size: 15px;
451+
-fx-background-radius: 0 4px 4px 0;
452+
}
453+
429454
.launch-pane > .jfx-button > StackPane > .jfx-rippler {
430455
-jfx-rippler-fill: -monet-on-primary-container;
431456
-jfx-mask-type: CIRCLE;
432-
-fx-padding: 0.0;
457+
-fx-padding: 0;
433458
}
434459

435-
.launch-pane > .jfx-button, .jfx-button * {
460+
.launch-pane > .jfx-button,
461+
.launch-pane > .jfx-button * {
436462
-fx-text-fill: -monet-on-primary-container;
437463
-fx-font-size: 14px;
438464
}
@@ -441,10 +467,6 @@
441467
-fx-fill: -monet-on-primary-container;
442468
}
443469

444-
.launch-pane > Rectangle {
445-
-fx-fill: -monet-primary-container;
446-
}
447-
448470
/*******************************************************************************
449471
* *
450472
* JFX Tab Pane *

0 commit comments

Comments
 (0)