diff options
| author | user <user@clank> | 2026-08-16 00:38:17 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-16 00:38:17 +0200 |
| commit | 8079f982bb240d6594b060caee7a5ac6f89e39b3 (patch) | |
| tree | e316fd3504360d1123774eb3a1a35459ef5ce725 /src/app.c | |
| parent | sl0ppty: sl0ppty --check (diff) | |
| download | slosh-8079f982bb240d6594b060caee7a5ac6f89e39b3.tar.gz slosh-8079f982bb240d6594b060caee7a5ac6f89e39b3.tar.xz slosh-8079f982bb240d6594b060caee7a5ac6f89e39b3.zip | |
sl0ppty: padding, per side
padding 1 // every side
padding 0 2 // vertical, horizontal
padding 2 0 0 1 // top, right, bottom, left
One value, two, or four in CSS order, because that is the order anybody
who has written a stylesheet already knows. `pad` becomes four fields and
the content rect is deflated per side rather than symmetrically, which is
the only real change: everything downstream already worked off
`n->content`.
The units do not change with how many numbers you write. They are ROWS,
like `gap`, and a horizontal one is multiplied by `gap_aspect` on the way
out -- so `padding 1`, `padding 1 1` and `padding 1 1 1 1` are one padding
rather than three, and a ring that looks square is still one number rather
than an arithmetic problem. Anyone who wants plain cells sets
`gap_aspect 1` and gets them everywhere, which is what that knob is for.
Three values is refused with a line saying what it wanted. CSS reads it as
top/horizontal/bottom, and a line whose meaning you have to look up is a
line nobody can read -- and `sl0ppty --check` now has something to say
about it, which is the difference between refusing and ignoring.
The dump writes the shortest form that means what is in force, so `padding
0` stays `padding 0` and a dump of a dump is still the same dump.
Checked by measuring both rects: a pane's insets from its own frame, four
numbers, for every form -- including that `gap_aspect 1` turns the
horizontal ones into cells, and that a refused padding leaves the rest of
the file applied.
Diffstat (limited to 'src/app.c')
| -rw-r--r-- | src/app.c | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -1144,15 +1144,21 @@ static void layout_node(node_t *n, rect_t r, layout_ctx_t *ctx) { n->collapsed = false; if (n->kind == NODE_LEAF) n->hidden = false; if (n->kind == NODE_LEAF) { - /* content is the frame deflated by its border and padding; a rect too - * small for a frame gets none, and the pane takes the whole thing. */ - uint16_t bx = r.w >= 3 && r.h >= 3 ? 1 + CFG.pad * CFG.gap_aspect : 0; - uint16_t by = r.w >= 3 && r.h >= 3 ? 1 + CFG.pad : 0; + /* content is the frame deflated by its border and its padding, per side; a + * rect too small for a frame gets neither, and the pane takes the whole + * thing. Horizontal padding is aspect-corrected, like the gap: the config's + * numbers are rows, so a square-looking ring is one number rather than an + * arithmetic problem. */ + bool framed = r.w >= 3 && r.h >= 3; + uint16_t left = framed ? 1 + CFG.pad_left * CFG.gap_aspect : 0; + uint16_t right = framed ? 1 + CFG.pad_right * CFG.gap_aspect : 0; + uint16_t top = framed ? 1 + CFG.pad_top : 0; + uint16_t bottom = framed ? 1 + CFG.pad_bottom : 0; n->content = (rect_t){ - .x = (uint16_t)(r.x + bx), - .y = (uint16_t)(r.y + by), - .w = (uint16_t)(r.w > 2 * bx ? r.w - 2 * bx : 1), - .h = (uint16_t)(r.h > 2 * by ? r.h - 2 * by : 1), + .x = (uint16_t)(r.x + left), + .y = (uint16_t)(r.y + top), + .w = (uint16_t)(r.w > left + right ? r.w - left - right : 1), + .h = (uint16_t)(r.h > top + bottom ? r.h - top - bottom : 1), }; if (ctx->apply && !n->hidden) pane_resize(n->pane, n->content.w, n->content.h); |
