这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions gemsfx/src/main/java/com/dlsc/gemsfx/skins/SelectionBoxSkin.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,10 @@ public void show(Node node) {

Node popupNode = getSkin().getNode();
if (popupNode instanceof Region region) {
region.setPrefWidth(bounds.getWidth());
region.setPrefWidth(Region.USE_COMPUTED_SIZE);
double popupNodeWidth = region.prefWidth(-1);
double prefWidth = Math.max(bounds.getWidth(), popupNodeWidth);
region.setPrefWidth(prefWidth);
}

if (owner.isAnimationEnabled()) {
Expand Down Expand Up @@ -435,6 +438,7 @@ private class SelectionPopupSkin implements Skin<SelectionPopup> {
private final SelectionPopup popup;
private final BorderPane contentPane;
private final VBox optionsBox;
private final ScrollPane scrollPane;

// Use indices as keys to handle duplicate items
private final Map<Integer, BooleanProperty> itemButtonProperties = new LinkedHashMap<>();
Expand All @@ -455,6 +459,7 @@ public String getUserAgentStylesheet() {
optionsBox = new VBox();
optionsBox.getStyleClass().add("options-box");
optionsBox.setFillWidth(true);
optionsBox.setMinWidth(Region.USE_PREF_SIZE);
optionsBox.managedProperty().bind(optionsBox.visibleProperty());
optionsBox.visibleProperty().bind(popup.getOwner().itemsProperty().emptyProperty().not());

Expand All @@ -463,9 +468,16 @@ public String getUserAgentStylesheet() {
contentPane.leftProperty().bind(control.leftProperty());
contentPane.rightProperty().bind(control.rightProperty());

ScrollPane scrollPane = new ScrollPane(optionsBox);
scrollPane = new ScrollPane(optionsBox);
scrollPane.getStyleClass().add("options-scroll-pane");
scrollPane.setFitToWidth(true);

optionsBox.widthProperty().addListener((obs, oldWidth, newWidth) -> {
if (scrollPane.getPrefViewportWidth() == 0.0) {
scrollPane.setPrefViewportWidth(newWidth.doubleValue());
}
});

contentPane.setCenter(scrollPane);

// Initialize the popup content
Expand All @@ -488,6 +500,7 @@ public String getUserAgentStylesheet() {
}

private void updatePopupContent() {
scrollPane.setPrefViewportWidth(0.0);
optionsBox.getChildren().clear();
itemButtonProperties.clear();

Expand Down
7 changes: 2 additions & 5 deletions gemsfx/src/main/resources/com/dlsc/gemsfx/selection-box.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
-fx-translate-y: 2px;
}

.selection-popup:above > .content {
}

.selection-popup > .content .extra-buttons-box {
-fx-border-width: 0 0 1px 0;
-fx-border-color: transparent transparent derive(-fx-background, -20%) transparent;
Expand All @@ -30,7 +27,7 @@
-fx-background-radius: 2px;
-fx-alignment: center-left;
-fx-text-fill: -fx-text-base-color;
-fx-padding: 4 0 4 26;
-fx-padding: 4 4 4 26;
-fx-background-color: -fx-control-inner-background;
}

Expand Down Expand Up @@ -64,7 +61,7 @@
.selection-popup > .content > .options-scroll-pane .options-box > .check-box {
-fx-label-padding: 0 0 0 4px;
-fx-text-fill: -fx-text-base-color;
-fx-padding: 4 0 4 5;
-fx-padding: 4px;
-fx-background-color: -fx-control-inner-background;
}

Expand Down