From c8d90bb79f14002457078358fa58b335901c14cb Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 5 Dec 2026 10:13:13 -0800 Subject: [PATCH] Edit Toolbar and DWG export keep their behavior on the new craft-libs - Tools panel and toolbars: a click on a toolbar's Edit Toolbar button while the drawer is open beside another toolbar takes the drawer there again. The rail now also reports the button's response from its measuring pass, so the click ran window.editToolbar twice in one frame and the second run closed the drawer. The command runs only from the pass that shows the rail. - DWG export: craft-dwg now also writes R13 and R14. DWG export still offers 2000 to 2018 and refuses R12, R13 and R14 with the same message. - Blend Options: the Ramp test expects the number field to keep its focus when another blend is selected, as SliderField::edit_target keeps it. The draft is still dropped and nothing is committed to the new blend. --- crates/cad/src/dwg.rs | 6 ++++-- crates/ui-egui/src/panels/tests_blend.rs | 4 +++- crates/ui-egui/src/toolbar.rs | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/cad/src/dwg.rs b/crates/cad/src/dwg.rs index 4b9cf7f902..babf160149 100644 --- a/crates/cad/src/dwg.rs +++ b/crates/cad/src/dwg.rs @@ -245,9 +245,11 @@ fn convert(bytes: &[u8]) -> Result { Ok(Converted { dxf, notes: notes.iter().map(|n| worded(n)).collect() }) } -/// Can a DWG file of `version` be written? craft-dwg writes 2000, 2004, 2007, 2010, 2013 and 2018. +/// Can a DWG file of `version` be written? DWG export writes 2000, 2004, 2007, 2010, 2013 and 2018. craft-dwg also +/// writes R13 and R14, which DWG export does not offer yet. pub fn writes(version: crate::DxfVersion) -> bool { - craft_dwg::VERSIONS.iter().any(|(code, _)| *code == version.acadver()) + !matches!(version, crate::DxfVersion::R12 | crate::DxfVersion::R13 | crate::DxfVersion::R14) + && craft_dwg::VERSIONS.iter().any(|(code, _)| *code == version.acadver()) } /// A DWG file of `version` from `dxf`, an ASCII DXF of that version as [`crate::export_drawings`] diff --git a/crates/ui-egui/src/panels/tests_blend.rs b/crates/ui-egui/src/panels/tests_blend.rs index 936d6355a2..b43eb606ad 100644 --- a/crates/ui-egui/src/panels/tests_blend.rs +++ b/crates/ui-egui/src/panels/tests_blend.rs @@ -634,7 +634,9 @@ fn a_secondary_press_on_ramp_while_selecting_another_blend_drops_its_draft_witho Event::PointerMoved(ramp), Event::PointerButton { pos: ramp, button: PointerButton::Secondary, pressed: true, modifiers: Modifiers::NONE }, ]); - assert!(!p.focused_role("Ramp:", Role::SPIN_BUTTON), "a secondary press does not focus Ramp's number field"); + // The number field keeps the focus it had while the draft was typed: a new edit target drops the draft, not the + // focus, and a secondary press moves neither. + assert!(p.focused_role("Ramp:", Role::SPIN_BUTTON), "Ramp's number field keeps the focus"); assert!(!p.focused_role("Ramp:", Role::SLIDER), "a secondary press does not focus Ramp's track"); p.frame_with(vec![Event::PointerButton { pos: ramp, button: PointerButton::Secondary, pressed: false, modifiers: Modifiers::NONE }]); p.key(Key::Enter, Modifiers::NONE); diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 72a3e4e0c6..f30bdc8bdb 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -507,7 +507,8 @@ fn show_rail(app: &mut VectorcraftApp, ui: &mut Ui, owner: Owner, at: GroupAt, m // Tools without options answer with an error; a double click on one does nothing more. app.run("tool.options", json!({ "tool": tool })).ok(); } - if out.edit_toolbar.as_ref().is_some_and(|button| button.clicked()) { + // A measuring pass of the rail reports the same click as the pass that shows it, and the command toggles the drawer. + if out.edit_toolbar.as_ref().is_some_and(|button| button.clicked()) && !craft::ui::runtime::measure::active(ui.ctx()) { let params = match &owner { Owner::Toolbar(id) => json!({ "toolbar": bar_of(&app.ui, *id).map(|bar| bar.name.clone()) }), _ => json!({}),