Skip to content

Commit

Permalink
collapsible frames should autosize when collapsed
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Dec 29, 2023
1 parent 5f43af6 commit bd646a9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions haxe/ui/containers/Frame.hx
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,22 @@ private class CollapsedBehaviour extends DataBehaviour {
collapseExpandIcon.swapClass("collapsed", "expanded");
border.swapClass("collapsed", "expanded");
contents.swapClass("collapsed", "expanded");
if (frame.percentHeight != null) {
builder.cachedPercentHeight = frame.percentHeight;
} else if (frame.height != null) {
builder.cachedHeight = frame.height;
}
frame.percentHeight = null;
frame.height = null;
} else {
collapseExpandIcon.swapClass("expanded", "collapsed");
border.swapClass("expanded", "collapsed");
contents.swapClass("expanded", "collapsed");
if (builder.cachedPercentHeight != null) {
frame.percentHeight = builder.cachedPercentHeight;
} else if (builder.cachedHeight != null) {
frame.height = builder.cachedHeight;
}
}
}
}
Expand All @@ -98,6 +110,9 @@ private class Builder extends CompositeBuilder {
private var _label:Label;
private var _header:Header;

public var cachedPercentHeight:Null<Float> = null;
public var cachedHeight:Null<Float> = null;

public function new(frame:Frame) {
super(frame);
_frame = frame;
Expand Down

0 comments on commit bd646a9

Please sign in to comment.