Skip to content

Commit f6414ab

Browse files
committed
check if parents also needs to be resized on resize
1 parent 03e5e70 commit f6414ab

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/main/java/com/cleanroommc/modularui/widget/WidgetTree.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ public static void resize(IWidget parent) {
278278

279279
@ApiStatus.Internal
280280
public static void resizeInternal(IWidget parent, boolean onOpen) {
281-
// TODO check if widget has a parent which depends on its children
281+
// check if updating this widget's pos and size can potentially update its parents
282+
while (!(parent instanceof ModularPanel) && (parent.getParent() instanceof ILayoutWidget || parent.getParent().flex().dependsOnChildren())) {
283+
parent = parent.getParent();
284+
}
282285
// resize each widget and calculate their relative pos
283286
if (!resizeWidget(parent, true, onOpen) && !resizeWidget(parent, false, onOpen)) {
284287
throw new IllegalStateException("Failed to resize widgets");

src/main/java/com/cleanroommc/modularui/widget/sizer/Flex.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ public boolean dependsOnChildren(GuiAxis axis) {
311311
return axis.isHorizontal() ? xAxisDependsOnChildren() : yAxisDependsOnChildren();
312312
}
313313

314+
public boolean dependsOnChildren() {
315+
return xAxisDependsOnChildren() || yAxisDependsOnChildren();
316+
}
317+
314318
public boolean hasFixedSize() {
315319
return this.x.hasFixedSize() && this.y.hasFixedSize();
316320
}

0 commit comments

Comments
 (0)