Merge pull request #2653 from storytold/fix/2572-variables-window-resize

M3: a test guards that a wider Local variables window shows more mode columns (#2572)
This commit is contained in:
BFlat authored and GitHub committed 2026-11-27 17:03:40 +07:00
commit 2fa2f202fd
2 files changed
+34 -1

No files matched your search

@@ -1,5 +1,5 @@
//! The Local variables window resizes from its edges and corners, height as well as width, stops at
//! a minimum size, and keeps its size when it is closed and opened again (#2354).
//! a minimum size, and keeps its size when it is closed and opened again (#2354); wider, it shows more mode columns (#2572).
use egui::{Event, Id, Pos2, Rect, vec2};
use figcraft_engine::Session;
@@ -123,3 +123,35 @@ fn a_resized_variables_window_keeps_its_size_when_reopened() {
let again = rect(&u);
assert!((again.width() - resized.width()).abs() < 1.0 && (again.height() - resized.height()).abs() < 1.0, "{resized:?} -> {again:?}");
}
/// How many mode column headings of the table are in view (painted inside their clip, which the
/// table's scroll area sets).
fn mode_columns(u: &mut Ui) -> usize {
let window = rect(u);
let out = u.frame_output(vec![]);
out.shapes
.iter()
.filter(|c| matches!(&c.shape, egui::Shape::Text(t) if t.galley.text().starts_with("Mode ") && c.clip_rect.contains(t.pos) && window.contains(t.pos)))
.count()
}
#[test]
fn a_wider_variables_window_shows_more_mode_columns() {
let mut s = Session::new();
s.execute("variable.createCollection", &json!({"name": "Theme"})).unwrap();
s.execute("variable.create", &json!({"collection": "Theme", "name": "v00", "type": "number", "value": 1})).unwrap();
for k in 2..=6 {
s.execute("variable.addMode", &json!({"collection": "Theme", "name": format!("Mode {k}")})).unwrap();
}
let mut u = Ui::new(s);
u.app.ui.variables = Some(Default::default());
for _ in 0..10 {
u.frame(vec![]);
}
let before = mode_columns(&mut u);
let room = u.screen.x - rect(&u).max.x - 20.0;
drag_corner(&mut u, vec2(room, 0.0));
let after = mode_columns(&mut u);
assert!(after > before, "the wider table shows more mode columns: {before} -> {after}");
assert!(after < 6, "the rest of the six modes scroll into view: {after} shown");
}
+1
View File
@@ -91,6 +91,7 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`.
| 2026-11-18 | patch | M3: enabled libraries were read only while the Assets panel showed, so after a file was opened the Design panel's style pickers offered none of their styles (a library's text styles read "No text styles yet") until the Assets tab had been opened. They are refreshed from the app's background tick now, a local library not read yet at once. The style picker has a source menu under its search field, as in Figma: All libraries (the default), This file, or one enabled library. Test: `style_picker::tests::a_reopened_files_text_styles_picker_lists_its_librarys_styles_without_the_assets_tab` |
| 2026-11-23 | patch | M3, #2569: `library.swap {from, to}` removes `from`'s copies that nothing in the file uses before it starts (a component imported with `library.import` but not placed, a variable imported but not bound), as `library.remove` does, but its result didn't say so: `{"components": 0, "unmatched": [], "removed": true}` after an imported component had been deleted. The result now names them in `dropped` (`component auth-button`, `variable Theme/accent`, `collection Theme`), apart from copies that went because what used them moved to `to`. Test: `library_swap/tests.rs` (`swap_lists_the_unused_copies_it_removes`) |
| 2026-11-27 | minor | M3, #2633: variables in the Local variables window stayed in creation order. A row's menu has Move up and Move down (Alt+↑ / Alt+↓ with one row selected), moving it past its neighbour in its group; a collection's and a group's menus have Sort A to Z and Sort Z to A, by name with each run of digits compared as a number, so `50, 100, 200 … 950` come in that order. The order is the stored one, so files, exports and the variable pickers follow it. New commands `variable.move {variables, before?}` and `variable.sort {collection, group?, descending?}`, one undo step each. Drag to reorder is not built. Tests: `variables_editor_tests::moving_variables_reorders_their_collection_only_and_undoes`, `variables_editor_tests::sorting_orders_numbers_by_value_within_the_group_asked`. Grade unchanged. |
| 2026-11-27 | patch | M3, #2572: a test guards that dragging the Local variables window wider shows more mode columns, each still 200 points wide, while the columns that do not fit scroll sideways. The resizing itself came with #2354 (after v0.18.1). Test: `variables_window_resize_tests.rs`. |
| 2026-11-23 | patch | M3, #2568: `library.swap {from, to}` re-pointed style links and variable bindings only on layers outside the read-only library copies. A copy the swap keeps (a component of `from` that `to` has no match for, or another library's component using `from`'s style) kept `from`'s style and variable, so instances placed after the swap showed the old colours while those placed before showed the new ones. The swap now re-points the copies' own layers too, with the same maps, and `from`'s style and variable copies that nothing links any more go. A layer's explicit mode for one of `from`'s collections stays next to `to`'s while a variable of that collection is left on `from` (no match), so that variable keeps its mode instead of falling back to the default. Tests: `library_swap/tests.rs` (`swap_repoints_the_styles_and_variables_of_component_copies_it_keeps`, `swap_keeps_the_mode_of_a_collection_that_still_has_a_variable_on_the_old_library`) |
| 2026-11-19 | patch | M3, #2414: a kit's style used by a component of a second library reached a file linking both as a second, unbound copy (`<auth>:<kit>:S:1`) frozen in the kit's default mode, so a mode set on the kit's collection didn't colour it (from two hops on, every such style). Publishing now keeps the variables the published styles bind and where the file's copies of other libraries' styles, variables and collections came from; importing files such a copy under that library when the file links it, so it is the file's own bound copy. Test: `library_style_hops_tests::a_kit_style_through_another_library_is_the_kits_bound_copy`; the issue's four-file chain renders Brand and Alt everywhere. Grade unchanged. |
| 2026-11-19 | patch | M3, #2349: with one variant of a set selected, the Design panel's variant property dropdowns showed the set's default values, and choosing a value set the default, so the variants swapped places. They now show the selected variant's own values (hover: "This variant's value"), and choosing one renames that variant only; with the set selected they still set its default. Test: `variant_own_value_tests::a_selected_variants_dropdown_shows_and_sets_its_own_value`. Grade unchanged. |