summaryrefslogtreecommitdiff
path: root/src/layout.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-23 02:00:00 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commitf6738c7edfff2249e0b13f2a76962f45d02c86bb (patch)
tree3f255da736fb0a6f4b926c72054d83091f941d21 /src/layout.zig
parent9695cb098c784792af79c22d46a17f7bc7247d33 (diff)
downloadpardes-f6738c7edfff2249e0b13f2a76962f45d02c86bb.tar.gz
pardes-f6738c7edfff2249e0b13f2a76962f45d02c86bb.zip
Center tagline bands, frame anchors evenly, fill to the window edge, and resize columns from their grip
Every tag band (workspace, column, pane) is centred in its row, so text sits at one baseline offset. Anchors are inset from the column rule by that same margin, so they are square and the band frames them on the left, top and bottom; the pane mark moves to stay centred. When the window is not a whole number of cells, the bands, rules, spines and scroll thumbs at the right and bottom edges run on through the leftover pixels. A column grip dropped short of another column's place now moves the column's left edge, with a dashed rail preview, sharing setColumnPairWidth with the border drag. A release still on the grip changes nothing, and a pair too narrow for two MINW columns is left alone. PARDES_TEST_PAD adds leftover pixels to a test-mode window and capture.
Diffstat (limited to 'src/layout.zig')
-rw-r--r--src/layout.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/layout.zig b/src/layout.zig
index c6cb7503..8db05a07 100644
--- a/src/layout.zig
+++ b/src/layout.zig
@@ -723,6 +723,23 @@ pub fn columnMoveTarget(p: *const Pardes, source: usize, x: u16) usize {
return insertion;
}
+/// Share out the width of columns `left` and `left + 1` so the left one is
+/// `left_width` cells, neither below MINW. A border drag and a column grip
+/// dropped inside its own place both end here.
+pub fn setColumnPairWidth(p: *Pardes, left: usize, left_width: u64) void {
+ if (left + 1 >= p.ncol) return;
+ const combined: u64 = p.col_w[left] + p.col_w[left + 1];
+ // Too narrow for both to keep MINW: any split would squeeze one away.
+ if (combined < 2 * @as(u64, config.MINW)) return;
+ const width = std.math.clamp(left_width, config.MINW, @max(@as(u64, config.MINW), combined -| config.MINW));
+ const pair = p.col_weight[left] + p.col_weight[left + 1];
+ if (pair <= 1 or combined == 0) return;
+ const numerator = @as(u128, pair) * width + combined / 2;
+ const share = std.math.clamp(@as(u64, @intCast(numerator / combined)), 1, pair - 1);
+ p.col_weight[left] = share;
+ p.col_weight[left + 1] = pair - share;
+}
+
pub fn reorderColumn(p: *Pardes, from: usize, to: usize) void {
if (from >= p.ncol or to >= p.ncol or from == to) return;
const ids = p.col_panes[from];