Эх сурвалжийг харах

ngui: hide scrollbars until the pointer enters a pane

The bar was always painted over the right edge of a scroll pane, so
files, chat, disks and gallery reserved a column for it and the content
never used the full width.

Draw an 8 px rounded overlay pill instead: it stays hidden while the
pointer is outside the pane, slides in from the right edge over ~100 ms
on hover, brightens over the hit strip and uses the accent colour while
dragged.  Presses in the strip start the drag (or jump the thumb) and are
consumed so the row or button beneath it does not activate.

Remove the per-app reservations so rows, messages and columns use the
full pane width, and let the control panel use the overlay bar too;
hide_bar remains as an explicit opt-out.  The terminal keeps its own
cell-rendered scrollbar.
Johannes Zellner 2 өдөр өмнө
parent
commit
da99a8231b

+ 4 - 2
AGENTS.md

@@ -500,8 +500,10 @@ it to `0x7E00`.  The kernel region itself only has one wall (`_end` below
   window still gets its release after the pointer leaves.  The userland
   `ngui.c/h` immediate-mode toolkit builds on those: clipped RGB565
   primitives, buttons, text input, the Adwaita symbolic icons and scrolling panes
-  (`ngui_scroll`; `hide_bar` keeps wheel/key scrolling without drawing a
-  scrollbar).
+  (`ngui_scroll`: an overlay scrollbar that is hidden while the pointer is
+  outside the pane, slides in on hover over ~100 ms, and reserves no layout
+  width; presses in its strip start the drag and do not reach the content;
+  `hide_bar` suppresses it entirely).
   `files` (`ucmd_files.c`) is its first user (its toolbar's `Disks`
   button opens the storage manager); `gallery` (`gallery.c`) is the
   live showcase of every control and primitive the toolkit exports.  Buttons

+ 8 - 6
docs/graphics.html

@@ -189,8 +189,8 @@
 			window).  <code>SYS_WIN_RESIZE_SELF</code> grows or shrinks the
 			popover to the section, clamped to <code>SYS_SCREEN_INFO</code>'s
 			framebuffer; the section scrolls with the wheel, touchpad or page
-			keys when it is taller than the screen, without drawing a
-			scrollbar.
+			keys when it is taller than the screen, and its overlay scrollbar
+			slides in while the pointer is over the panel.
 		</p>
 		<p>
 			The WM is the ring-3 process loaded from
@@ -296,10 +296,11 @@
 			(<code>+dy</code> is later content). A click that starts
 			in a window still receives its release after the pointer leaves.
 			The ngui helper <code>ngui_scroll_wheel()</code> applies the delta
-			to a pane when the pointer is over it; a pane can set
-			<code>hide_bar</code> to keep wheel/key scrolling without a visible
-			scrollbar (the control panel does this so every card uses the full
-			width).
+			to a pane when the pointer is over it. A pane's scrollbar is an
+			overlay: an 8 px rounded pill at its right edge that stays hidden
+			while the pointer is outside, slides in over about 100 ms on
+			hover, and never reduces the content rectangle or reflows a row.
+			<code>hide_bar</code> suppresses it entirely.
 			The WM process itself is special: it maps the screen shadow at
 			<code>0x58000000</code> and each front canvas at
 			<code>0x59000000 + index × 4 MB</code>, which is how it composites
@@ -361,6 +362,7 @@
 		<ul>
 			<li><strong>Text fields</strong> support drag-selection, double-click select-all, Ctrl+Left/Right word jumps, Ctrl+Delete/Backspace word deletion and Ctrl+A. They use the proportional face with measured caret, selection and horizontal scrolling; a field marked <code>disabled</code> ignores pointer and keyboard input, drops the focus and paints its value dimmed in the same proportional face. A field marked <code>secret</code> is measured and painted from a <code>*</code> mask (caret, selection and click positions follow the mask, Ctrl+Left/Right jump to the ends), and Tab returns <code>NGUI_INPUT_NEXT</code> together with <code>NGUI_INPUT_CANCEL</code> so forms can move the focus. Fields hold up to 511 characters (<code>NGUI_INPUT_MAX</code> 512). The terminal and editor keep the 8×16 cell grid.</li>
 			<li><strong>Popover components</strong> give a menu panel its surface: <code>ngui_popover_begin()</code> fills the canvas and returns the body and footer rectangles (no title bar or close button); <code>ngui_section()</code> draws a captioned section header with an optional right-aligned action button; <code>ngui_list_row()</code> is a two-line hover/selected row with optional signal bars and trailing text; <code>ngui_tile()</code> is a rounded quick-settings tile and <code>ngui_slider()</code> a draggable horizontal slider. The WM draws no outer chrome, so the app paints the whole window.</li>
