mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 04:27:49 +00:00
look-rest-2: LeastWidth::WideDialog and Dialog::least_width; the listed About is a wide dialog, as WordCraft's; trial
This commit is contained in:
@@ -200,6 +200,9 @@ pub enum LeastWidth {
|
||||
DialogSideButton,
|
||||
/// `size.rail.width` per column: a tool rail of this many columns, as wide as the shell slot that holds it.
|
||||
Rail(std::num::NonZeroU8),
|
||||
/// `size.dialog.least` and `size.dialog.wrap` together: a wide dialog, as wide as a dialog's least content beside a
|
||||
/// paragraph's line (an About dialog whose tabs hold credit tables).
|
||||
WideDialog,
|
||||
/// Five `size.rail.width`: a page's side menu (a File page's list of pages), wide enough that its rows read as a
|
||||
/// band beside the page, not as buttons cut to their labels.
|
||||
SideMenu,
|
||||
@@ -214,6 +217,7 @@ impl LeastWidth {
|
||||
LeastWidth::DialogButton => tokens.size.dialog.button,
|
||||
LeastWidth::DialogSideButton => tokens.size.dialog.side_button,
|
||||
LeastWidth::Rail(columns) => tokens.size.rail.width * f32::from(columns.get()),
|
||||
LeastWidth::WideDialog => tokens.size.dialog.least + tokens.size.dialog.wrap,
|
||||
LeastWidth::SideMenu => tokens.size.rail.width * 5.0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,6 +245,14 @@ impl<'a> Dialog<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
/// The least width of the dialog's content from the size role `least`, in place of `size.dialog.least`: a wide
|
||||
/// dialog (`LeastWidth::WideDialog`) whose tabs hold tables.
|
||||
#[must_use]
|
||||
pub fn least_width(mut self, least: crate::contract::LeastWidth) -> Self {
|
||||
self.props = self.props.least_width(least);
|
||||
self
|
||||
}
|
||||
|
||||
/// The dialog reports the alert-dialog role instead of the dialog role.
|
||||
#[must_use]
|
||||
pub(super) fn alert(mut self) -> Self {
|
||||
|
||||
@@ -13,8 +13,8 @@ use crate::buttons::{Button, IconButton, Link};
|
||||
use crate::choice::Segmented;
|
||||
use crate::contract::Gap;
|
||||
use crate::contract::{
|
||||
Bind, CollectionEvent, ColumnEvent, ColumnSort, ColumnSpec, Entry, NoValue, Outcome, Props as _, Remember as _, Scroll, SelectMode, Show as _,
|
||||
ShowCollection as _, ShowContainer as _, clicked,
|
||||
Bind, CollectionEvent, ColumnEvent, ColumnSort, ColumnSpec, Entry, LeastWidth, NoValue, Outcome, Props as _, Remember as _, Scroll, SelectMode,
|
||||
Show as _, ShowCollection as _, ShowContainer as _, clicked,
|
||||
};
|
||||
use crate::dialog::{Dialog, DialogId, DialogOutput, DialogResult, DialogStack, FieldRefusal, StackDialog, dialog_id};
|
||||
use crate::display::{Divider, Shade, Text};
|
||||
@@ -298,6 +298,10 @@ impl<'a> AboutDialog<'a> {
|
||||
if let Some(open) = open {
|
||||
dialog = dialog.opened(open);
|
||||
}
|
||||
// The listed layout is a wide dialog, as WordCraft's About, whose tabs hold the credit tables.
|
||||
if layout == AboutLayout::Listed {
|
||||
dialog = dialog.least_width(LeastWidth::WideDialog);
|
||||
}
|
||||
let shown_dialog = dialog.show(ui, |ui, cx| {
|
||||
let mut kept = if cx.appeared() { View::default() } else { cx.memory::<View>().clone() };
|
||||
// A bound tab is the caller's each pass, so a tab set from outside shows on the next pass.
|
||||
|
||||
@@ -71,6 +71,22 @@ fn the_listed_about_tab_stands_one_item_to_a_line_and_closes_with_close() {
|
||||
assert_eq!(links.borrow().as_slice(), ["https://example.org".to_owned()]);
|
||||
}
|
||||
|
||||
/// The listed layout is a wide dialog (`LeastWidth::WideDialog`), as WordCraft's About: wider than the centred one
|
||||
/// with the same text.
|
||||
#[trial]
|
||||
fn the_listed_about_is_a_wide_dialog() {
|
||||
let width = |layout: AboutLayout| {
|
||||
let mut fixture = Fixture::new(move |ui| {
|
||||
let info = AboutInfo::new("PhotoCraft", "An image editor.", "1.0");
|
||||
let _ = AboutDialog::new(&info, &CREDITS).layout(layout).show(ui);
|
||||
});
|
||||
fixture.room(Vec2::new(1400.0, 1000.0)).idle(30);
|
||||
fixture.by_role(Role::DIALOG).first().expect("the dialog shows").rect.width()
|
||||
};
|
||||
let (listed, centred) = (width(AboutLayout::Listed), width(AboutLayout::Centred));
|
||||
assert!(listed > centred + 200.0, "the listed About is a wide dialog: {listed} against {centred}");
|
||||
}
|
||||
|
||||
#[trial]
|
||||
fn about_tab_is_a_field() {
|
||||
let host = Rc::new(RefCell::new(DialogHost::new()));
|
||||
|
||||
Reference in New Issue
Block a user