Skip to content

Commit a83e3cd

Browse files
committed
Use preferred size as minimum size for dialogs and popups
1 parent ebf450b commit a83e3cd

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

tabshell-core/src/main/java/com/techsenger/tabshell/core/dialog/AbstractDialogFxView.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import javafx.scene.layout.HBox;
5656
import javafx.scene.layout.Pane;
5757
import javafx.scene.layout.Priority;
58+
import javafx.scene.layout.Region;
5859
import javafx.scene.layout.VBox;
5960

6061
/**
@@ -296,6 +297,7 @@ protected void build() {
296297
super.getNode().getStyleClass().addAll("wrapper", StyleClasses.CORNERS_BOTTOM);
297298
VBox.setVgrow(super.getNode(), Priority.ALWAYS);
298299
this.dialogBox.getStyleClass().addAll("dialog-box", StyleClasses.CORNERS_ALL, StyleClasses.SHADOW);
300+
dialogBox.setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
299301
this.resizer = new RegionResizer(minWidth, minHeight, maxWidth, maxHeight,
300302
(e) -> {
301303
var event = new DialogResizeEvent(DialogResizeEvent.DIALOG_RESIZE_STARTED, e);

tabshell-core/src/main/java/com/techsenger/tabshell/core/dialog/AbstractDialogPresenter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public boolean isActive() {
111111
return active;
112112
}
113113

114+
@Override
114115
public void setActive(boolean active) {
115116
this.active = active;
116117
getView().setActive(active);
@@ -121,6 +122,7 @@ public double getMinWidth() {
121122
return minWidth;
122123
}
123124

125+
@Override
124126
public void setMinWidth(double minWidth) {
125127
this.minWidth = minWidth;
126128
getView().setMinWidth(minWidth);
@@ -131,6 +133,7 @@ public double getMinHeight() {
131133
return minHeight;
132134
}
133135

136+
@Override
134137
public void setMinHeight(double minHeight) {
135138
this.minHeight = minHeight;
136139
getView().setMinHeight(minHeight);
@@ -141,6 +144,7 @@ public double getMaxWidth() {
141144
return maxWidth;
142145
}
143146

147+
@Override
144148
public void setMaxWidth(double maxWidth) {
145149
this.maxWidth = maxWidth;
146150
getView().setMaxWidth(maxWidth);
@@ -151,6 +155,7 @@ public double getMaxHeight() {
151155
return maxHeight;
152156
}
153157

158+
@Override
154159
public void setMaxHeight(double maxHeight) {
155160
this.maxHeight = maxHeight;
156161
getView().setMaxHeight(maxHeight);
@@ -161,6 +166,7 @@ public boolean isOutOfBoundsAllowed() {
161166
return outOfBoundsAllowed;
162167
}
163168

169+
@Override
164170
public void setOutOfBoundsAllowed(boolean outOfBoundsAllowed) {
165171
this.outOfBoundsAllowed = outOfBoundsAllowed;
166172
getView().setOutOfBoundsAllowed(outOfBoundsAllowed);
@@ -171,6 +177,7 @@ public boolean isResizable() {
171177
return resizable;
172178
}
173179

180+
@Override
174181
public void setResizable(boolean resizable) {
175182
this.resizable = resizable;
176183
getView().setResizable(resizable);

tabshell-core/src/main/java/com/techsenger/tabshell/core/dialog/WriteOnlyDialog.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ public interface WriteOnlyDialog {
6363
*/
6464
void setMaxHeight(double value);
6565

66+
/**
67+
* Sets the pref width of the dialog. This is optional — by default, {@code dialogBox} and {@code contentBox}
68+
* have {@code minSize} set to {@link Region#USE_PREF_SIZE}, so the dialog will size itself based on its content
69+
* automatically.
70+
*
71+
* @param value the pref width in pixels
72+
*/
73+
void setPrefWidth(double value);
74+
75+
/**
76+
* Sets the pref height of the dialog. This is optional — by default, {@code dialogBox} and {@code contentBox}
77+
* have {@code minSize} set to {@link Region#USE_PREF_SIZE}, so the dialog will size itself based on its content
78+
* automatically.
79+
*
80+
* @param value the pref height in pixels
81+
*/
82+
void setPrefHeight(double value);
83+
6684
/**
6785
* Enables or disables the ability to move the dialog outside the bounds of its parent container.
6886
* <p>

tabshell-core/src/main/java/com/techsenger/tabshell/core/popup/AbstractPopupFxView.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import javafx.scene.Cursor;
2424
import javafx.scene.layout.Pane;
2525
import javafx.scene.layout.Priority;
26+
import javafx.scene.layout.Region;
2627
import javafx.scene.layout.StackPane;
2728
import javafx.scene.layout.VBox;
2829

@@ -104,6 +105,7 @@ protected void build() {
104105
waitingPane.setMouseTransparent(false);
105106
waitingPane.setCursor(Cursor.WAIT);
106107

108+
contentBox.setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
107109
VBox.setVgrow(contentBox, Priority.ALWAYS);
108110
VBox.setVgrow(stackPane, Priority.ALWAYS);
109111
}

0 commit comments

Comments
 (0)