+			<li><strong>Scroll panes</strong> keep the wheel and page keys, and draw a Firefox-style overlay pill instead of a permanent track. It is hidden by default, animates in from the pane's right edge while the pointer is over the pane, brightens over the hit strip and turns accent-coloured while dragged. Presses in the strip start a drag (or jump the thumb) and do not reach the rows or buttons beneath it; content uses the full pane width in every app.</li>
 			<li><strong>Clip stack</strong> keeps nested panes and popups inside their parents.</li>
 			<li><strong>Layout cuts</strong> split a rectangle into rows, columns and fixed margins without a constraint solver.</li>
 			<li><strong>No retained widget tree.</strong> Apps redraw from state every frame, which keeps the toolkit small and predictable.</li>

+ 4 - 10
user/apps/chat/ucmd_chat.c

@@ -2666,7 +2666,7 @@ static void draw_login(void)
 static void draw_sidebar(struct ngui_rect r)
 {
 	struct ngui_rect list, btns, b;
-	int y, i, section, row_w, scrolls;
+	int y, i, section, row_w;
 	int lh = line_h();
 
 	ngui_fill_rect(&ui, r, ui.theme.panel);
@@ -2683,8 +2683,7 @@ static void draw_sidebar(struct ngui_rect r)
 	side_scroll.content_h = 2 * SIDE_HEAD + nconv * SIDE_ROW + 8;
 	ngui_scroll_begin(&ui, list, &side_scroll);
 	ngui_scroll_wheel(&ui, list, &side_scroll);
-	scrolls = side_scroll.content_h > side_scroll.view_h;
-	row_w = list.w - (scrolls ? 16 : 0);
+	row_w = list.w;
 	y = list.y - side_scroll.offset;
 	for (section = 0; section < 2; section++) {
 		ngui_text_px(&ui, list.x + 10, y + 6,
@@ -2854,19 +2853,14 @@ static void draw_timeline(struct ngui_rect r)
 			  ui.theme.text_dim);
 		return;
 	}
-	tl_width = r.w - 16;
+	tl_width = r.w;
 	total = content_height();
 	tl_scroll.content_h = total;
 	ngui_scroll_begin(&ui, r, &tl_scroll);
 	if (ngui_scroll_wheel(&ui, r, &tl_scroll))
 		last_input_ms = u_ticks_ms();
 	scrolls = total > r.h;
-	width = r.w - (scrolls ? 16 : 0);
-	if (width != tl_width) {
-		tl_width = width;
-		total = content_height();
-		tl_scroll.content_h = total;
-	}
+	width = r.w;
 	/* Scrolling to the very top pages in older history by itself (the
 	 * button stays for the pointer).  Rate-limited so a failing request
 	 * cannot spin. */

+ 3 - 20
user/apps/disks/ucmd_disks.c

@@ -609,18 +609,6 @@ static void draw_toolbar(struct ngui_rect r)
 	}
 }
 
-/* ngui's scroll pane paints its bar over the right edge of the pane, so the
- * content must leave that strip free while the pane scrolls. */
-#define SCROLLBAR_ROOM 20
-
-static struct ngui_rect scroll_content(struct ngui_rect area,
-				       const struct ngui_scroll *s)
-{
-	if (!s->hide_bar && s->content_h > s->view_h)
-		area.w -= SCROLLBAR_ROOM;
-	return area;
-}
-
 /* Empty IDE channels and absent eMMC/USB slots are registered as devices
  * but have nothing to show; a floppy drive is listed without media too. */
 static int listed(const struct disk *d)
@@ -642,7 +630,7 @@ static void draw_device_list(struct ngui_rect area)
 	list_scroll.content_h = (y + 1) * ROW_H + 2 * SECTION_H;
 	ngui_scroll_begin(&ui, area, &list_scroll);
 	ngui_scroll_wheel(&ui, area, &list_scroll);
-	col = scroll_content(area, &list_scroll);
+	col = area;
 	y = area.y - list_scroll.offset;
 
 	r = (struct ngui_rect){ col.x, y, col.w, SECTION_H };
