Skip to content

Commit 9339ccf

Browse files
committed
Decouple balanced top and left window paddings
1 parent 0d5ecc7 commit 9339ccf

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/renderer/size.zig

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ pub const Size = struct {
4444
self.grid(),
4545
self.cell,
4646
);
47+
48+
// The top/bottom padding is interesting. Subjectively, lots of padding
49+
// at the top looks bad. So instead of always being equal (like left/right),
50+
// we force the top padding to be at most equal to the maximum left padding,
51+
// which is the balanced explicit horizontal padding plus half a cell width.
52+
const max_padding_left = (explicit.left + explicit.right + self.cell.width) / 2;
53+
const vshift = self.padding.top -| max_padding_left;
54+
self.padding.top -= vshift;
55+
self.padding.bottom += vshift;
4756
}
4857
};
4958

@@ -258,16 +267,12 @@ pub const Padding = struct {
258267
const space_right = @as(f32, @floatFromInt(screen.width)) - grid_width;
259268
const space_bot = @as(f32, @floatFromInt(screen.height)) - grid_height;
260269

261-
// The left/right padding is just an equal split.
270+
// The padding is split equally along both axes.
262271
const padding_right = @floor(space_right / 2);
263272
const padding_left = padding_right;
264273

265-
// The top/bottom padding is interesting. Subjectively, lots of padding
266-
// at the top looks bad. So instead of always being equal (like left/right),
267-
// we force the top padding to be at most equal to the left, and the bottom
268-
// padding is the difference thereafter.
269-
const padding_top = @min(padding_left, @floor(space_bot / 2));
270-
const padding_bot = space_bot - padding_top;
274+
const padding_bot = @floor(space_bot / 2);
275+
const padding_top = padding_bot;
271276

272277
const zero = @as(f32, 0);
273278
return .{

0 commit comments

Comments
 (0)