From 95c557733f4e07a27c2aed3d3ed39eb489b15e58 Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 12:43:17 +0000 Subject: [PATCH] merge-c: 1.8: Create Shape raises the range alert for a width or height typed past 1..300,000 px, every kind (UnitSelectOutput.out_of_range; CreateShapeDialog::alert_title, take_range_alert) (#13358) --- crates/draw/src/ui/shape_drag/dialog.rs | 92 +++++++++++++------- crates/draw/tests/it/shape_drag.rs | 43 ++++++++- crates/ui-widgets/src/pickers/unit_select.rs | 27 ++++-- 3 files changed, 122 insertions(+), 40 deletions(-) diff --git a/crates/draw/src/ui/shape_drag/dialog.rs b/crates/draw/src/ui/shape_drag/dialog.rs index 2237176ed..c10d7fa24 100644 --- a/crates/draw/src/ui/shape_drag/dialog.rs +++ b/crates/draw/src/ui/shape_drag/dialog.rs @@ -9,7 +9,7 @@ use craft_behavior::Mixed; use craft_theme::variant::Tone; use craft_ui::choice::Checkbox; use craft_ui::contract::{Bind, Entry, Props as _, Remember as _, Show as _, ShowContainer as _}; -use craft_ui::dialog::{DialogId, DialogResult, DialogStack, FieldRefusal, StackDialog, dialog_id}; +use craft_ui::dialog::{Alert, DialogId, DialogResult, DialogStack, FieldRefusal, StackDialog, dialog_id}; use craft_ui::form::{Field, FieldGroup}; use craft_ui::notices::{Notice, NoticeLayout}; use craft_ui::patterns::form_dialogs::{FormDialog, GuideUnits}; @@ -17,7 +17,7 @@ use craft_ui::pickers::UnitSelect; use craft_ui::runtime::env::{Env, Label, UnitKind, Units}; use craft_ui::runtime::memory::{SaveKey, saved_value, set_saved_value}; use craft_ui::sections::DialogRole; -use craft_ui::text::{LinkMode, LinkedFields, LinkedLayout, NumberField}; +use craft_ui::text::{LinkMode, LinkedFields, LinkedLayout, NumberField, RangeAlert}; use egui::Ui; use kurbo::{Point, Rect}; use serde::{Deserialize, Serialize}; @@ -151,9 +151,10 @@ struct Memory { /// "Radius" label, with the "Link radii" toggle between the columns (`LinkMode::Equal`, on by /// default). Polygon and Star: Sides (3–100) and Star Ratio (1–100 %, default 100); the Polygon drag /// keeps ratio 1. Then "From Center". -/// - A width or height outside [`CreateShapeOptions::SIZE`] shows [`CreateShapeWords::bad_size`] under -/// the fields and disables OK; so does a click farther than 300,000 px from the origin -/// ([`CreateShapeWords::bad_position`]). +/// - A width or height typed past [`CreateShapeOptions::SIZE`] keeps the nearest end and raises the range alert, +/// which the app opens from [`take_range_alert`](Self::take_range_alert) (#13358). A size set out of range +/// through automation shows [`CreateShapeWords::bad_size`] under the fields and disables OK; so does a click +/// farther than 300,000 px from the origin ([`CreateShapeWords::bad_position`]). /// - OK answers [`CreatedShape`] at the click (centred on it with From Center, unrounded) and /// remembers width, height, From Center and the star ratio per kind; Cancel answers nothing and /// remembers nothing. @@ -165,6 +166,10 @@ pub struct CreateShapeDialog { units: [UnitKind; 2], /// Whether the dialog is open: bound to the form's open state, so the host's dialog closes with it. open: bool, + /// The title of the range alert; the dialog's own title when `None`. + alert_title: Option