From 53da45bbe4c16eadaa04286577c5f686dbe04bdc Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 21 Nov 2026 21:28:06 +0700 Subject: [PATCH] plugins-w1: net change of 1 commits - plugins-w1: written from its sheet --- crates/ui-canvas/src/canvas/crop/mod.rs | 12 ++++++------ crates/ui-contract/src/runtime/env/units.rs | 11 +++++------ crates/ui-panels/src/dialog/prompt/stories.rs | 13 ++++++++++++- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/crates/ui-canvas/src/canvas/crop/mod.rs b/crates/ui-canvas/src/canvas/crop/mod.rs index c9b6b1a52b..c4b439da3f 100644 --- a/crates/ui-canvas/src/canvas/crop/mod.rs +++ b/crates/ui-canvas/src/canvas/crop/mod.rs @@ -282,9 +282,6 @@ fn size_row(cx: &Cx<'_, CropOverlay<'_>>, space: &CanvasSpace, (w, h): (f64, f64 vec![(Label::from(words.crop_width.as_str().to_owned()), text(x, w)), (Label::from(words.crop_height.as_str().to_owned()), text(y, h))] } -fn angle_row(cx: &Cx<'_, CropOverlay<'_>>, degrees: f64) -> Vec<(Label, String)> { - readout::angle_row(&cx.words::(), &cx.env.units(), degrees) // P3(plugins-w1): cv.F8 -} impl CropOverlay<'_> { /// Starts the drag of `grab` pressed at screen point `origin`. @@ -316,11 +313,12 @@ impl CropOverlay<'_> { *to = rules.snap_screen(&view, pos, mods); self.report.dragging = true; if let Some(degrees) = gesture::line_degrees(*from, *to) { - readout(cx, pos, &angle_row(cx, degrees)); + readout(cx, pos, &readout::angle_row(&cx.words::(), &cx.env.units(), degrees)); } return; } - let held_space = crate::runtime::keys::down(&cx.ctx).contains(&Key::Space); + // PLAN: pl.F1's `held` is typed `Vec` at the stub; shortcuts-w2 must return `craft_keymap::Key` for this compare. + let held_space = crate::runtime::keys::held(&cx.ctx).contains(&Key::Space); let to = drag.press_view.as_ref().unwrap_or(&view).to_doc(pos); let (to, lines) = rules.snapped(drag, &view, to, mods, held_space); self.report.snapped = lines; @@ -343,7 +341,9 @@ impl CropOverlay<'_> { _ => {} } let rows = match drag.kind { - Kind::Turn { .. } => angle_row(cx, gesture::turn_degrees(&drag.last, self.image_mode)), + Kind::Turn { .. } => { + readout::angle_row(&cx.words::(), &cx.env.units(), gesture::turn_degrees(&drag.last, self.image_mode)) + } Kind::Draw { .. } | Kind::Resize(_) => drag.last.crop_size().map(|size| size_row(cx, space, size)).unwrap_or_default(), _ => Vec::new(), }; diff --git a/crates/ui-contract/src/runtime/env/units.rs b/crates/ui-contract/src/runtime/env/units.rs index e94678d3c0..31f0e74ea8 100644 --- a/crates/ui-contract/src/runtime/env/units.rs +++ b/crates/ui-contract/src/runtime/env/units.rs @@ -55,9 +55,7 @@ craft_ui::words! { yards_name: "units.yardsName" = "Yards"; metres_name: "units.metresName" = "Metres"; q_name: "units.qName" = "Q"; - ha_name: "units.haName" = "H"; - letters_name: "units.lettersName" = "Letters"; - hyphens_name: "units.hyphensName" = "Hyphens"; + ha_name: "units.haName" = "Ha"; } } @@ -151,7 +149,8 @@ pub enum UnitKind { } impl UnitKind { - /// The kinds that measure a length, which [`per_inch`](Self::per_inch) answers for: what a length field offers. + /// The lengths a unit choice offers. [`per_inch`](Self::per_inch) answers for more kinds (feet, yards, metres, Q, + /// Ha), which a typed number still reads. pub const LENGTHS: [UnitKind; 5] = [UnitKind::Inches, UnitKind::Centimetres, UnitKind::Millimetres, UnitKind::Points, UnitKind::Picas]; /// The kind a [`Reader`](craft_behavior::Reader) tag names: the tags `reader_over` registers are indexes of `ALL`. @@ -321,8 +320,8 @@ impl ColumnSize { } /// A length kept in one unit and shown in another: what a length field reads and writes (`stored`, the document's -/// unit) and what it shows and parses bare numbers in (`shown`, the user's unit). Both are `UnitKind::Pixels` or one -/// of [`UnitKind::LENGTHS`]; the document's resolution sizes pixels. +/// unit) and what it shows and parses bare numbers in (`shown`, the user's unit). Both are `UnitKind::Pixels` or any +/// kind [`UnitKind::per_inch`] answers; the document's resolution sizes pixels. #[derive(Clone, Copy, Debug, PartialEq)] #[non_exhaustive] pub struct LengthUnits { diff --git a/crates/ui-panels/src/dialog/prompt/stories.rs b/crates/ui-panels/src/dialog/prompt/stories.rs index aec09ee521..7785bc9ff9 100644 --- a/crates/ui-panels/src/dialog/prompt/stories.rs +++ b/crates/ui-panels/src/dialog/prompt/stories.rs @@ -1,6 +1,6 @@ //! Stories of the prompts. -use super::super::stories::hosted; +use super::super::stories::{hosted, opener}; use super::super::{ Alert, DialogHost, HostedAlert, Prompt, RecoveredDocument, RecoveryDialog, StackDialog as _, StandardPrompt, UnsavedChangesDialog, }; @@ -58,6 +58,17 @@ fn prompt_with_extras(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { shown } +/// The answer that takes no input until the prompt has been shown for half a second, behind the button that opens it. +#[story(Prompt<'static>, covers = [], drive = Drive::Never)] +fn prompt_with_an_armed_answer(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + Prompt::new("Install plug-in", "Do you want to install “Sharpen Pro”?") + .paragraph("Plug-ins run with the same access as the app.") + .answers([FooterButton::new("OK", DialogRole::Other).armed_after(0.5), FooterButton::new("Cancel", DialogRole::Cancel)]) + .opened(Bind::bound(opener(ui, data, "Install Plug-in…"))) + .show(ui) + .into() +} + #[story(Alert<'static>, covers = [], drive = Drive::Never)] fn alert(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { hosted(ui, data, (), || HostedAlert::new(Alert::new("About", "Version 1.0").tone(Tone::Info, "A newer version is available.")))