From dba6a3f5b850a2c5fb1159705255c9a026801ee5 Mon Sep 17 00:00:00 2001 From: makesomethingshit Date: Sun, 29 Nov 2026 19:57:06 +0900 Subject: [PATCH] Local variables: halve the Import and Export gap (#2246) --- crates/ui-egui/src/dialogs/variables_panel.rs | 5 ++--- .../src/variables_window_resize_tests.rs | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/dialogs/variables_panel.rs b/crates/ui-egui/src/dialogs/variables_panel.rs index d45aa87e4..0eeaee6c8 100644 --- a/crates/ui-egui/src/dialogs/variables_panel.rs +++ b/crates/ui-egui/src/dialogs/variables_panel.rs @@ -317,9 +317,8 @@ fn header(app: &mut FigApp, ui: &mut Ui, open: &mut bool) { // Import and export, left of Close. let bar = Rect::from_min_max(pos2(r.max.x - 280.0, r.min.y + 10.0), pos2(r.max.x - 40.0, r.max.y - 10.0)); let mut bar = ui.new_child(UiBuilder::new().max_rect(bar).layout(egui::Layout::right_to_left(egui::Align::Center))); - // The window lays itself out without item spacing (set by the caller); the buttons in this bar - // keep the same gap between them as the one between Export and the Close button (#1754). - bar.spacing_mut().item_spacing.x = 16.0; + // The window uses zero item spacing. Keep Import and Export together with a smaller gap (#2246). + bar.spacing_mut().item_spacing.x = 8.0; let export = widgets::button(&mut bar, tr("Export…"), false, true); crate::right::menu_popup(&export).show(|ui| { for (label, format) in [ diff --git a/crates/ui-egui/src/variables_window_resize_tests.rs b/crates/ui-egui/src/variables_window_resize_tests.rs index 71a8ffb0c..4e78ec713 100644 --- a/crates/ui-egui/src/variables_window_resize_tests.rs +++ b/crates/ui-egui/src/variables_window_resize_tests.rs @@ -10,6 +10,28 @@ use crate::live_tests::{flat, texts}; const COUNT: usize = 60; +#[test] +fn import_and_export_are_eight_points_apart_in_local_variables() { + let mut u = Ui::new(Session::new()); + let ctx = u.ctx.clone(); + ctx.enable_accesskit(); + crate::control::handle(&mut u.app, &ctx, "ui.set", &json!({"variables": true})).unwrap(); + u.frame(vec![]); + let nodes = crate::component_swap_default_tests::tree(&mut u); + let bounds = |label| { + nodes + .iter() + .find(|n| n.role() == egui::accesskit::Role::Button && n.label() == Some(label)) + .and_then(|n| n.bounds()) + .unwrap_or_else(|| panic!("missing button bounds for {label}")) + }; + let export = bounds("Export…"); + let close_gap = bounds("Close").x0 - export.x1; + assert!((close_gap - 6.0).abs() < 0.5, "Export and Close should remain 6 pt apart, measured {close_gap} pt"); + let gap = export.x0 - bounds("Import…").x1; + assert!((gap - 8.0).abs() < 0.5, "Import and Export should be 8 pt apart, measured {gap} pt"); +} + /// The window open on a collection of many number variables. fn window() -> Ui { let mut s = Session::new();