@@ -999,17 +987,14 @@ static int draw_disk(struct ngui_rect area, int y, struct disk *d)
 static void draw_details(struct ngui_rect area)
 {
 	struct ngui_rect col;
-	int y, top, had_bar;
+	int y, top;
 
 	ngui_inset(&area, 14);
 	ngui_scroll_begin(&ui, area, &detail_scroll);
 	ngui_scroll_wheel(&ui, area, &detail_scroll);
 	if (!ui.focus)
 		ngui_scroll_keys(&ui, &detail_scroll);
-	/* The height is only known after drawing, so the bar decision uses
-	 * the previous frame's; redraw once when it flips. */
-	col = scroll_content(area, &detail_scroll);
-	had_bar = col.w != area.w;
+	col = area;
 	top = area.y - detail_scroll.offset;
 	if (sel_disk < 0)
 		y = draw_overview(col, top);
@@ -1017,8 +1002,6 @@ static void draw_details(struct ngui_rect area)
 		y = draw_disk(col, top, &disks[sel_disk]);
 	detail_scroll.content_h = y - top;
 	ngui_scroll_end(&ui, area, &detail_scroll);
-	if (had_bar != (scroll_content(area, &detail_scroll).w != area.w))
-		ngui_invalidate(&ui);
 }
 
 /* ---- dialogs ---- */

+ 1 - 4
user/apps/files/ucmd_files.c

@@ -16,7 +16,6 @@
 #define FM_PATH_H       26
 #define FM_STATUS_H     18
 #define FM_SIDEBAR_W    140
-#define FM_SCROLL_W     9
 #define FM_EDIT_MAX     16384
 #define FM_STATUS_MS    3000
 
