LRC-LIB-KEYWORDS: Edit Keyword Set's fields are alike

The nine fields took their width from what the dialog had while it
found its size: the first two columns came out squeezed ("ceremony"
showed "ceren") and the third wide. They are now equal columns of a
set width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nathaniel Ledford
2026-10-09 15:59:15 -04:00
co-authored by Claude Opus 5.5
parent 68c1e78c1b
commit bbf2515c20
2 changed files with 17 additions and 2 deletions
+3 -2
View File
@@ -787,8 +787,9 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {
ui.add_space(6.0);
ui.label(egui::RichText::new(crate::i18n::tr("Keywords (⌥1–⌥9)")).color(t.text_dim));
slots.resize(9, String::new());
let w = ((ui.available_width() - 8.0) / 3.0).floor().max(60.0);
egui::Grid::new("keyword-set-slots").num_columns(3).spacing([4.0, 4.0]).show(ui, |ui| {
// equal columns of a set width (the window is still finding its own)
let w = 130.0;
egui::Grid::new("keyword-set-slots").num_columns(3).min_col_width(w).spacing([6.0, 4.0]).show(ui, |ui| {
for (i, slot) in slots.iter_mut().enumerate() {
let r = crate::text_field::TextField::singleline(&format!("field:keywordSetSlot:{}", i + 1), slot)
.hint(format!("⌥{}", i + 1))
+14
View File
@@ -97,3 +97,17 @@ fn an_empty_slot_is_an_idle_button() {
h.settle(SETTLE);
assert!(h.app.widgets.iter().any(|(w, _)| w == "kwSetEmpty:2"), "slot 2 is shown empty");
}
/// The nine fields are alike and wide enough for a keyword: a grid of equal columns, not one sized
/// by what the window had room for while it found its size.
#[test]
fn the_slots_are_alike() {
let mut h = keywords_panel();
open_editor(&mut h);
let slots: Vec<egui::Rect> =
(1..=9).map(|i| h.app.widgets.iter().find(|(w, _)| *w == format!("field:keywordSetSlot:{i}")).map(|(_, r)| *r).expect("slot")).collect();
for r in &slots {
assert!(r.width() >= 100.0, "{r:?}");
assert!((r.width() - slots[0].width()).abs() < 1.0, "{r:?} vs {:?}", slots[0]);
}
}