mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 02:09:00 +00:00
ui-patterns: warnings of the forms set, list manager and PDF trials follow the contract
This commit is contained in:
@@ -522,7 +522,7 @@ impl<'a> ParamDialog<'a> {
|
||||
// The footer rows' buttons follow the extra buttons. A button's label cannot change inside the pass that
|
||||
// draws it, so it shows the state the previous pass left.
|
||||
let footer_rows: Vec<&Param> = params.iter().filter(|param| param.footer_on().is_some()).collect();
|
||||
let footer_id = egui::Id::new(("paramDialog.footer", key.as_str()));
|
||||
let footer_id = egui::Id::unique(("paramDialog.footer", key.as_str()));
|
||||
let flip_id = footer_id.with("flip");
|
||||
let footer_states: Vec<bool> = if footer_rows.is_empty() { Vec::new() } else { ui.data(|data| data.get_temp(footer_id)).unwrap_or_default() };
|
||||
let footer_buttons = footer_rows.iter().enumerate().map(|(at, param)| {
|
||||
|
||||
@@ -584,11 +584,6 @@ impl RowOptions {
|
||||
self.resettable
|
||||
}
|
||||
|
||||
/// The label a footer row shows while on; `Some` for a row drawn in the footer.
|
||||
pub(crate) fn footer_on(&self) -> Option<&Label> {
|
||||
self.footer_on.as_ref()
|
||||
}
|
||||
|
||||
/// The lengths a number row keeps and shows.
|
||||
pub(crate) fn length(&self) -> Option<LengthUnits> {
|
||||
self.length
|
||||
@@ -994,7 +989,7 @@ impl Param {
|
||||
/// The row is shown only while `fields[key]` equals `value`, as [`enabled_when`](Param::enabled_when) enables it;
|
||||
/// otherwise it takes no space. Its value stays in the fields and in the result.
|
||||
#[must_use]
|
||||
pub fn visible_when(mut self, key: impl Into<String>, value: impl Into<FieldValue>) -> Self {
|
||||
pub fn visible_when(self, key: impl Into<String>, value: impl Into<FieldValue>) -> Self {
|
||||
self.visible_when_in(key, [value])
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
//! `ListManager`'s in-place rename: a commit is a choice, Escape and an entry of another kind are not.
|
||||
|
||||
use craft_ui::contract::Bind;
|
||||
use craft_ui::patterns::form_dialogs::{ActionEnabled, ListManager, ListManagerAction, ListManagerChoice, ListManagerEntry};
|
||||
use craft_ui::patterns::form_dialogs::{ListManager, ListManagerAction, ListManagerChoice, ListManagerEntry, ListManagerWords};
|
||||
use craft_ui::runtime::env::Env;
|
||||
use craft_ui::testing::{Fixture, trial};
|
||||
use egui::{Key, Modifiers, Vec2};
|
||||
use std::cell::{Cell, RefCell};
|
||||
@@ -19,7 +20,7 @@ fn a_committed_rename_reports_entry_and_name_and_escape_keeps_it() {
|
||||
let (held, seen, ended) = (Rc::clone(&rows), Rc::clone(&choices), Rc::clone(&closed));
|
||||
let mut fixture = Fixture::new(move |ui| {
|
||||
let entries = held.borrow().clone();
|
||||
let actions = vec![ListManagerAction::new("run", "Run", ActionEnabled::OnEntry { kind: None })];
|
||||
let actions = vec![ListManagerAction::run(&Env::of(ui).words::<ListManagerWords>())];
|
||||
let out = ListManager::new("Macros", "Macro name:", entries, actions).renames(1).opened(Bind::given(true)).show(ui);
|
||||
ended.set(ended.get() || out.closed.is_some());
|
||||
if let Some(choice) = out.choice {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The hosted Save PDF dialog on a `DialogHost`: the fields automation lists and sets, Alt-Reset, and the Summary text.
|
||||
|
||||
use craft_pdf::settings::{Choice, Compatibility, PdfPreset, PdfSettings, Standard};
|
||||
use craft_pdf::settings::{Compatibility, PdfPreset, PdfSettings, Standard};
|
||||
use craft_ui::dialog::{DialogHost, DialogId};
|
||||
use craft_ui::patterns::form_dialogs::{HostedPdfExport, PdfExportWords, summary_text};
|
||||
use craft_ui::runtime::env::Env;
|
||||
|
||||
Reference in New Issue
Block a user