From 799c6f01be3bdef5f2c3f74afce43dda6bb490a2 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 18:01:32 -0800 Subject: [PATCH] Tools: a short rail shows its scroll bar with the pointer away When the window is too short for every tool, the Tools panel, toolbars made with New Toolbar and torn-off tool strips scroll their tools. The scroll bar showed only while the pointer was over the rail, so nothing showed that tools were hidden. The rail now keeps its scroll bar visible whenever its tools do not fit (ToolRail::bar_at_rest). --- crates/ui-egui/src/toolbar.rs | 6 +++-- crates/ui-egui/src/toolbar/tests.rs | 34 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index be89cd34c1..6f2f72d06a 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -439,12 +439,14 @@ fn show_rail(app: &mut VectorcraftApp, ui: &mut Ui, owner: Owner, at: GroupAt, m let located = locate::wanted(&app.ui, &home); let holds = |tool: &str| model.slots.iter().any(|slot| slot.tools.iter().any(|t| t.id == tool)); let reveal = matches!(at, GroupAt::Show(_)).then(|| locate::take_reveal(&mut app.ui, &home, holds)).flatten(); - // The current tool in production's pressed fill, with no accent edge. + // The current tool in production's pressed fill, with no accent edge. A rail too short for its tools shows its + // scroll bar with the pointer away too, so the hidden tools can be found. let mut rail = ToolRail::new(tl!("Tools"), &model.slots, ¤t, &model.last_used) .opens(opens) .tips(&cards) .active_look(ActiveLook::Pressed) - .density(rail_density(app, &owner)); + .density(rail_density(app, &owner)) + .bar_at_rest(); if let Some(tool) = &located { rail = rail.mark(tool); } diff --git a/crates/ui-egui/src/toolbar/tests.rs b/crates/ui-egui/src/toolbar/tests.rs index 5671cbe62e..2495ec4d03 100644 --- a/crates/ui-egui/src/toolbar/tests.rs +++ b/crates/ui-egui/src/toolbar/tests.rs @@ -582,3 +582,37 @@ fn the_rail_builds_its_slots_only_when_its_tool_groups_change() { let kept = app.dock_rt.rail_models.get(&Owner::Tools.panel()).map(|model| model.slots.len()); assert_eq!(kept, Some(advanced), "the rail shows the Advanced toolbar's slots"); } + +/// A window too short for the tools shows the rail's scroll bar with the pointer away from the rail: a narrow bar, +/// several times taller than wide, inside the rail's end edge. A window tall enough for every tool shows none. +#[test] +fn a_short_tools_rail_shows_its_scroll_bar_at_rest() { + let mut app = app_with(200, 200); + let ctx = reader(); + app.run("window.toolbarColumns", json!({ "double": false })).unwrap(); + let bars = |app: &mut VectorcraftApp, t0: f64, height: f32| { + let nodes = settled(app, &ctx, t0, height); + let rail = nodes.iter().find(|n| n.role() == Role::Toolbar && n.label() == Some("Tools")).and_then(bounds).expect("the rail is drawn"); + let screen_rect = Some(egui::Rect::from_min_size(Pos2::ZERO, egui::vec2(1200.0, height))); + let out = crate::testing::app_frame(app, &ctx, egui::RawInput { time: Some(t0 + 0.2), screen_rect, ..Default::default() }); + let mut stack: Vec = out.shapes.into_iter().map(|clipped| clipped.shape).collect(); + let mut found = 0; + while let Some(shape) = stack.pop() { + match shape { + egui::Shape::Vec(inner) => stack.extend(inner), + egui::Shape::Rect(r) => { + let b = r.rect; + let narrow = b.width() > 0.0 && b.width() <= rail.width() * 0.25 && b.height() >= b.width() * 3.0; + let at_end = rail.expand(0.5).contains_rect(b) && b.center().x > rail.center().x; + if narrow && at_end { + found += 1; + } + } + _ => {} + } + } + found + }; + assert!(bars(&mut app, 0.0, 400.0) > 0, "a short rail shows its scroll bar with the pointer away"); + assert_eq!(bars(&mut app, 10.0, 2000.0), 0, "a rail with room for every tool shows no scroll bar"); +}