Skip to content

Commit

Permalink
Merge pull request #147 from dlsc-software-consulting-gmbh/enhancemen…
Browse files Browse the repository at this point in the history
…t-reuse-center-box

Reuse center box
  • Loading branch information
dlemmermann authored Apr 12, 2024
2 parents 87b88d5 + 74cb0d0 commit 2cfe747
Showing 1 changed file with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,26 +273,15 @@ public ContentPane() {
notification.getActions().addListener((Observable it) -> updateActions(actionsBox));
updateActions(actionsBox);

centerProperty().bind(Bindings.createObjectBinding(() -> {
VBox center = new VBox(titleTimeBox, descriptionLabel, actionsBox);
center.setFillWidth(true);
center.setAlignment(Pos.CENTER_LEFT);
center.getStyleClass().add("text-container");
center.setMinHeight(Region.USE_PREF_SIZE);

boolean contentIsExpanded = false;
if (isShowContent()) {
Node content = getContent();
if (content != null) {
VBox.setMargin(content, new Insets(5, 0, 0, 0));
center.getChildren().add(content);
contentIsExpanded = true;
}
}
NotificationView.this.pseudoClassStateChanged(PSEUDO_CLASS_EXPANDED, contentIsExpanded);
VBox center = new VBox(titleTimeBox, descriptionLabel, actionsBox);
center.setFillWidth(true);
center.setAlignment(Pos.CENTER_LEFT);
center.getStyleClass().add("text-container");
center.setMinHeight(Region.USE_PREF_SIZE);
setCenter(center);

return center;
}, contentProperty(), showContentProperty()));
contentProperty().addListener(it -> updateCenterNode(center));
showContentProperty().addListener(it -> updateCenterNode(center));

Label clearAllLabel = new Label("Clear All");
clearAllLabel.getStyleClass().add("clear-all");
Expand Down Expand Up @@ -349,6 +338,23 @@ public ContentPane() {
updateDateAndTimeLabel();
}

private void updateCenterNode(VBox center) {
Node content = getContent();
boolean contentIsExpanded = isShowContent() && content != null;
NotificationView.this.pseudoClassStateChanged(PSEUDO_CLASS_EXPANDED, contentIsExpanded);

if (contentIsExpanded) {
if (!center.getChildren().contains(content)) {
VBox.setMargin(content, new Insets(5, 0, 0, 0));
center.getChildren().add(content);
}
} else {
if (content != null) {
center.getChildren().remove(content);
}
}
}

private void updateStackStyle() {
closeIconWrapper.getStyleClass().remove("stack");
if (stackingEnabled.get() && !notification.getGroup().isExpanded() && notification.getGroup().getNotifications().size() > 1) {
Expand Down

0 comments on commit 2cfe747

Please sign in to comment.