mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 03:17:43 +00:00
print, ui-patterns: name check is public, section list foot, story data borrow
This commit is contained in:
@@ -817,7 +817,7 @@ impl<'a> PrintDialog<'a> {
|
||||
let source = keyed(&titles, |title: &String| title.clone());
|
||||
// PLAN: assumes `SectionList::foot(self, impl FnOnce(&mut Ui) + 'a) -> Self` (type-w6 request on ty.X70).
|
||||
let picked = SectionList::new(words.sections.clone(), &source, current.clone())
|
||||
.foot(preview)
|
||||
.foot(|ui| preview(ui))
|
||||
.show(
|
||||
ui,
|
||||
|title| ListRow::new(Label::from(title.clone())),
|
||||
|
||||
@@ -139,10 +139,11 @@ fn print_dialog_sections_no_sheet(ui: &mut Ui, data: &mut StoryData) -> StoryOut
|
||||
#[story(PrintDialog<'static>, covers = [], drive = Drive::Never)]
|
||||
fn print_dialog_preset_editor(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let sections = [PrintSection::new("Position and Size", vec![Param::number("scale", "Scale", 100.0, 1.0, 0)])];
|
||||
PrintDialog::new(Bind::bound(data.value("settings", Settings::default())), &[], Bind::given(DialogFields::default()))
|
||||
let (settings, name) = data.value("editor", (Settings::default(), "Default".to_owned()));
|
||||
PrintDialog::new(Bind::bound(settings), &[], Bind::given(DialogFields::default()))
|
||||
.layout(PrintLayout::Sections)
|
||||
.mode(PrintMode::PresetEditor)
|
||||
.preset_name(Bind::bound(data.value("name", "Default".to_owned())))
|
||||
.preset_name(Bind::bound(name))
|
||||
.check_name(|name| name.eq_ignore_ascii_case("Default").then_some(PresetError::NameTaken))
|
||||
.sections(§ions)
|
||||
.show(ui)
|
||||
|
||||
@@ -74,7 +74,8 @@ impl<'a> NameCheck<'a> {
|
||||
}
|
||||
|
||||
impl NameCheck<'_> {
|
||||
fn refuses(&self, name: &str) -> Option<PresetError> {
|
||||
/// The refusal of `name`, `None` when the host accepts it.
|
||||
pub fn refuses(&self, name: &str) -> Option<PresetError> {
|
||||
(self.0)(name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user