plugins-w1: net change of 1 commits

- plugins-w1: written from its sheet
This commit is contained in:
bflatastic
2026-11-21 21:28:08 +07:00
parent df3182f2ec
commit 53da45bbe4
3 changed files with 23 additions and 13 deletions
+6 -6
View File
@@ -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::<CanvasWords>(), &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::<CanvasWords>(), &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<egui::Key>` 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::<CanvasWords>(), &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(),
};
+5 -6
View File
@@ -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 {
+12 -1
View File
@@ -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.")))