Merge pull request #2730 from makesomethingshit/fix/2246-variables-header-gap

Local variables: halve the Import and Export gap (#2246)
This commit is contained in:
BFlat authored and GitHub committed 2026-11-29 18:05:09 +07:00
commit ae35ddb4aa
2 files changed
+24 -3

No files matched your search

@@ -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 [
@@ -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();