Dialogs: compact tile sizing for Insert › Chart type selector (#7456) (#7466)

In Insert › Chart and Change Chart Type dialogs (dialogs_chart.rs),
the chart types TileGrid configured a 3-column gallery without thumbnail
sizing, causing tiles to expand to the default card size (128 pt compact /
160 pt comfortable, resulting in ~132×104 pt cells). This caused the
3-column grid to balloon over ~420 pt in width, crowding the modal dialog.

Configure .thumb_size(ThumbSize::Large).zoom(1.6).aspect(19.0 / 15.0) on
the chart types TileGrid, producing ~76.8×60.6 pt preview pictures in
~85×87 pt cells within a ~280 pt grid, matching pre-refactor parity
(~112×92 pt cells with 76×60 pt preview pictures). Add a regression test
verifying cell and grid bounds.
This commit is contained in:
Lucas Batista Vargas
2026-11-24 00:05:52 +00:00
committed by GitHub
parent e4633540c0
commit cf161d30a3
2 changed files with 19 additions and 1 deletions
+4 -1
View File
@@ -14,7 +14,7 @@ use craft::ui::contract::{
use craft::ui::dialog::DialogId;
use craft::ui::display::Text;
use craft::ui::layout_components::Row;
use craft::ui::list::{ListRow, ThumbAspect};
use craft::ui::list::{ListRow, ThumbAspect, ThumbSize};
// PLAN: assumed `FormCx::accept` (dialogs-w5, S-L285)
use craft::ui::patterns::form_dialogs::FormCx;
use craft::ui::primitives::DataWidth;
@@ -272,6 +272,9 @@ fn chart_grid(ui: &mut Ui, colors: [Color32; 3], form: &mut ChartTypeForm) -> bo
let current = kinds.iter().position(|k| *k == form.kind).unwrap_or(0);
let source = keyed(&positions, |i| *i);
let out = TileGrid::<usize>::new(tl!("Chart types").to_string())
.thumb_size(ThumbSize::Large)
.zoom(1.6)
.aspect(19.0 / 15.0)
.select(SelectMode::Single)
.card_columns(3)
// Every type shows, as in production, so the dialog's body is the one scroll.
+15
View File
@@ -1800,3 +1800,18 @@ fn smartart_layout_cells_keep_productions_size() {
let grid = h.get_by_role_and_label(Role::ListBox, "Layouts").rect();
assert!(grid.height() <= 304.0, "the picker is three 96 pt rows, got {:?}", grid.size());
}
/// #7456: the Insert Chart dialog renders compact chart type tiles in its 3-column gallery,
/// instead of expanding each thumbnail to default card dimensions (~132×104 pt) and ballooning the grid.
#[test]
fn insert_chart_tiles_render_within_compact_bounds() {
use egui::accesskit::Role;
let mut h = app_harness(app_with("Text"));
open_named(&mut h, "insertChart", json!({}));
crate::test_harness::frames(&mut h, 4);
let cell = h.get_by_role_and_label(Role::ListItem, "Clustered Column").rect();
assert!(cell.width() <= 90.0 && cell.height() <= 92.0, "chart tile should be compact (~85×87 pt), got {:?}", cell.size());
let grid = h.get_by_role_and_label(Role::ListBox, "Chart types").rect();
assert!(grid.width() <= 380.0, "3-column chart types grid should not exceed comfortable dialog proportions (~360 pt), got {:?}", grid.size());
}