From b8a3b4df3945476bd6e2d934cb09d5c0d1deb081 Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 30 Nov 2026 11:06:26 +0100 Subject: [PATCH] Warp over type: the bar lists Custom greyed and no None (#12499 follow-up) craft-libs#4338 gave WarpFields the over-type layout: no Split, Grid greyed, styles marked greyed_over_type listed disabled. style_entries now marks Custom greyed and leaves None out over type, Reset on type goes back to Arc 0 as Warp opens there, and a style at Bend, H and V 0 takes a stored Warp Text off, since the bar no longer offers None. Needs a craft-libs pin that contains storytold/craft-libs@2680a3b. Co-Authored-By: Claude Opus 5.5 --- crates/engine-core/src/cmd/warp_cmds.rs | 4 +++- crates/engine-core/src/cmd/warp_cmds/tests.rs | 22 +++++++++++++++++++ .../src/tools/transform_tool/options_bar.rs | 17 +++++++++----- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/crates/engine-core/src/cmd/warp_cmds.rs b/crates/engine-core/src/cmd/warp_cmds.rs index 6be7f1329e..8afbd81086 100644 --- a/crates/engine-core/src/cmd/warp_cmds.rs +++ b/crates/engine-core/src/cmd/warp_cmds.rs @@ -438,8 +438,10 @@ fn target(s: &Session, cmd: &str, p: &Value) -> Result<(LayerId, Rect)> { fn type_warp(cmd: &str, w: &Warp) -> Result> { let clamp = |v: f64| if v.is_finite() { v.clamp(-100.0, 100.0) as f32 } else { 0.0 }; match w.style { + // A style with no bend or distortion is no Warp Text (#12499): over type the bar offers no + // None, so Bend, H and V at 0 is how a stored Warp Text is taken off. WarpStyle::None => Ok(None), - WarpStyle::Custom if w.is_identity() => Ok(None), + _ if w.is_identity() => Ok(None), WarpStyle::Custom => Err(bad(cmd, "type can only take a warp style (arc, flag, …); a custom mesh needs rasterized type")), WarpStyle::Cylinder => Err(bad(cmd, "type can only take a warp style (arc, flag, …); a cylinder needs rasterized type")), s => Ok(Some(photocraft_doc::text::TextWarp { diff --git a/crates/engine-core/src/cmd/warp_cmds/tests.rs b/crates/engine-core/src/cmd/warp_cmds/tests.rs index 089b515a81..0c550e5653 100644 --- a/crates/engine-core/src/cmd/warp_cmds/tests.rs +++ b/crates/engine-core/src/cmd/warp_cmds/tests.rs @@ -71,6 +71,28 @@ fn warp_style_on_type_is_warp_text() { assert!(s.execute("edit.transform.warp", json!({"warp": Warp::custom(mesh, [0.0, 0.0, 10.0, 10.0])})).is_err()); } +/// A style at Bend, H and V 0 takes a stored Warp Text off (#12499): over type the bar offers no +/// None, so this is how the warp is removed. On unwarped type it changes nothing. +#[test] +fn an_unbent_style_on_type_removes_its_warp_text() { + let mut s = crate::session(); + s.execute("file.new", json!({"width": 200, "height": 100})).unwrap(); + s.execute("type.create", json!({"x": 10, "y": 60, "text": "Hi"})).unwrap(); + let warp = |s: &crate::Session| { + let st = s.active().unwrap(); + let LayerContent::Text(t) = &st.doc.layer(st.active_layer.unwrap()).unwrap().content else { panic!("type") }; + t.warp.clone() + }; + let r = s.execute("edit.transform.warp", json!({"style": "arc", "bend": 0})).unwrap(); + assert_eq!(r["changed"], false, "unwarped type stays as it is"); + s.execute("edit.transform.warp", json!({"style": "flag", "bend": 30})).unwrap(); + assert!(warp(&s).is_some()); + let n = s.active().unwrap().history.past_len(); + s.execute("edit.transform.warp", json!({"style": "flag", "bend": 0})).unwrap(); + assert!(warp(&s).is_none(), "the Warp Text is off"); + assert_eq!(s.active().unwrap().history.past_len(), n + 1, "in one step"); +} + /// The seven values of a cylinder over the session's painted box (x 10..60, y 10..40). const CYL: [f64; 7] = [10.0, 40.0, 60.0, 10.0, 0.3, 0.3, 0.5]; diff --git a/crates/ui-egui/src/tools/transform_tool/options_bar.rs b/crates/ui-egui/src/tools/transform_tool/options_bar.rs index 83369eb96f..25eaba29ef 100644 --- a/crates/ui-egui/src/tools/transform_tool/options_bar.rs +++ b/crates/ui-egui/src/tools/transform_tool/options_bar.rs @@ -133,12 +133,17 @@ fn ruler_texts(app: &PhotocraftApp) -> (RulerText, RulerText) { } /// The Warp menu's styles in Photoshop's order: None, Custom and the presets, then Cylinder -/// (#4112). Custom and Cylinder are not offered over type (#3004: Warp Text has neither), and a -/// cylinder has no splits or grid (its handles are its own). +/// (#4112). Over type, None and Cylinder are not offered and Custom is listed greyed (#3004: Warp +/// Text has neither Custom nor Cylinder; #12499: the reference lists Custom greyed and no None), +/// and a cylinder has no splits or grid (its handles are its own). pub(super) fn style_entries() -> Vec { let entry = |s: WarpStyle| WarpStyleEntry::new(s.id(), s.label()).preset(s.is_preset()); WarpStyle::all() - .map(|s| if s == WarpStyle::Custom { entry(s).over_type(false) } else { entry(s) }) + .map(|s| match s { + WarpStyle::None => entry(s).over_type(false), + WarpStyle::Custom => entry(s).greyed_over_type(true), + _ => entry(s), + }) .chain(std::iter::once(entry(WarpStyle::Cylinder).over_type(false).splits(false))) .collect() } @@ -208,11 +213,11 @@ fn warp_edit(app: &mut PhotocraftApp, edit: WarpFieldsEdit) { set_warp(app, next); } -/// Back to the untouched box: the default one-patch grid over the box, no bend (over type, the -/// None style). One undo step through the session, and no Split tool armed. +/// Back to the untouched box: the default one-patch grid over the box, no bend (over type, Arc at +/// Bend 0, as Warp opens there, #12499). One undo step through the session, and no Split tool armed. pub fn reset_warp(app: &mut PhotocraftApp) { let Some((b, on_type)) = app.ui.transform.as_ref().and_then(|t| t.session.warp()).map(|w| (w.warp.bounds, w.on_type)) else { return }; - set_warp(app, if on_type { Warp::none(b) } else { Warp::custom(BezierMesh::identity(b, 1, 1), b) }); + set_warp(app, if on_type { Warp { style: WarpStyle::Arc, ..Warp::none(b) } } else { Warp::custom(BezierMesh::identity(b, 1, 1), b) }); if let Some(pv) = app.transform_preview.as_mut() { pv.split = None; }