Satisfy requirements metioned in #469

This commit is contained in:
huanghongxun 2018-10-11 22:06:34 +08:00
parent 2dc956b357
commit 0e5250dfb3
2 changed files with 21 additions and 1 deletions

View File

@ -96,7 +96,8 @@ public final class MainPage extends StackPane implements DecoratorPage {
btnLaunch.setClip(new Rectangle(-100, -100, 310, 200));
btnMenu.setClip(new Rectangle(211, -100, 100, 200));
menu.setMaxHeight(365);
menu.setMinWidth(545);
menu.setMaxWidth(545);
menu.setAlwaysShowingVBar(true);
updatePane.visibleProperty().bind(UpdateChecker.outdatedProperty());
closeUpdateButton.setGraphic(SVG.close(Theme.whiteFillBinding(), 10, 10));

View File

@ -18,6 +18,9 @@
package org.jackhuang.hmcl.ui.construct;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.When;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Node;
@ -31,6 +34,7 @@ import org.jackhuang.hmcl.ui.FXUtils;
public class PopupMenu extends Control {
private final ObservableList<Node> content = FXCollections.observableArrayList();
private final BooleanProperty alwaysShowingVBar = new SimpleBooleanProperty();
public PopupMenu() {
}
@ -39,6 +43,18 @@ public class PopupMenu extends Control {
return content;
}
public boolean isAlwaysShowingVBar() {
return alwaysShowingVBar.get();
}
public BooleanProperty alwaysShowingVBarProperty() {
return alwaysShowingVBar;
}
public void setAlwaysShowingVBar(boolean alwaysShowingVBar) {
this.alwaysShowingVBar.set(alwaysShowingVBar);
}
@Override
protected Skin<?> createDefaultSkin() {
return new PopupMenuSkin();
@ -52,6 +68,9 @@ public class PopupMenu extends Control {
ScrollPane scrollPane = new ScrollPane();
scrollPane.setFitToHeight(true);
scrollPane.setFitToWidth(true);
scrollPane.vbarPolicyProperty().bind(new When(alwaysShowingVBar)
.then(ScrollPane.ScrollBarPolicy.ALWAYS)
.otherwise(ScrollPane.ScrollBarPolicy.AS_NEEDED));
VBox content = new VBox();
content.getStyleClass().add("menu");