mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-24 03:33:46 -04:00
优化 AdvancedListBox 滚动条显示逻辑
This commit is contained in:
parent
cf72cc3274
commit
8b4ff578a2
@ -31,6 +31,7 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
public class AdvancedListBox extends ScrollPane {
|
public class AdvancedListBox extends ScrollPane {
|
||||||
private final VBox container = new VBox();
|
private final VBox container = new VBox();
|
||||||
|
private ScrollBarPolicy lastVbarPolicy = null;
|
||||||
|
|
||||||
{
|
{
|
||||||
setContent(container);
|
setContent(container);
|
||||||
@ -40,7 +41,6 @@ public class AdvancedListBox extends ScrollPane {
|
|||||||
setFitToHeight(true);
|
setFitToHeight(true);
|
||||||
setFitToWidth(true);
|
setFitToWidth(true);
|
||||||
setHbarPolicy(ScrollBarPolicy.NEVER);
|
setHbarPolicy(ScrollBarPolicy.NEVER);
|
||||||
setVbarPolicy(ScrollBarPolicy.NEVER);
|
|
||||||
|
|
||||||
container.getStyleClass().add("advanced-list-box-content");
|
container.getStyleClass().add("advanced-list-box-content");
|
||||||
|
|
||||||
@ -50,10 +50,16 @@ public class AdvancedListBox extends ScrollPane {
|
|||||||
@Override
|
@Override
|
||||||
protected void layoutChildren() {
|
protected void layoutChildren() {
|
||||||
super.layoutChildren();
|
super.layoutChildren();
|
||||||
|
ScrollBarPolicy newPolicy;
|
||||||
if (container.getHeight() > getHeight()) {
|
if (container.getHeight() > getHeight()) {
|
||||||
setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
|
newPolicy = ScrollBarPolicy.AS_NEEDED;
|
||||||
} else {
|
} else {
|
||||||
setVbarPolicy(ScrollBarPolicy.NEVER);
|
newPolicy = ScrollBarPolicy.NEVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastVbarPolicy == null || newPolicy != lastVbarPolicy) {
|
||||||
|
setVbarPolicy(newPolicy);
|
||||||
|
lastVbarPolicy = newPolicy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user