diff --git a/crates/ui-egui/src/dialogs/revolve_lights.rs b/crates/ui-egui/src/dialogs/revolve_lights.rs index 4da63692a2..40ef6f2199 100644 --- a/crates/ui-egui/src/dialogs/revolve_lights.rs +++ b/crates/ui-egui/src/dialogs/revolve_lights.rs @@ -423,9 +423,12 @@ pub(crate) fn sphere(ui: &mut egui::Ui, fields: &mut DialogFields, cx: &mut Cust if let Some(index) = out.picked { select(fields, index); } - // What each event leaves in the lights, a cancel's restored start included. + // What each event leaves in the lights, a cancel's restored start included, each from where the one before left + // them (Down then Up in one pass lands back where it began). + let mut from = list.clone(); for lights in out.edit.events.iter().filter_map(|event| event.landed()) { - write_moved(fields, &list, lights); + write_moved(fields, &from, lights); + from.clone_from(lights); } let current = selected(fields, list.len()); let behind = list.get(current).is_some_and(|l| l.behind); diff --git a/crates/ui-egui/src/panels/tests_three_d.rs b/crates/ui-egui/src/panels/tests_three_d.rs index 54d18b2f22..e48b3b2b68 100644 --- a/crates/ui-egui/src/panels/tests_three_d.rs +++ b/crates/ui-egui/src/panels/tests_three_d.rs @@ -763,7 +763,11 @@ fn the_graphics_frame_is_built_once_for_each_revision() { } /// `app` with the graphics' handles over an 800 × 600 canvas, and the handle the trial reads the app through. -fn handles_fixture(app: VectorcraftApp) -> (Rc>, Fixture) { +fn handles_fixture(mut app: VectorcraftApp) -> (Rc>, Fixture) { + // The handles show while the 3D and Materials panel shows its Materials tab. + if !crate::panel_docking::visible(&app, super::ID) { + app.run("window.panel", json!({ "panel": super::ID })).unwrap(); + } let app = Rc::new(RefCell::new(app)); let drawn = Rc::clone(&app); let mut fixture = Fixture::new(move |ui| { diff --git a/crates/ui-egui/src/panels/three_d.rs b/crates/ui-egui/src/panels/three_d.rs index 83af207e4b..45371c70ea 100644 --- a/crates/ui-egui/src/panels/three_d.rs +++ b/crates/ui-egui/src/panels/three_d.rs @@ -242,6 +242,8 @@ pub(crate) fn send(app: &mut VectorcraftApp, changed: Map, phase: /// document moved under the gesture, or the panel was removed (the gesture commits as one step). pub(crate) fn apply(app: &mut VectorcraftApp, params: &[Param], input: &DialogFields, events: &EditEvents) { let settings = |fields: &DialogFields| Value::Object(form::json_of(params, fields)); + // The one-step changes of a pass (several key presses in one frame) are one undo step, to where the last left them. + let mut set = None; for event in events { match event { EditEvent::Begin { id, .. } => { @@ -259,7 +261,7 @@ pub(crate) fn apply(app: &mut VectorcraftApp, params: &[Param], input: &DialogFi let changed = changed_settings(&app.three_d.before, &settings(after)); send(app, changed, Live::Released); } - EditEvent::Set { after, .. } => send(app, changed_settings(&settings(input), &settings(after)), Live::Released), + EditEvent::Set { after, .. } => set = Some(after), EditEvent::Cancel { reason, .. } => { if matches!(reason, CancelReason::Removed) || reason.document_moved() { send(app, Map::new(), Live::Released); @@ -270,6 +272,9 @@ pub(crate) fn apply(app: &mut VectorcraftApp, params: &[Param], input: &DialogFi _ => {} } } + if let Some(after) = set { + send(app, changed_settings(&settings(input), &settings(after)), Live::Released); + } } /// The 3D and Materials panel.