getFirstFittedRatio
Calculates the split ratio to fit the first pane to the size of its children.
Must be called after all the children on showFirst have been called
and before showSecond is called
Parameters
- self:*PanedWidget
- *PanedWidget
- autofit:AutoFitOptions
- AutoFitOptions
Source
Implementation
pub fn getFirstFittedRatio(self: *PanedWidget, autofit: AutoFitOptions) f32 {
const content_size = switch (self.init_opts.direction) {
.horizontal => self.data().contentRect().w,
.vertical => self.data().contentRect().h,
};
// use the maximum possible handle margin to ensure we show all the content
const total_pane_size = content_size - self.handleSize() * 2;
const size_of_first = @max(autofit.min_size, switch (self.init_opts.direction) {
.horizontal => self.layout.min_size_children.w,
.vertical => self.layout.min_size_children.h,
});
return std.math.clamp(
size_of_first / @max(1, total_pane_size),
autofit.min_split,
autofit.max_split,
);
}