fix: change Parent layout notifying behaviour
this fixes issues that the size of parent doesn't change when children has size changed
@@ -91,12 +91,23 @@ public abstract class Parent extends Node {
}
}
Parent parent = parent().get();
- while (parent != null && parent.layoutState == LayoutState.CLEAN) {
- parent.layoutState = LayoutState.DIRTY_BRANCH;
- parent = parent.parent().get();
+ if(parent != null && parent.layoutState == LayoutState.CLEAN){
+ parent.needsLayout();
}
}
+ // Tell that this Parent does not need layouting anymore
+ public void revokeNeedsLayout(){
+ var flag = LayoutState.CLEAN;
+ for (Node child : children) {
+ if(child instanceof Parent && ((Parent) child).isNeedsLayout()){
+ flag = LayoutState.DIRTY_BRANCH;
+ break;
+ }
+ }
+ layoutState = flag;
+ }
+
public boolean isNeedsLayout() {
return layoutState == LayoutState.NEED_LAYOUT;
}