@@ -815,7 +814,6 @@ static void draw_sidebar(struct ngui *g, struct ngui_rect r, unsigned int *actio
 static void draw_list(struct ngui *g, struct ngui_rect r, unsigned int *action)
 {
 	unsigned int i;
-	int scrolls;
 	int row_w;
 	int hover_idx = -1;
 	int press_idx = -1;
@@ -824,8 +822,7 @@ static void draw_list(struct ngui *g, struct ngui_rect r, unsigned int *action)
 	list_scroll.content_h = (int)(entry_count * FM_ROW_H);
 	ngui_scroll_begin(g, r, &list_scroll);
 	ngui_scroll_wheel(g, r, &list_scroll);
-	scrolls = list_scroll.content_h > list_scroll.view_h;
-	row_w = r.w - (scrolls ? FM_SCROLL_W : 0);
+	row_w = r.w;
 
 	if (g->inside && g->mouse_x >= r.x && g->mouse_x < r.x + row_w &&
 	    g->mouse_y >= r.y && g->mouse_y < r.y + r.h &&

+ 5 - 7
user/apps/gallery/gallery.c

@@ -914,7 +914,7 @@ static void draw_scroll(struct ngui *g, struct ngui_rect card)
 	scroll_pane_valid = 1;
 	ngui_text_ellipsis(g, rect_make(x, top, card.w - 2 * CARD_PAD, 16),
 			   x, top,
-			   "A nested pane: click a row, drag its scrollbar.",
+			   "A nested pane: hover for its scrollbar, then drag it.",
 			   g->theme.text_dim);
 
 	list_scroll.content_h = LIST_ROWS * LIST_ROW_H;
@@ -922,8 +922,7 @@ static void draw_scroll(struct ngui *g, struct ngui_rect card)
 	ngui_scroll_begin(g, pane, &list_scroll);
 	ngui_scroll_wheel(g, pane, &list_scroll);
 
-	if (g->pressed && ngui_rect_contains(&pane, g->press_x, g->press_y) &&
-	    g->press_x < pane.x + pane.w - 9) {
+	if (g->pressed && ngui_rect_contains(&pane, g->press_x, g->press_y)) {
 		int idx = (g->press_y - pane.y + list_scroll.offset) /
 			LIST_ROW_H;
 
@@ -947,14 +946,13 @@ static void draw_scroll(struct ngui *g, struct ngui_rect card)
 
 	for (i = 0; i < LIST_ROWS; i++) {
 		int ry = pane.y + i * LIST_ROW_H - list_scroll.offset;
-		struct ngui_rect row = rect_make(pane.x, ry, pane.w - 9,
+		struct ngui_rect row = rect_make(pane.x, ry, pane.w,
 						 LIST_ROW_H);
 		char label[64];
 		unsigned int n = 0;
 		unsigned short bg;
 		int hover = g->inside &&
 			ngui_rect_contains(&pane, g->mouse_x, g->mouse_y) &&
-			g->mouse_x < pane.x + pane.w - 9 &&
 			(g->mouse_y - pane.y + list_scroll.offset) /
 				LIST_ROW_H == i;
 
@@ -976,7 +974,7 @@ static void draw_scroll(struct ngui *g, struct ngui_rect card)
 			s_append(label, &n, " ", sizeof(label));
 		s_append(label, &n, list_items[i], sizeof(label));
 		ngui_text_ellipsis(g, rect_make(pane.x + 32, ry + 4,
-						pane.w - 9 - 44, 16),
+						pane.w - 44, 16),
 				   pane.x + 32, ry + 4, label,
 				   i == list_selected ? g->theme.text :
 							g->theme.text_dim);
@@ -1123,7 +1121,7 @@ static void draw_cursors(struct ngui *g, struct ngui_rect card)
 static void draw_body(struct ngui *g, struct ngui_rect body)
 {
 	int x = body.x + PAGE_PAD;
-	int w = body.w - PAGE_PAD * 2 - 9;
+	int w = body.w - PAGE_PAD * 2;
 	int i;
 
 	page.content_h = sec_content_h;

+ 0 - 2
user/apps/netmenu/ucmd_netmenu.c

@@ -1999,8 +1999,6 @@ void _start(const char *arg)
 	view = VIEW_MAIN;
 	expanded = EXPAND_NONE;
 	main_scroll.offset = 0;
-	main_scroll.hide_bar = 1;
-	saved_scroll.hide_bar = 1;
 
 	load_devices();
 	load_status();

+ 191 - 73
user/lib/ngui/ngui.c

@@ -2290,81 +2290,188 @@ void ngui_scroll_ensure_visible(struct ngui_scroll *s, int y, int h)
 	scroll_clamp(s);
 }
 
+#define SCROLLBAR_W       8
+#define SCROLLBAR_INSET   2
+#define SCROLLBAR_HIT_W   14
+#define SCROLLBAR_STEPS   8
+#define SCROLLBAR_STEP_MS 14
+
+static struct ngui_rect scroll_track_rect(const struct ngui_rect *r)
+{
+	struct ngui_rect t;
+	int inset = SCROLLBAR_INSET;
+
+	if (r->w < SCROLLBAR_W + 2 * inset || r->h <= 2 * inset)
+		inset = 0;
+	t.x = r->x + r->w - SCROLLBAR_W - inset;
+	t.y = r->y + inset;
+	t.w = SCROLLBAR_W;
+	t.h = r->h - 2 * inset;
+	return t;
+}
+
+static struct ngui_rect scroll_hit_rect(const struct ngui_rect *r)
+{
+	struct ngui_rect h = *r;
+	int w = SCROLLBAR_HIT_W;
+
+	if (w > r->w)
+		w = r->w;
+	h.x = r->x + r->w - w;
+	h.w = w;
+	return h;
+}
+
+static int pointer_in_rect(struct ngui *ui, const struct ngui_rect *r)
+{
+	if (!ui->inside || !ngui_rect_contains(r, ui->mouse_x, ui->mouse_y))
+		return 0;
+	if (ui->nclip > 0 &&
+	    !ngui_rect_contains(&ui->clip[ui->nclip - 1], ui->mouse_x,
+				ui->mouse_y))
+		return 0;
+	return 1;
+}
+
+/* Width of the pill for one animation step.  The bar grows into the pane
+ * from its right edge, so the animation needs no alpha compositing. */
+static int scroll_bar_w(int vis)
+{
+	if (vis <= 0)
+		return 0;
+	if (vis >= SCROLLBAR_STEPS)
+		return SCROLLBAR_W;
+	return 1 + (vis - 1) * (SCROLLBAR_W - 1) / (SCROLLBAR_STEPS - 1);
+}
+
+/* Advance the overlay bar animation.  The bar stays hidden while the pointer
+ * is outside the pane and slides in on hover; a drag pins it open.  Setting
+ * ui->dirty while steps remain makes the app draw the next frame. */
+static void scroll_bar_update(struct ngui *ui, const struct ngui_rect *r,
+			      struct ngui_scroll *s)
+{
+	int hover, target, steps;
+	unsigned int now, due;
+
+	if (s->hide_bar || !scrollable(s)) {
+		s->dragging = 0;
+		s->bar_vis = 0;
+		s->bar_target = 0;
+		s->bar_hot = 0;
+		return;
+	}
+
+	{
+		struct ngui_rect hit = scroll_hit_rect(r);
+
+		hover = pointer_in_rect(ui, r);
+		s->bar_hot = hover &&
+			     ngui_rect_contains(&hit, ui->mouse_x, ui->mouse_y);
+	}
+	target = (hover || s->dragging) ? SCROLLBAR_STEPS : 0;
+	now = u_ticks_ms();
+	if (target != s->bar_target) {
+		s->bar_target = target;
+		s->bar_ms = now;
+		if (s->bar_vis != target)
+			ui->dirty = 1;
+		return;
+	}
+	if (s->bar_vis == target)
+		return;
+
+	due = now - s->bar_ms;
+	steps = (int)(due / SCROLLBAR_STEP_MS);
+	if (steps > 0) {
+		if (target > s->bar_vis) {
+			s->bar_vis += steps;
+			if (s->bar_vis > target)
+				s->bar_vis = target;
+		} else {
+			s->bar_vis -= steps;
+			if (s->bar_vis < target)
+				s->bar_vis = target;
+		}
+		s->bar_ms += (unsigned int)steps * SCROLLBAR_STEP_MS;
+	}
+	if (s->bar_vis != target)
+		ui->dirty = 1;
+}
+
+static void scroll_bar_press(struct ngui_scroll *s,
+			     const struct ngui_rect *track, int th, int y)
+{
+	int ty = scroll_thumb_y(track, s);
+
+	if (y >= ty && y < ty + th) {
+		s->dragging = 1;
+		s->drag_dy = y - ty;
+	} else {
+		int rel = y - track->y - th / 2;
+		int avail = track->h - th;
+		int max = s->content_h - s->view_h;
+
+		if (rel < 0)
+			rel = 0;
+		if (rel > avail)
+			rel = avail;
+		if (avail > 0)
+			s->offset = rel * max / avail;
+		s->dragging = 1;
+		s->drag_dy = th / 2;
+		scroll_clamp(s);
+	}
+}
+
+static void scroll_bar_drag(struct ngui_scroll *s,
+			    const struct ngui_rect *track, int th, int y)
+{
+	int rel = y - track->y - s->drag_dy;
+	int avail = track->h - th;
+	int max = s->content_h - s->view_h;
+
+	if (rel < 0)
+		rel = 0;
+	if (rel > avail)
+		rel = avail;
+	if (avail > 0)
+		s->offset = rel * max / avail;
+	scroll_clamp(s);
+}
+
 void ngui_scroll_begin(struct ngui *ui, struct ngui_rect r,
 		       struct ngui_scroll *s)
 {
-	struct ngui_rect bar;
-	int scrolls = scrollable(s);
+	struct ngui_rect track, hit;
+	int th;
 
 	s->view_h = r.h;
 	scroll_clamp(s);
 	if (!ui->buttons)
 		s->dragging = 0;
-	if (s->hide_bar)
-		s->dragging = 0;
-	if (!s->hide_bar && scrolls) {
-		int th = scroll_thumb_h(&r, s);
-		int ty = scroll_thumb_y(&r, s);
+	scroll_bar_update(ui, &r, s);
 
-		bar = rect_make(r.x + r.w - 15, r.y, 14, r.h);
+	if (!s->hide_bar && scrollable(s)) {
+		track = scroll_track_rect(&r);
+		hit = scroll_hit_rect(&r);
+		th = scroll_thumb_h(&track, s);
 		if (ui->pressed &&
-		    ngui_rect_contains(&bar, ui->press_x, ui->press_y)) {
-			if (ui->press_y >= ty && ui->press_y < ty + th) {
-				s->dragging = 1;
-				s->drag_dy = ui->press_y - ty;
-			} else {
-				int rel = ui->press_y - r.y - th / 2;
-				int avail = r.h - th;
-				int max = s->content_h - s->view_h;
-
-				if (rel < 0)
-					rel = 0;
-				if (rel > avail)
-					rel = avail;
-				if (avail > 0)
-					s->offset = rel * max / avail;
-				s->dragging = 1;
-				s->drag_dy = th / 2;
-				scroll_clamp(s);
-			}
+		    ngui_rect_contains(&hit, ui->press_x, ui->press_y)) {
+			scroll_bar_press(s, &track, th, ui->press_y);
+			/* The bar is on top of the content: a drag must not
+			 * also activate a row or button below it. */
+			ui->pressed = 0;
+			ui->clicked = 0;
 		}
-		/* Sampled buttons are authoritative while held: some event paths
-		 * deliver the press late or coalesce it with the release.  Start
-		 * the drag from the current pointer position as well. */
+		/* Sampled buttons are authoritative while held: some event
+		 * paths deliver the press late or coalesce it with the
+		 * release.  Start the drag from the current pointer position
+		 * as well, but only once the bar is fully visible. */
 		if (!s->dragging && (ui->buttons & 1) &&
-		    ngui_rect_contains(&bar, ui->mouse_x, ui->mouse_y)) {
-			if (ui->mouse_y >= ty && ui->mouse_y < ty + th) {
-				s->dragging = 1;
-				s->drag_dy = ui->mouse_y - ty;
-			} else {
-				int rel = ui->mouse_y - r.y - th / 2;
-				int avail = r.h - th;
-				int max = s->content_h - s->view_h;
-
-				if (rel < 0)
-					rel = 0;
-				if (rel > avail)
-					rel = avail;
-				if (avail > 0)
-					s->offset = rel * max / avail;
-				s->dragging = 1;
-				s->drag_dy = th / 2;
-				scroll_clamp(s);
-			}
-		}
-		if (s->dragging && (ui->buttons & 1)) {
-			int rel = ui->mouse_y - r.y - s->drag_dy;
-			int avail = r.h - th;
-			int max = s->content_h - s->view_h;
-
-			if (rel < 0)
-				rel = 0;
-			if (rel > avail)
-				rel = avail;
-			if (avail > 0)
-				s->offset = rel * max / avail;
-			scroll_clamp(s);
-		}
+		    s->bar_hot && s->bar_vis == SCROLLBAR_STEPS)
+			scroll_bar_press(s, &track, th, ui->mouse_y);
+		if (s->dragging && (ui->buttons & 1))
+			scroll_bar_drag(s, &track, th, ui->mouse_y);
 		if (ui->released)
 			s->dragging = 0;
 	}
@@ -2374,19 +2481,30 @@ void ngui_scroll_begin(struct ngui *ui, struct ngui_rect r,
 void ngui_scroll_end(struct ngui *ui, struct ngui_rect r,
 		     struct ngui_scroll *s)
 {
+	struct ngui_rect track, thumb;
+	int bw, th, ty;
+	unsigned short color;
+
 	ngui_pop_clip(ui);
-	if (s->hide_bar || !scrollable(s))
+	/* content_h is often known only after drawing, so advance the state
+	 * here as well; a new target requests a follow-up frame. */
+	scroll_bar_update(ui, &r, s);
+	if (s->hide_bar || !scrollable(s) || s->bar_vis <= 0)
 		return;
-	{
-		struct ngui_rect bar = rect_make(r.x + r.w - 15, r.y, 14, r.h);
-		int th = scroll_thumb_h(&r, s);
-		int ty = scroll_thumb_y(&r, s);
-		struct ngui_rect thumb = rect_make(bar.x, ty, 14, th);
 
-		ngui_fill_rect(ui, bar, ui->theme.panel_alt);
-		ngui_fill_rect(ui, thumb, s->dragging ?
-			       ui->theme.accent : ui->theme.text_dim);
-	}
+	track = scroll_track_rect(&r);
+	bw = scroll_bar_w(s->bar_vis);
+	if (bw <= 0)
+		return;
+	th = scroll_thumb_h(&track, s);
+	ty = scroll_thumb_y(&track, s);
+	thumb = rect_make(r.x + r.w - SCROLLBAR_INSET - bw, ty, bw, th);
+	color = s->dragging ? ui->theme.accent :
+		s->bar_hot ? ui->theme.text_dim : ui->theme.border;
+	ngui_fill_round_rect(ui, thumb, bw / 2, bw / 2, bw / 2, bw / 2,
+			     color);
+	if (s->bar_hot)
+		ngui_set_cursor(ui, CURSOR_DEFAULT);
 }
 
 int ngui_scroll_wheel(struct ngui *ui, struct ngui_rect r,

+ 6 - 0
user/lib/ngui/ngui.h

@@ -104,6 +104,12 @@ struct ngui_scroll {
 	int dragging;
 	int drag_dy;
 	int hide_bar;                 /* wheel/keys only; draw no scrollbar */
+	/* The bar is an overlay: it reserves no layout width, stays hidden
+	 * while the pointer is outside the pane and slides in on hover. */
+	int bar_vis;                  /* 0 hidden .. animation target shown */
+	int bar_target;               /* requested visibility (0 or full) */
+	int bar_hot;                  /* pointer is over the scrollbar strip */
+	unsigned int bar_ms;          /* last animation step (u_ticks_ms) */
 };
 
 struct ngui_slider {