Compare commits

...
Author SHA1 Message Date
Martin BallandClaude Opus 5.5 4e5af936c5 #7167: Insert > Icons is as wide as 12 large previews (needs the craft-libs pin bump)
The picker asks for 12 columns. With the craft-libs fix that sizes a content-sized tab strip by its tabs own widths, the dialog is as wide as those columns, not 80% of the window. Test: the first row holds 12 icons and the dialog is narrower than 13.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 00:48:03 +00:00
Martin BallandClaude Opus 5.5 426a97a246 #7167: Icons picker: large previews and the picker keeps its height (needs the craft-libs pin bump)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 00:13:06 +00:00
Martin BallandClaude Opus 5.5 c088eba814 #7167: Insert > Icons keeps one size and place across categories
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 23:29:06 +00:00
2 changed files with 46 additions and 0 deletions
+6
View File
@@ -236,6 +236,9 @@ fn translated_groups() -> std::rc::Rc<Vec<IconPickerGroup<String>>> {
})
}
/// How many icons a row of the Icons dialog holds: the dialog is as wide as they are.
pub(super) const ICONS_COLUMNS: usize = 12;
/// Insert › Icons: the library as a searchable grid with a filter row; Insert runs `insert.icon`.
#[derive(Clone, Default, PartialEq, Serialize, Deserialize)]
pub(crate) struct IconsForm {
@@ -263,8 +266,11 @@ impl WordForm for IconsForm {
fn body(&mut self, ui: &mut Ui, cx: &mut FormCx<'_, '_>, _asks: &mut Vec<Asks>) -> bool {
let groups = translated_groups();
// Large previews, and a picker that keeps its height across categories (#7167).
let out = IconPicker::new(Label::from(tl!("Icons")), Bind::bound(&mut self.picked), groups.as_slice())
.group_display(IconPickerGroups::Filter)
.large_previews()
.columns(ICONS_COLUMNS)
.empty(Label::from(tl!("No icons match your search.")))
.show(ui);
if out.picked.is_some() && out.response.double_clicked() {
+40
View File
@@ -1782,3 +1782,43 @@ fn colour_fields_say_their_label_and_colour_in_the_interface_language() {
assert!(present, "the translated field is {name}");
}
}
/// Insert › Icons keeps its size and place whichever category is picked (#7167): the footer's Cancel button, which
/// stands at the dialog's lower edge, does not move.
#[test]
fn icons_dialog_keeps_its_size_across_categories() {
let mut h = app_harness(app_with("x"));
open_named(&mut h, "icons", json!({}));
h.run_steps(6);
let cancel = |h: &egui_kittest::Harness<'_, WordApp>| h.get_by_role_and_label(egui::accesskit::Role::Button, "Cancel").rect();
let all = cancel(&h);
for category in ["Arrows", "Transport", "All"] {
h.get_by_label(category).click();
h.run_steps(6);
assert_eq!(cancel(&h), all, "the dialog moved or resized on {category}");
}
}
/// Insert › Icons is as wide as its row of large previews (#7167), not as wide as the window lets a dialog be: the
/// first row holds `ICONS_COLUMNS` icons and the next icon starts the second, and the dialog is narrower than one
/// more column.
#[test]
fn icons_dialog_is_as_wide_as_its_columns() {
let mut h = app_harness(app_with("x"));
open_named(&mut h, "icons", json!({}));
h.run_steps(6);
let columns = super::bookmarks::ICONS_COLUMNS;
// All lists the icons category by category.
use wordcraft_render::icon_lib::{Category, ICONS};
let order: Vec<&str> =
Category::ALL.into_iter().flat_map(|c| ICONS.iter().filter(move |icon| icon.category == c)).map(|icon| icon.name).collect();
let tile = |h: &egui_kittest::Harness<'_, WordApp>, at: usize| {
let name = order[at];
h.query_all_by_label(name).last().unwrap_or_else(|| panic!("no tile for {name}")).rect()
};
let (first, last, next) = (tile(&h, 0), tile(&h, columns - 1), tile(&h, columns));
assert_eq!(last.top(), first.top(), "the first row holds {columns} icons");
assert!(next.top() > first.top(), "icon {} starts the second row", columns + 1);
let dialog = h.get_by_role(egui::accesskit::Role::Dialog).rect();
assert!(dialog.width() < (columns + 1) as f32 * first.width(), "the dialog is {} wide for tiles of {}", dialog.width(), first.width());
}