From 34e96f9325bafa4e7c7d0fe3774c177e1d90712d Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 19:38:28 +0700 Subject: [PATCH] ui-panels footer: DialogButtonLook::Filled shows Cancel, Other, Alternate and Alternative as the filled neutral button (buttons::FILLED, now public: surface.control with no edge, state.hover under the pointer) beside the accented answer. Footer story and trial under Filled --- crates/ui-panels/src/sections/footer.rs | 12 +++++++--- .../ui-panels/src/sections/footer/stories.rs | 22 ++++++++++++++++++- crates/ui-panels/tests/it/dialogs.rs | 11 ++++++++++ crates/ui-widgets/src/buttons/mod.rs | 5 +++-- 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/crates/ui-panels/src/sections/footer.rs b/crates/ui-panels/src/sections/footer.rs index 581ee146e..40427888a 100644 --- a/crates/ui-panels/src/sections/footer.rs +++ b/crates/ui-panels/src/sections/footer.rs @@ -392,6 +392,9 @@ pub enum DialogButtonLook { /// PdfCraft's: Cancel and an Alternate answer (Don't Save, No) are plain text (the ghost look) beside the accented /// accepting button, as production's prompts show them. Quiet, + /// VectorCraft's: every button but the accepting and the destructive one is a filled neutral tile with no edge + /// (`buttons::FILLED`). + Filled, } /// What a dialog button means; it decides the button's look and its place in the row. @@ -719,7 +722,7 @@ impl FooterBar { let armed_for = Env::of(&*ui).get::().0; let default_at = buttons.iter().position(|button| button.role == DialogRole::Accept && button.live(armed_for)); let least = if column { LeastWidth::DialogSideButton } else { LeastWidth::DialogButton }; - let quiet = Env::of(ui).get::() == DialogButtonLook::Quiet; + let look = Env::of(ui).get::(); let place = |ui: &mut Ui, shown: &mut Shown| { for at in display_order(&roles, os == Os::Windows, column) { let button = &buttons[at]; @@ -727,8 +730,11 @@ impl FooterBar { DialogRole::Accept => Variant::PRIMARY, DialogRole::Destructive => Variant::DANGER, // Production shows Cancel and Don't Save as plain text beside the accented answer. - DialogRole::Cancel | DialogRole::Alternate if quiet => Variant::GHOST, - DialogRole::Cancel | DialogRole::Other | DialogRole::Alternate | DialogRole::Alternative => Variant::SECONDARY, + DialogRole::Cancel | DialogRole::Alternate if look == DialogButtonLook::Quiet => Variant::GHOST, + DialogRole::Cancel | DialogRole::Other | DialogRole::Alternate | DialogRole::Alternative => match look { + DialogButtonLook::Filled => crate::buttons::FILLED, + DialogButtonLook::Standard | DialogButtonLook::Quiet => Variant::SECONDARY, + }, }; let live = button.live(armed_for); let mut widget = Button::new(button.label.clone()).variant(variant).enabled(live).least_width(least); diff --git a/crates/ui-panels/src/sections/footer/stories.rs b/crates/ui-panels/src/sections/footer/stories.rs index 5801a5ec4..8f82fd707 100644 --- a/crates/ui-panels/src/sections/footer/stories.rs +++ b/crates/ui-panels/src/sections/footer/stories.rs @@ -1,8 +1,9 @@ //! Stories of the footer actions. -use super::{DropAction, FooterAction, FooterBar}; +use super::{DialogButtonLook, DialogRole, DropAction, FooterAction, FooterBar, FooterButton}; use crate::buttons::IconButton; use crate::contract::{PopupKind, Props as _, Show as _, ShowContainer as _}; +use crate::runtime::env::with_env; use crate::story_kit::sample::words; use crate::testing::{Drive, StoryData, StoryOutput, story}; use craft_behavior::IconId; @@ -24,6 +25,25 @@ fn footer_actions(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { FooterBar::actions(actions).show_footer(ui).into() } +/// The dialog buttons of an app that sets `DialogButtonLook::Filled` at its root: Cancel, the Alternate answer and +/// another outcome are filled neutral tiles with no edge beside the accented OK, at rest, under the pointer and pressed. +#[story(FooterBar, covers = [], drive = Drive::Never, title = "Filled dialog buttons")] +fn footer_filled_buttons(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { + let buttons = [ + FooterButton::new("Reset", DialogRole::Other), + FooterButton::new("Don't Save", DialogRole::Alternate), + FooterButton::new("Cancel", DialogRole::Cancel), + FooterButton::new("OK", DialogRole::Accept), + ]; + with_env( + ui, + |overrides| { + overrides.values.set(DialogButtonLook::Filled); + }, + |ui| FooterBar::buttons(buttons).show_footer(ui).into(), + ) +} + #[story(DropAction, covers = [Default], drive = Drive::Never)] fn drop_action(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { DropAction::new(|_: &u8| true) diff --git a/crates/ui-panels/tests/it/dialogs.rs b/crates/ui-panels/tests/it/dialogs.rs index 5f5d416f8..2d4b3c919 100644 --- a/crates/ui-panels/tests/it/dialogs.rs +++ b/crates/ui-panels/tests/it/dialogs.rs @@ -738,6 +738,17 @@ fn a_footer_cancel_is_a_ghost_button_beside_the_accent_answer() { assert!(!seen.contains(&Variant::SECONDARY), "no outlined button in the footer: {seen:?}"); } +/// VectorCraft's dialogs (`DialogButtonLook::Filled`) show Cancel and Don't Save as filled neutral tiles beside the +/// accented answer, not as outlines. +#[trial] +fn a_footer_cancel_is_a_filled_button_beside_the_accent_answer() { + use craft_theme::Variant; + let seen = footer_variants(Some(craft_ui::sections::DialogButtonLook::Filled)); + assert!(seen.contains(&craft_ui::buttons::FILLED), "Cancel is a filled button: {seen:?}"); + assert!(seen.contains(&Variant::PRIMARY), "Save is the accented button: {seen:?}"); + assert!(!seen.contains(&Variant::SECONDARY), "no outlined button in the footer: {seen:?}"); +} + /// The left edges of a Save anyway / Save as… / Cancel prompt's buttons on Linux, with the Alternate's role set to /// `role` when it names one. fn alternate_edges(role: Option) -> (f32, f32, f32) { diff --git a/crates/ui-widgets/src/buttons/mod.rs b/crates/ui-widgets/src/buttons/mod.rs index 7e4234f16..946b5939d 100644 --- a/crates/ui-widgets/src/buttons/mod.rs +++ b/crates/ui-widgets/src/buttons/mod.rs @@ -91,8 +91,9 @@ pub enum PushButtonLook { Filled, } -/// The filled neutral variant a push button takes under [`PushButtonLook::Filled`]. -pub(crate) const FILLED: craft_theme::Variant = craft_theme::Variant::look(craft_theme::Emphasis::Filled, craft_theme::variant::Tone::Neutral); +/// The filled neutral variant a push button takes under [`PushButtonLook::Filled`]: `surface.control` with no edge at +/// rest. +pub const FILLED: craft_theme::Variant = craft_theme::Variant::look(craft_theme::Emphasis::Filled, craft_theme::variant::Tone::Neutral); /// The variant a push or split button that asks for none takes in `env` (`Component::default_variant`): the filled one /// under [`PushButtonLook::Filled`], outside a ribbon.