minSizeSetAndRefresh
Parameters
- self:*WidgetData
- *WidgetData
Source
Implementation
pub fn minSizeSetAndRefresh(self: *WidgetData) void {
self.min_size = self.min_size.min(self.options.max_sizeGet());
if (dvui.minSizeGet(self.id)) |ms| {
// If the size we got was exactly our previous min size then our min size
// was a binding constraint. So if our min size changed it might cause
// layout changes.
// If this was like a Label where we knew the min size before getting our
// rect, then either our min size is the same as previous, or our rect is
// a different size than our previous min size.
if ((self.rect.w == ms.w and ms.w != self.min_size.w) or
(self.rect.h == ms.h and ms.h != self.min_size.h))
{
//std.debug.print("{x} minSizeSetAndRefresh {} {} {}\n", .{ self.id, self.rect, ms, self.min_size });
dvui.refresh(null, @src(), self.id);
}
} else {
// This is the first frame for this widget. Almost always need a
// second frame to appear correctly since nobody knew our min size the
// first frame.
dvui.refresh(null, @src(), self.id);
}
var cw = dvui.currentWindow();
cw.min_sizes.put(cw.gpa, self.id, self.min_size) catch |err| {
// returning an error here means that all widgets deinit can return
// it, which is very annoying because you can't "defer try
// widget.deinit()". Also if we are having memory issues then we
// have larger problems than here.
dvui.log.err("minSizeSetAndRefresh got {any} when trying to set min size of widget {x}\n", .{ err, self.id });
};
}