Add a separator to separate launch button and popup button

This commit is contained in:
huanghongxun 2018-09-19 10:46:14 +08:00
parent 61ab8a6769
commit 9c169fb560
3 changed files with 21 additions and 16 deletions

View File

@ -28,6 +28,7 @@ import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import org.jackhuang.hmcl.event.EventBus;
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
@ -61,6 +62,8 @@ public final class MainPage extends StackPane implements DecoratorPage {
private JFXButton btnMenu;
@FXML
private Label lblCurrentGame;
@FXML
private Rectangle separator;
private Profile profile;
{
@ -74,14 +77,14 @@ public final class MainPage extends StackPane implements DecoratorPage {
});
btnLaunch.setClip(new Rectangle(-100, -100, 280, 200));
btnMenu.setClip(new Rectangle(180, -100, 100, 200));
btnMenu.setClip(new Rectangle(181, -100, 100, 200));
menu.setMinWidth(200);
StackPane graphic = new StackPane();
Node svg = SVG.triangle(Theme.whiteFillBinding(), 10, 10);
StackPane.setAlignment(svg, Pos.CENTER_RIGHT);
graphic.getChildren().setAll(svg);
graphic.setTranslateX(11);
graphic.setTranslateX(12);
btnMenu.setGraphic(graphic);
Profiles.selectedVersionProperty().addListener((o, a, version) -> {
@ -113,7 +116,6 @@ public final class MainPage extends StackPane implements DecoratorPage {
.sorted((a, b) -> VersionNumber.COMPARATOR.compare(VersionNumber.asVersion(a.getId()), VersionNumber.asVersion(b.getId())))
.map(version -> new IconedMenuItem(null, version.getId(), () -> {
repository.getProfile().setSelectedVersion(version.getId());
Versions.launch(repository.getProfile(), version.getId());
popup.hide();
}))
.collect(Collectors.toList());

View File

@ -233,6 +233,7 @@ public class DecoratorSkin extends SkinBase<DecoratorControl> {
Rectangle separator = new Rectangle();
separator.visibleProperty().bind(refreshNavButton.visibleProperty());
separator.heightProperty().bind(navBar.heightProperty());
separator.setFill(Color.GRAY);
JFXButton btnMin = new JFXButton();
StackPane pane = new StackPane(minus);

View File

@ -4,21 +4,23 @@
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.Rectangle?>
<fx:root type="StackPane" pickOnBounds="false"
xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1">
<StackPane fx:id="main" style="-fx-padding: 25;">
<JFXButton prefWidth="200" prefHeight="50" buttonType="RAISED" styleClass="jfx-button-raised"
onMouseClicked="#launch" fx:id="btnLaunch"
StackPane.alignment="BOTTOM_RIGHT">
<graphic>
<VBox alignment="CENTER" translateX="-10" maxWidth="160">
<Label style="-fx-font-size: 15;" text="%version.launch" />
<Label style="-fx-font-size: 10px;" fx:id="lblCurrentGame" />
</VBox>
</graphic>
</JFXButton>
<JFXButton prefWidth="200" prefHeight="50" buttonType="RAISED" styleClass="jfx-button-raised"
style="-fx-font-size: 15;" onMouseClicked="#onMenu"
fx:id="btnMenu" StackPane.alignment="BOTTOM_RIGHT" />
<StackPane maxWidth="200" maxHeight="50" StackPane.alignment="BOTTOM_RIGHT">
<JFXButton prefWidth="200" prefHeight="50" buttonType="RAISED" styleClass="jfx-button-raised"
onMouseClicked="#launch" fx:id="btnLaunch">
<graphic>
<VBox alignment="CENTER" translateX="-7" maxWidth="160">
<Label style="-fx-font-size: 15;" text="%version.launch"/>
<Label style="-fx-font-size: 10px;" fx:id="lblCurrentGame"/>
</VBox>
</graphic>
</JFXButton>
<Rectangle fx:id="separator" translateX="80" height="52" fill="gray" width="1" mouseTransparent="true"/>
<JFXButton prefWidth="200" prefHeight="50" buttonType="RAISED" styleClass="jfx-button-raised"
style="-fx-font-size: 15;" onMouseClicked="#onMenu" fx:id="btnMenu" />
</StackPane>
</StackPane>
</fx:root>