mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-27 11:45:55 +00:00
Merge pull request #9400 from dotCooCoo/fix/kinsoku-empty-preset-caption
Kinsoku Shori Sets: show None when the set list is empty
This commit is contained in:
@@ -361,10 +361,11 @@ impl KinsokuDialog {
|
||||
let rows: Vec<PresetRow<String>> = list.iter().map(|s| PresetRow::item(name_of(s).to_owned(), name_of(s), 0)).collect();
|
||||
let mut value = list.get(self.index(list.len())).map(|s| name_of(s).to_owned());
|
||||
let suggestion = new_name(&list, &self.opened);
|
||||
// PLAN: PresetPicker has no placeholder: an empty list shows an empty name field, not "None".
|
||||
let source = PresetSource::listed(&rows);
|
||||
let refuses = |typed: &str| name_problem(&list, typed);
|
||||
let picker = PresetPicker::new(tl!("Kinsoku Set"), Bind::bound(&mut value), &source, Bind::bound(&mut self.picker)).field(PickerField::Name);
|
||||
let picker = PresetPicker::new(tl!("Kinsoku Set"), Bind::bound(&mut value), &source, Bind::bound(&mut self.picker))
|
||||
.field(PickerField::Name)
|
||||
.placeholder(tl!("None"));
|
||||
let out = NamedPresetRow::new(tl!("Kinsoku Set"), picker).suggest_name(suggestion).check_name(NameCheck::of_host(&refuses)).show(ui);
|
||||
self.apply(out.events);
|
||||
|
||||
|
||||
@@ -47,6 +47,21 @@ fn cancel(app: &VectorcraftApp) {
|
||||
app.dialogs().unwrap().with(|h| h.cancel::<KinsokuDialog>(&ctx));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_kinsoku_list_shows_none_in_the_preset_picker() {
|
||||
let mut fixture = craft::ui::testing::Fixture::new(|ui| crate::dialogs::host::window_dialogs(ui.ctx()).with(|host| host.run(ui)));
|
||||
fixture.room(egui::vec2(800.0, 600.0));
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.ui_ctx = Some(fixture.ctx().clone());
|
||||
app.run("file.new", json!({"width": 400, "height": 400})).unwrap();
|
||||
open(&mut app).unwrap();
|
||||
fixture.settle();
|
||||
|
||||
let picker = fixture.by_label("Kinsoku Set").expect("Kinsoku Set picker");
|
||||
assert_eq!(fixture.tree().value_of(picker.node), Some("None"));
|
||||
assert!(picked(&app).is_empty(), "the caption does not select a set");
|
||||
}
|
||||
|
||||
/// Type › Kinsoku Shori Settings… opens on the document's sets; New adds one based on Hard, its
|
||||
/// categories edited in their fields and Add putting in a character by its code point; nothing
|
||||
/// changes until OK, which sets them as one undo step; Cancel leaves them.
|
||||
|
||||
Reference in New Issue
Block a user