rectFor
Parameters
- self:*FlexBoxWidget
- *FlexBoxWidget
- id:dvui.Id
- dvui.Id
- min_size:Size
- Size
- e:Options.Expand
- Options.Expand
- g:Options.Gravity
- Options.Gravity
Source
Implementation
pub fn rectFor(self: *FlexBoxWidget, id: dvui.Id, min_size: Size, e: Options.Expand, g: Options.Gravity) Rect {
_ = id;
_ = e;
_ = g;
var container_width = self.data().contentRect().w;
if (container_width == 0) {
// if we are not being shown at all, probably this is the first
// frame for us and we should calculate our min height assuming we
// get at least our min width
container_width = self.data().options.min_size_contentGet().w;
if (container_width == 0) {
// wasn't given a min width, assume something
container_width = 500;
}
}
if (self.insert_pt.x > 0 and self.insert_pt.x + min_size.w > container_width) {
// we ran off the end and didn't start at the left edge, break
self.insert_pt.x = 0;
self.insert_pt.y += self.row_size.h - self.init_options.border_collapse.y;
self.row_size = .{ .w = 0, .h = min_size.h };
self.row += 1;
self.col = 0;
} else {
self.row_size.h = @max(self.row_size.h, min_size.h);
}
var ret = Rect.fromPoint(self.insert_pt).toSize(min_size);
switch (self.init_options.justify_content) {
.start => {},
.center => ret.x += (self.data().contentRect().w - self.max_row_width_prev) / 2,
}
self.insert_pt.x += min_size.w - self.init_options.border_collapse.x;
return ret;
}