SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Viewport: with Orbit, Pan or Zoom lit, a press held still keeps the highlight under it (#8864) (#8898)
austin62jakee5ef3bad02ac
diff --git a/crates/ui-egui/src/select_other_tests.rs b/crates/ui-egui/src/select_other_tests.rsindex 28d2759d76..00af395ab1 100644--- a/crates/ui-egui/src/select_other_tests.rs+++ b/crates/ui-egui/src/select_other_tests.rs@@ -520,6 +520,31 @@ fn holding_still_opens_the_list_while_a_navigation_mode_is_lit() {}}+/// A press held still on a line keeps the line lit until the list opens, with Orbit, Pan or+/// Zoom lit as with none: the press is not navigating yet (#8864).+#[test]+fn a_press_held_still_keeps_the_highlight_while_a_navigation_mode_is_lit() {+ for slot in [None, Some("orbit"), Some("pan"), Some("zoom")] {+ let (mut h, at) = two_lines();+ if let Some(slot) = slot {+ h.step(&json!({"click": {"handle": format!("nav:slot:{slot}")}})).unwrap();+ }+ h.step(&json!({"move": at})).unwrap();+ h.frames(2);+ assert!(hovered_curve(&h).is_some(), "{slot:?}: the line under the pointer is lit");+ let pos = egui::pos2(at[0].as_f64().unwrap_or_default() as f32, at[1].as_f64().unwrap_or_default() as f32);+ let button = |pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() };+ h.app.synthetic.push(button(true));+ h.frames(10);+ assert!(!crate::select_other::is_open(&h.app), "{slot:?}: not open yet");+ assert!(hovered_curve(&h).is_some(), "{slot:?}: still lit while the press is held");+ h.frames(40);+ assert!(crate::select_other::is_open(&h.app), "{slot:?}: the hold opened the list");+ h.app.synthetic.push(button(false));+ h.frames(2);+ }+}+/// A drag under a lit mode still moves the view and does not open the list, whether it starts/// at once or after the press was held still for longer than egui waits to call it a drag.#[test]diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rsindex e2cf7f589f..f5903604d1 100644--- a/crates/ui-egui/src/viewport.rs+++ b/crates/ui-egui/src/viewport.rs@@ -4142,13 +4142,16 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {// events. Testing delta made the highlight reappear whenever a held drag paused.// Resolve it before rendering so the GPU scene and screen overlays use the same hit.// A 3D mouse moving the view is not such a gesture: the pointer hand is free, and hover- // and clicks keep picking while the other hand turns the view.+ // and clicks keep picking while the other hand turns the view. Nor is a left press held+ // still under a mode lit in the navigation bar or a held Space: they own drags, and the+ // press may be opening Select Other (#8864); once it drags, `mode` says so. A preset's+ // left-button binding or Ctrl+left orbit navigates from the press on.let navigating = scroll != 0.0|| pinch != 1.0|| pan != egui::Vec2::ZERO|| middle|| secondary_down- || (primary_nav.is_some() && primary_down)+ || (app.viewport.primary_nav.is_some() && primary_down)|| mode.is_some()|| app.viewport.axis_drag.is_some()|| app.viewport.spin@@ -8526,8 +8529,16 @@ mod tests {hover_frame(&mut app, &ctx, vec![egui::Event::PointerMoved(p)]);assert!(app.viewport.hover.is_some());hover_frame(&mut app, &ctx, vec![egui::Event::PointerButton { pos: p, button, pressed: true, modifiers: Default::default() }]);- assert!(app.viewport.hover.is_none(), "hover on navigation press");- for offset in [1.0, 2.0, 3.0] {+ // The lit mode owns drags, not a press held still (which may be opening Select+ // Other, #8864): the highlight stays until the press drags.+ let lit = button == egui::PointerButton::Primary;+ assert_eq!(app.viewport.hover.is_some(), lit, "hover on a {button:?} press");+ if lit {+ hover_frame(&mut app, &ctx, vec![egui::Event::PointerMoved(p + vec2(1.0, 0.0))]);+ assert!(app.viewport.hover.is_some(), "a press within click distance is still");+ }+ let offsets = if lit { [20.0, 21.0, 22.0] } else { [1.0, 2.0, 3.0] };+ for offset in offsets {hover_frame(&mut app, &ctx, vec![egui::Event::PointerMoved(p + vec2(offset, 0.0))]);assert!(app.viewport.hover.is_none(), "hover while moving");for _ in 0..3 {