Hack to remove extra space in stacks
This commit is contained in:
parent
e46071227c
commit
bb807a86f3
@ -1,6 +1,7 @@
|
||||
const dim = @import("dimensions.zig");
|
||||
const term = @import("term.zig");
|
||||
const pane = @import("pane.zig");
|
||||
const log = @import("log.zig");
|
||||
const std = @import("std");
|
||||
|
||||
const Pane = pane.Pane;
|
||||
@ -126,6 +127,7 @@ pub const Stack = struct {
|
||||
var used: usize = 0;
|
||||
var available = height - total_absolute;
|
||||
const ratio = available / total_fill;
|
||||
var extra = available - (total_fill * ratio);
|
||||
|
||||
for (self.children) |child| {
|
||||
child.pane.dimensions.pos = .{
|
||||
@ -140,7 +142,8 @@ pub const Stack = struct {
|
||||
|
||||
switch (child.dimensions.height.type) {
|
||||
.Fill => {
|
||||
child.pane.dimensions.size.height = child.dimensions.height.value * ratio;
|
||||
child.pane.dimensions.size.height = (child.dimensions.height.value * ratio) + @min(child.dimensions.height.value, extra);
|
||||
extra -= @min(child.dimensions.width.value, extra);
|
||||
available -= child.pane.dimensions.size.height;
|
||||
},
|
||||
.Absolute => child.pane.dimensions.size.height = child.dimensions.height.value,
|
||||
@ -206,6 +209,7 @@ pub const Stack = struct {
|
||||
var used: usize = 0;
|
||||
var available = width - total_absolute;
|
||||
const ratio = available / total_fill;
|
||||
var extra = available - (total_fill * ratio);
|
||||
|
||||
for (self.children) |child| {
|
||||
child.pane.dimensions.pos = .{
|
||||
@ -220,7 +224,8 @@ pub const Stack = struct {
|
||||
|
||||
switch (child.dimensions.width.type) {
|
||||
.Fill => {
|
||||
child.pane.dimensions.size.width = child.dimensions.width.value * ratio;
|
||||
child.pane.dimensions.size.width = (child.dimensions.width.value * ratio) + @min(child.dimensions.width.value, extra);
|
||||
extra -= @min(child.dimensions.width.value, extra);
|
||||
available -= child.pane.dimensions.size.width;
|
||||
},
|
||||
.Absolute => child.pane.dimensions.size.width = child.dimensions.width.value,
|
||||
|
Loading…
Reference in New Issue
Block a user