From c31cef119901acf0df8201107d1734f5109c9d55 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:12:18 -0800 Subject: [PATCH 1/2] Tools: the controls under the tools scroll with them in a short window In a window too short for every tool, the Tools panel kept its paint chips, drawing modes and the other controls under the tools pinned at the bottom, so fewer tools were in view. The controls now scroll with the tools (ToolRail::footer_scrolls): in a window 560 points tall the rail shows 14 tools instead of 10, and scrolling to the end brings the controls into view under the last tool. Toolbars made with New Toolbar and torn-off strips keep their footer in view. --- crates/ui-egui/src/toolbar.rs | 4 +++ crates/ui-egui/src/toolbar/tests.rs | 49 ++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 6f2f72d06a..65c1aadc35 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -456,6 +456,10 @@ fn show_rail(app: &mut VectorcraftApp, ui: &mut Ui, owner: Owner, at: GroupAt, m if app.session.prefs.tool_group_labels { rail = rail.captions(); } + // The Tools panel's controls under the tools scroll with them, so a short window shows more tools. + if tools_panel { + rail = rail.footer_scrolls(); + } if own_bar { rail = rail.tear_off().edit_toolbar(tl!("Edit Toolbar")); } diff --git a/crates/ui-egui/src/toolbar/tests.rs b/crates/ui-egui/src/toolbar/tests.rs index 9ce6cca2e6..75dfeb327c 100644 --- a/crates/ui-egui/src/toolbar/tests.rs +++ b/crates/ui-egui/src/toolbar/tests.rs @@ -282,17 +282,18 @@ fn polygon_and_star_canvas_counts_persist_without_new_toolbar_dialogs() { /// The paint chips, drawing modes and the rest of the footer lie inside the rail at one and at two columns (one column /// shows the current drawing mode alone), and in two columns the three drawing modes sit side by side, each setting -/// its mode (#1129). +/// its mode (#1129). The window is tall enough for every tool and the controls under them, which scroll with the tools. #[test] fn the_paint_and_drawing_mode_buttons_fit_the_toolbar_width() { let mut app = app_with(200, 200); let ctx = reader(); + let height = 2000.0; let footer = ["Color (, or Shift+,)", "Gradient (. or Shift+.)", "None (/)", "Draw Normal (Shift+D)", "Draw Behind (Shift+D)", "Draw Inside (Shift+D)"]; let mut nodes = vec![]; for (k, double) in [false, true].into_iter().enumerate() { app.run("window.toolbarColumns", json!({ "double": double })).unwrap(); - nodes = settled(&mut app, &ctx, k as f64 * 10.0, 900.0); + nodes = settled(&mut app, &ctx, k as f64 * 10.0, height); // The rail itself, not its dock grip, which is named for the pane too. let rail = nodes.iter().find(|n| n.role() == Role::Toolbar && n.label() == Some("Tools")).and_then(bounds).expect("the rail is drawn"); for label in &footer[..if double { 6 } else { 4 }] { @@ -302,13 +303,12 @@ fn the_paint_and_drawing_mode_buttons_fit_the_toolbar_width() { } let modes = ["Draw Normal (Shift+D)", "Draw Behind (Shift+D)", "Draw Inside (Shift+D)"].map(|label| named_rect(&nodes, label)); assert!(modes.iter().all(|r| (r.top() - modes[0].top()).abs() < 0.5), "side by side: {modes:?}"); - click(&mut app, &ctx, 20.0, modes[1].center(), 900.0); + click(&mut app, &ctx, 20.0, modes[1].center(), height); assert_eq!(app.session.draw_mode, vectorcraft_engine::DrawMode::Behind); } /// In one column the Color, Gradient and None chips share one line, and a rule across the rail parts the controls under -/// the tools from the tools, which scroll above them in a short rail: it lies between the last tool and Fill and -/// Stroke. +/// the tools from the tools: it lies between the last tool and Fill and Stroke. #[test] fn the_controls_under_the_tools_share_a_line_under_a_rule() { let mut app = app_with(200, 200); @@ -604,3 +604,42 @@ fn a_short_tools_rail_shows_its_scroll_bar_at_rest() { 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"); } + +/// In a window too short for the Tools panel, the controls under the tools scroll with them: the tool buttons fill +/// the rail down to its bottom edge, Fill and Stroke starts out of view under them, and scrolling to the end brings +/// Fill and Stroke into view under the last tool. +#[test] +fn the_tools_panel_controls_scroll_with_the_tools_in_a_short_window() { + let mut app = app_with(200, 200); + let ctx = reader(); + app.run("window.toolbarColumns", json!({ "double": false })).unwrap(); + let height = 560.0; + let nodes = settled(&mut app, &ctx, 0.0, height); + let rail = nodes.iter().find(|n| n.role() == Role::Toolbar && n.label() == Some("Tools")).and_then(bounds).expect("the rail is drawn"); + let tools = cells(&app, &nodes); + let in_view: Vec<&egui::Rect> = tools.iter().filter(|r| r.bottom() <= rail.bottom() + 0.5).collect(); + assert!(in_view.len() < tools.len(), "the window is too short for every tool: {} of {}", in_view.len(), tools.len()); + let pitch = tools[1].top() - tools[0].top(); + let lowest = in_view.iter().map(|r| r.bottom()).fold(f32::MIN, f32::max); + let bottom = rail.bottom(); + assert!(bottom - lowest < pitch, "the tools fill the rail to its bottom: the last in view ends at {lowest}, the rail at {bottom}"); + let proxy = named_rect(&nodes, "Fill and Stroke"); + assert!(proxy.top() >= rail.bottom() - 0.5, "Fill and Stroke starts out of view: {proxy:?} under {rail:?}"); + + let wheel = Event::MouseWheel { + unit: egui::MouseWheelUnit::Point, + delta: egui::vec2(0.0, -400.0), + modifiers: Default::default(), + phase: egui::TouchPhase::Move, + source: egui::MouseWheelSource::Unknown, + }; + let over = tools[0].center(); + for k in 0..10 { + frame(&mut app, &ctx, 1.0 + f64::from(k) * 0.05, vec![Event::PointerMoved(over), wheel.clone()], height); + } + let nodes = settled(&mut app, &ctx, 2.0, height); + let proxy = named_rect(&nodes, "Fill and Stroke"); + let last = cells(&app, &nodes).into_iter().max_by(|a, b| a.bottom().total_cmp(&b.bottom())).expect("the rail shows tools"); + assert!(proxy.bottom() <= rail.bottom() + 0.5, "Fill and Stroke is in view after scrolling: {proxy:?} in {rail:?}"); + assert!(last.bottom() <= proxy.top(), "the last tool {last:?} stands above Fill and Stroke {proxy:?}"); +} From 214c88d98536c143061b8560dff02f092afa1804 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 11:45:44 -0800 Subject: [PATCH 2/2] Tools: the controls under the tools scroll with them, as bottom_controls says The doc comment on bottom_controls still said the tools scroll above the controls in a short rail. The Tools panel's rail now uses footer_scrolls, so the controls scroll with the tools and the rail draws the rule above them. --- crates/ui-egui/src/toolbar.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 4d58c972d7..618bace39b 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -772,8 +772,8 @@ fn quad_bounds(quad: &[Point; 4]) -> vectorcraft_geom::Rect { /// The Fill/Stroke proxy, Color/Gradient/None, the drawing modes and screen mode under the rail's /// tools: in two columns the three drawing modes show, in one only the current one, which cycles /// them. A row the rail is too narrow for goes on in the next line. The All Tools drawer's Show -/// section hides any of them. The rail's footer region draws the rule that parts them from the tools, which scroll -/// above it in a short rail. +/// section hides any of them. The rail draws the rule that parts them from the tools, and they scroll with the tools +/// in a short rail. fn bottom_controls(app: &mut VectorcraftApp, ui: &mut Ui, footer: RailFooter) { let two = footer.columns > 1; let show = app.ui.toolbar_show;