优化 ScrollBar 样式 by CiiLu · Pull Request #5784 · HMCL-dev/HMCL

if (scrollBar.getOrientation() == Orientation.HORIZONTAL) {
thumb.relocate(0, -8);
thumb.widthProperty().bind(Bindings.max(20, scrollBar.visibleAmountProperty().divide(range).multiply(scrollBar.widthProperty())));
thumb.setHeight(8);
thumb.xProperty().bind(Bindings.subtract(scrollBar.widthProperty(), thumb.widthProperty()).multiply(position));
thumb.relocate(0, -4.5);
thumb.setHeight(4.5);

NumberBinding trackWidth = Bindings.subtract(scrollBar.widthProperty(), offset * 2);
thumb.widthProperty().bind(Bindings.max(20, scrollBar.visibleAmountProperty().divide(range).multiply(trackWidth)));
thumb.xProperty().bind(
Bindings.add(offset,
Bindings.subtract(trackWidth, thumb.widthProperty()).multiply(position))
);
} else {
thumb.relocate(-8, 0);
thumb.setWidth(8);
thumb.heightProperty().bind(Bindings.max(20, scrollBar.visibleAmountProperty().divide(range).multiply(scrollBar.heightProperty())));
thumb.yProperty().bind(Bindings.subtract(scrollBar.heightProperty(), thumb.heightProperty()).multiply(position));
thumb.relocate(-4.5, 0);
thumb.setWidth(4.5);

NumberBinding trackHeight = Bindings.subtract(scrollBar.heightProperty(), offset * 2);
thumb.heightProperty().bind(Bindings.max(20, scrollBar.visibleAmountProperty().divide(range).multiply(trackHeight)));
thumb.yProperty().bind(
Bindings.add(offset,
Bindings.subtract(trackHeight, thumb.heightProperty()).multiply(position))
);
}