mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-30 18:25:34 +01:00
Merge pull request #10103 from dotCooCoo/fix/tools-footer-scrolls
Tools: the controls under the tools scroll with them in a short window
This commit is contained in:
2 files changed
+50
-7
No files matched your search
@@ -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"));
|
||||
}
|
||||
@@ -768,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;
|
||||
|
||||
@@ -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 one 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, and no second rule doubles it.
|
||||
/// under the tools from the tools: it lies between the last tool and Fill and Stroke, and no second rule doubles it.
|
||||
#[test]
|
||||
fn the_controls_under_the_tools_share_a_line_under_a_rule() {
|
||||
let mut app = app_with(200, 200);
|
||||
@@ -607,3 +607,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:?}");
|
||||
}
|
||||
Reference in new issue
Block a user