Merge pull request #9287 from dotCooCoo/fix/asset-export-scale-table-fits

Asset Export: the scale row's fields share the panel's width instead of running past its right edge
This commit is contained in:
BFlat
2026-11-25 18:19:46 +07:00
committed by GitHub
2 changed files with 32 additions and 2 deletions
+3 -2
View File
@@ -73,8 +73,9 @@ pub(crate) const SIZES: [&str; 12] = ["0.5x", "0.75x", "1x", "1.5x", "2x", "3x",
/// The iOS and Android rows (the engine's `mobile` and `density` presets) and their labels.
pub(crate) const PLATFORMS: [(&str, &str); 2] = [("mobile", "iOS"), ("density", "Android")];
/// The columns of the format rows: scale, suffix, format and the remove button.
const COLUMNS: &[ColumnWidth] = &[ColumnWidth::Content; 4];
/// The columns of the format rows: scale, suffix and format share the room the remove button leaves. When the
/// fields cannot narrow that far, the grid stacks the cells.
const COLUMNS: &[ColumnWidth] = &[ColumnWidth::fill(1.0), ColumnWidth::fill(1.0), ColumnWidth::fill(1.0), ColumnWidth::Content];
/// The text of `key` in `fields`, "" when it has none.
fn text<'a>(fields: &'a Map<String, Value>, key: &str) -> &'a str {
@@ -937,6 +937,35 @@ fn tile_menu_rename_opens_the_clicked_assets_inline_field() {
assert_eq!(assets(&mut p.app())[0]["name"], "Renamed");
}
/// In a panel narrower than the scale row's fields at their full length, the row's Scale, Suffix, Format and Remove
/// share the panel's width, and the Save As Preset row under them stays inside it too.
#[test]
fn the_scale_row_fits_the_panel_width() {
use craft::ui::contract::Role;
for width in [300.0, 440.0] {
let (mut app, _, [a, b]) = app(true);
app.run("assets.add", json!({"ids": [a, b]})).unwrap();
let mut p = panel(app);
p.room(egui::vec2(width, 1600.0));
p.frame();
run(&p, "ui.assetExport.savePresetAs", json!({}));
p.frame();
let controls = [
("Scale", p.rect_role("Scale", Role::COMBO_BOX)),
("Suffix", p.rect("Suffix")),
("Format", p.rect_role("Format", Role::COMBO_BOX)),
("Remove", p.rect("Remove")),
("Name:", p.rect_role("Name:", Role::TEXT_INPUT)),
("Cancel", p.rect("Cancel")),
];
// The four controls of the scale row are on one line.
assert_eq!(controls[0].1.center().y, controls[3].1.center().y, "one row at {width}");
for (name, rect) in controls {
assert!(rect.left() >= -0.5 && rect.right() <= width + 0.5, "{name} at {rect:?} is outside a {width} pt panel");
}
}
}
/// The menu adds the selected artwork as one asset or one per object (an object that is an asset already keeps its
/// asset), and is off with no artwork selected.
#[test]