diff options
| author | user <user@clank> | 2026-08-14 13:59:05 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-14 13:59:05 +0200 |
| commit | 4bb2bb5f05dda628722ae363fa4580aa69f37e7c (patch) | |
| tree | 4c06be8b88295a266405a9ec28e67993e4936fae /src | |
| parent | sl0ppty: drag greys the other panes, and dim_unfocused (diff) | |
| download | slosh-4bb2bb5f05dda628722ae363fa4580aa69f37e7c.tar.gz slosh-4bb2bb5f05dda628722ae363fa4580aa69f37e7c.tar.xz slosh-4bb2bb5f05dda628722ae363fa4580aa69f37e7c.zip | |
sl0ppty: dashed borders and a deeper push-back while dragging
Two changes to the same moment, on opposite sides of the chrome boundary.
Every pane that is not being dragged now draws a dashed border, because every
one of them is somewhere the pane could be dropped and a dashed frame says so
without needing a legend. The pane in your hand keeps a solid one, so the two
states are distinguishable by shape and not only by colour — which matters on
a terminal whose palette makes the greying subtle, and to anyone who would not
see the greying at all. The pane actually under the pointer still takes the
existing drop-target highlight on top of the dashes: these are all targets,
that one is the one you are on.
Borders are chrome, so this is not a shader and could not have been. It lives
in draw_frame, keyed off the same drag.moved that gates the greying, so a press
that turns out to be a click neither greys nor dashes anything.
The greying itself gets a second pass: desaturated *and* darkened, rather than
only desaturated. Grey alone still competes for attention at the same
brightness, which is what made the dragged pane fail to pop. Two shaders
instead of one that does both, because "colourless" and "recessed" are
different things to want and want separate knobs — drag_grayscale 200 and
drag_dim 140. This is the first thing to actually use the chain, and it is
what the chain was for.
The knob that used to mean "off" no longer does, and the test that asserted it
caught that immediately: drag_grayscale 0 now leaves drag_dim still dimming.
Rather than couple them, the test became three — both off, each alone — which
is better coverage of a two-knob effect than the single case was of a one-knob
one.
Diffstat (limited to 'src')
| -rw-r--r-- | src/app.c | 57 | ||||
| -rw-r--r-- | src/config.c | 3 | ||||
| -rw-r--r-- | src/config.h | 1 |
3 files changed, 44 insertions, 17 deletions
@@ -1278,6 +1278,18 @@ static void draw_frame(app_t *a, screen_t *s, node_t *leaf) { color_t fg = drop_target ? BTN_BG : (focused ? FRAME_FOCUS : FRAME_IDLE); uint16_t attrs = drop_target ? ATTR_BOLD : 0; + /* While a pane is being dragged, every other pane is somewhere it could be + * dropped, and a dashed border says so without needing a legend. The pane in + * your hand keeps a solid one, so the two states are told apart by the frame + * as well as by the colour — which matters on a terminal whose palette makes + * the greying subtle. The pane actually under the pointer still takes the + * drop_target highlight on top of the dashes: these are all targets, that is + * the one you are on. */ + bool drag_target = + a->drag.kind == DRAG_TITLE && a->drag.moved && a->drag.src != leaf->id; + const char *hbar = drag_target ? "\u2504" : "\u2500"; + const char *vbar = drag_target ? "\u2506" : "\u2502"; + const char *tl = CFG.rounded ? "╭" : "┌", *tr = CFG.rounded ? "╮" : "┐"; const char *bl = CFG.rounded ? "╰" : "└", *br = CFG.rounded ? "╯" : "┘"; @@ -1287,12 +1299,12 @@ static void draw_frame(app_t *a, screen_t *s, node_t *leaf) { screen_text(s, r.x, y1, bl, fg, NO_COLOR, attrs); screen_text(s, x1, y1, br, fg, NO_COLOR, attrs); for (uint16_t x = (uint16_t)(r.x + 1); x < x1; x++) { - screen_text(s, x, r.y, "─", fg, NO_COLOR, attrs); - screen_text(s, x, y1, "─", fg, NO_COLOR, attrs); + screen_text(s, x, r.y, hbar, fg, NO_COLOR, attrs); + screen_text(s, x, y1, hbar, fg, NO_COLOR, attrs); } for (uint16_t y = (uint16_t)(r.y + 1); y < y1; y++) { - screen_text(s, r.x, y, "│", fg, NO_COLOR, attrs); - screen_text(s, x1, y, "│", fg, NO_COLOR, attrs); + screen_text(s, r.x, y, vbar, fg, NO_COLOR, attrs); + screen_text(s, x1, y, vbar, fg, NO_COLOR, attrs); } /* The frame's top row is the drag handle. Registered before the split @@ -1456,34 +1468,45 @@ size_t app_shade_count(app_t *a, uint32_t pane_id) { * that forgot to clear it is a bug that only shows up in front of someone. * The rect and the collapsed flag are recomputed every pass for exactly this * reason; this is the same rule applied to colour. */ -static size_t policy_shader(app_t *a, node_t *n, shader_t *out) { +static size_t policy_shaders(app_t *a, node_t *n, shader_t *out, size_t cap) { + size_t k = 0; /* Only once the pointer has actually moved: a press that turns out to be a * click would otherwise flash the whole session grey on its way to nothing. */ if (a->drag.kind == DRAG_TITLE && a->drag.moved) { - /* The pane being dragged keeps its colour and everything else goes grey, - * so the one that is moving lifts off the page. This replaces the focus - * dimming rather than stacking with it: two reasons to be grey compound - * into one muddy grey that reads as neither. */ - if (n->id == a->drag.src || !CFG.drag_grayscale) return 0; - return shader_make(out, "grayscale", (color_t){0}, CFG.drag_grayscale) ? 1 - : 0; + /* The pane being dragged is left alone and everything else is pushed back + * — desaturated *and* darkened, because grey alone still competes for + * attention at the same brightness. Two passes rather than one shader + * that does both: they are independently tunable, and "colourless" and + * "recessed" are different things to want. + * + * This replaces the focus dimming rather than stacking with it: two + * reasons to be grey compound into a muddy grey that reads as neither. */ + if (n->id == a->drag.src) return 0; + if (CFG.drag_grayscale && k < cap && + shader_make(&out[k], "grayscale", (color_t){0}, CFG.drag_grayscale)) + k++; + if (CFG.drag_dim && k < cap && + shader_make(&out[k], "dim", (color_t){0}, CFG.drag_dim)) + k++; + return k; } - if (CFG.dim_unfocused && n != cur(a)->focus) - return shader_make(out, "dim", (color_t){0}, CFG.dim_unfocused) ? 1 : 0; - return 0; + if (CFG.dim_unfocused && n != cur(a)->focus && k < cap && + shader_make(&out[k], "dim", (color_t){0}, CFG.dim_unfocused)) + k++; + return k; } /* A pane with nothing to apply costs nothing: no context is built and no cell * is visited, so an unshaded session emits the same bytes it did before. */ static void shade_leaf(app_t *a, screen_t *s, node_t *n) { - shader_t chain[SHADE_MAX + 1]; + shader_t chain[SHADE_MAX + 2]; size_t nc = 0; /* Attached first, policy last: a pane's own colour is the thing the * session's opinion of the moment is then applied to. */ for (size_t i = 0; i < n->nshaders && nc < SHADE_MAX; i++) chain[nc++] = n->shaders[i]; - nc += policy_shader(a, n, &chain[nc]); + nc += policy_shaders(a, n, &chain[nc], (sizeof chain / sizeof *chain) - nc); if (!nc) return; shade_ctx_t base = { diff --git a/src/config.c b/src/config.c index 40a1cc9..6c1650c 100644 --- a/src/config.c +++ b/src/config.c @@ -131,6 +131,7 @@ void config_defaults(config_t *c) { c->double_click_ms = 400; c->dim_unfocused = 0; c->drag_grayscale = 200; + c->drag_dim = 140; c->status_bar = true; c->focus_follows_mouse = true; @@ -260,6 +261,8 @@ bool config_load(config_t *c, const char *path, char *err, size_t errcap) { c->dim_unfocused); c->drag_grayscale = (uint8_t)kdl_arg_int(kdl_child(root, "drag_grayscale"), 0, c->drag_grayscale); + c->drag_dim = + (uint8_t)kdl_arg_int(kdl_child(root, "drag_dim"), 0, c->drag_dim); const char *sh = kdl_arg(kdl_child(root, "shell"), 0, NULL); if (sh) { diff --git a/src/config.h b/src/config.h index 17c3645..eed50a6 100644 --- a/src/config.h +++ b/src/config.h @@ -65,6 +65,7 @@ typedef struct { * off by default; the drag greying is transient and on. */ uint8_t dim_unfocused; uint8_t drag_grayscale; + uint8_t drag_dim; bool status_bar; bool focus_follows_mouse; |
