mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-01 14:26:49 -06:00
M1: a click on the toolbar no longer reaches the canvas under it (#307)
This commit is contained in:
@@ -92,3 +92,19 @@ fn the_mode_switcher_ends_the_pen_path_too() {
|
||||
assert_eq!(layers(&u), finished, "{label}: the path is kept as Escape keeps it");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_press_on_the_mode_switcher_does_not_reach_the_canvas() {
|
||||
// The switcher floats over the canvas: the pen must not place an anchor under it.
|
||||
for label in ["Prototype", "Design"] {
|
||||
let mut u = Ui::new(Session::new());
|
||||
u.app.run("tool.set", json!({"tool": "pen"}));
|
||||
let at = mode_button(&mut u, label);
|
||||
u.button(at, true);
|
||||
assert!(u.app.session.tool.pen.is_none(), "{label}: the press starts no path");
|
||||
u.button(at, false);
|
||||
u.frame(vec![]);
|
||||
assert!(u.app.session.tool.pen.is_none(), "{label}: no path after the click");
|
||||
assert_eq!(layers(&u), 0, "{label}: the click adds nothing");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,6 +329,10 @@ fn builder_toolbar(app: &mut FigApp, ui: &mut Ui) {
|
||||
/// toolbar region keyboard navigation moves through.
|
||||
fn pill(ui: &Ui, nav: &mut Nav, canvas: Rect, width: f32, t: &Tokens) -> Rect {
|
||||
let rect = Rect::from_center_size(pos2(canvas.center().x, canvas.max.y - 12.0 - 24.0), vec2(width, 48.0));
|
||||
// The pill takes the press and the drag over it: its buttons sense clicks only, and egui gives
|
||||
// a drag the canvas under them would sense to the canvas, so the pen placed an anchor there.
|
||||
// Not focusable: the keyboard walks the buttons, not the pill.
|
||||
ui.interact(rect, ui.id().with("pill"), Sense::CLICK | Sense::DRAG);
|
||||
a11y::area(nav, Region::Toolbar, rect);
|
||||
a11y::container_bounds(ui, rect);
|
||||
let painter = ui.painter();
|
||||
|
||||
Reference in New Issue
Block a user