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).
This commit is contained in:
dotCooCoo committed 2026-11-28 18:01:32 -08:00
1 parent ac031311a2
commit 799c6f01be
2 files changed
+38 -2

No files matched your search

+4 -2
View File
@@ -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, &current, &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);
}
+34
View File
@@ -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<egui::Shape> = 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");
}