summaryrefslogtreecommitdiff
path: root/gui/src/Geometry.zig
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src/Geometry.zig')
-rw-r--r--gui/src/Geometry.zig7
1 files changed, 6 insertions, 1 deletions
diff --git a/gui/src/Geometry.zig b/gui/src/Geometry.zig
index 3ebdf4e..0fa2aee 100644
--- a/gui/src/Geometry.zig
+++ b/gui/src/Geometry.zig
@@ -2,6 +2,7 @@
const std = @import("std");
const Rect = @import("sketch").Rect;
const Geometry = @This();
+pub const toolbar_count = 17;
w: f32,
h: f32,
content: f32,
@@ -15,7 +16,7 @@ pub fn init(w: f32, h: f32, scroll: f32) Geometry {
const gap: f32 = 16;
const room = @max(240, w - 2 * margin);
const columns: usize = @intFromFloat(@max(1, @floor((w - 48) / 42)));
- const top: f32 = 78 + @as(f32, @floatFromInt((16 + columns - 1) / columns)) * 34;
+ const top: f32 = 78 + @as(f32, @floatFromInt((toolbar_count + columns - 1) / columns)) * 34;
const tall = @max(320, (h - top - 64) * 0.64);
const bottom = @max(240, h - top - tall - gap - 48);
var code: Rect = .{ .x = margin, .y = top, .w = room, .h = tall };
@@ -45,6 +46,10 @@ pub fn seam(r: Rect) f32 {
return @min(536, r.w * 0.34);
}
+pub fn scaled(r: Rect, scale: f32) Rect {
+ return .{ .x = r.x * scale, .y = r.y * scale, .w = r.w * scale, .h = r.h * scale };
+}
+
test "wide panes sit beside each other; narrow panes stack without overlap at every font scale" {
for ([_][2]f32{ .{ 2240, 1260 }, .{ 1440, 900 }, .{ 800, 700 } }) |size| {
for ([_]f32{ 0.6, 1, 2 }) |scale| {