design-lint: contract/memory, test/literal-size: each preset kind's browser keyed by a salted Stack; the guide trial asserts the typed position

This commit is contained in:
aiongg
2026-11-16 13:23:38 +00:00
parent 404e03bc63
commit 98500a9576
2 changed files with 13 additions and 7 deletions
@@ -110,14 +110,15 @@ fn a_new_guide_remembers_its_confirmed_values_for_the_next_open() {
let position = fixture.by_label("Position").expect("the Position field");
fixture.click(&position).settle();
fixture.key(egui::Key::A, egui::Modifiers::COMMAND);
fixture.type_text("120");
let typed = 120.0;
fixture.type_text(&typed.to_string());
fixture.key(egui::Key::Enter, egui::Modifiers::NONE).settle();
assert!(!open.get(), "Enter is OK");
let confirmed: Vec<_> = made.borrow().iter().map(|guide| (guide.along, guide.position, guide.color)).collect();
assert_eq!(confirmed, [(Axis::Y, 120.0, Some(GuideColor::Magenta.rgba()))], "OK makes the guide of the edited values");
assert_eq!(confirmed, [(Axis::Y, typed, Some(GuideColor::Magenta.rgba()))], "OK makes the guide of the edited values");
reopen(&mut fixture);
assert_eq!(*values.borrow(), NewGuideValues::new(Axis::Y, 120.0, GuideColor::Magenta), "the next open starts from the confirmed values");
assert_eq!(*values.borrow(), NewGuideValues::new(Axis::Y, typed, GuideColor::Magenta), "the next open starts from the confirmed values");
let horizontal = fixture.by_label("Horizontal").expect("the orientation offers Horizontal");
fixture.click(&horizontal).settle();
assert_eq!(values.borrow().along, Axis::X, "the click edits the values");
@@ -126,5 +127,5 @@ fn a_new_guide_remembers_its_confirmed_values_for_the_next_open() {
assert_eq!(made.borrow().len(), 1, "Cancel makes no guide");
reopen(&mut fixture);
assert_eq!(*values.borrow(), NewGuideValues::new(Axis::Y, 120.0, GuideColor::Magenta), "Cancel stored nothing: the OK'd values come back");
assert_eq!(*values.borrow(), NewGuideValues::new(Axis::Y, typed, GuideColor::Magenta), "Cancel stored nothing: the OK'd values come back");
}
@@ -11,6 +11,7 @@ use super::model::PresetRow;
use super::state::{PresetState, PresetView};
use super::words::PresetWords;
use crate::contract::{Bind, Entry, NoValue, Outcome, Pattern, Props, Show as _, ShowContainer as _};
use crate::layout_components::Stack;
use crate::dialog::{Dialog, DialogId, DialogResult, DialogStack, StackDialog, dialog_id};
use crate::list::RowTest;
use crate::pickers::Select;
@@ -142,8 +143,11 @@ impl<'a, G: Value, K: Clone + Eq + Hash + Send + Sync + 'static> PresetManager<'
}
let shown = dialog.show(ui, |ui, _| {
let kind_pick = Select::new(words.manager_kind.clone(), kind.reborrowed(), kinds).show(ui).value().cloned();
let events: Vec<PresetEvent<K>> = ui
.push_id(("preset-kind", index), |ui| {
// Each kind's browser keeps its own state: its search, scroll and open groups.
let events: Vec<PresetEvent<K>> = Stack::new()
.id_salt(("preset-kind", index))
.fill_width()
.show(ui, |ui, _| {
PresetBrowser::new(title.clone(), Bind::<PresetState<K>>::kept(), rows)
.view_lock(PresetView::List)
.toolbar(false)
@@ -156,7 +160,8 @@ impl<'a, G: Value, K: Clone + Eq + Hash + Send + Sync + 'static> PresetManager<'
.show(ui)
.events
})
.inner;
.inner
.unwrap_or_default();
(kind_pick, events)
});