PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Type: Warp on live type takes the warp styles and stays editable, no prompt (#3004) (#3008)
Valentin Klein67747dfd0271
diff --git a/crates/engine/src/warp_cmds.rs b/crates/engine/src/warp_cmds.rsindex daecc6b9c..851e819e6 100644--- a/crates/engine/src/warp_cmds.rs+++ b/crates/engine/src/warp_cmds.rs@@ -208,9 +208,53 @@ fn target(s: &Session, cmd: &str, p: &Value) -> Result<(LayerId, Rect)> {Ok((id, rect))}+/// The Warp Text settings a transform warp gives a type layer: a preset style (or none) keeps the+/// type editable, as Photoshop's Edit › Transform › Warp on type does (#3004).+fn type_warp(cmd: &str, w: &Warp) -> Result<Option<photocraft_doc::text::TextWarp>> {+ let clamp = |v: f64| if v.is_finite() { v.clamp(-100.0, 100.0) as f32 } else { 0.0 };+ match w.style {+ WarpStyle::None => Ok(None),+ WarpStyle::Custom 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")),+ s => Ok(Some(photocraft_doc::text::TextWarp {+ style: s.psd_name().into(),+ value: clamp(w.bend),+ horizontal_distortion: clamp(w.h_distort),+ vertical_distortion: clamp(w.v_distort),+ horizontal: !w.vertical,+ })),+ }+}++/// Warp on a type layer sets its Warp Text style: one history step, and the type stays editable.+fn warp_type_layer(s: &mut Session, cmd: &str, id: LayerId, w: &Warp) -> Result<Value> {+ let tw = type_warp(cmd, w)?;+ let unchanged = s.active().and_then(|d| d.doc.layer(id)).is_some_and(|l| matches!(&l.content, LayerContent::Text(t) if t.warp == tw));+ if unchanged {+ return Ok(json!({"layer": id.0, "changed": false}));+ }+ s.edit("Warp", |doc, _| {+ let group = crate::transform_cmds::group_locks(doc, id);+ let snapshot = doc.clone();+ let l = doc.layer_mut(id).ok_or(EngineError::NoLayer(id))?;+ let locks = l.locks.union(group);+ if locks.position || locks.all {+ return Err(EngineError::Other(format!("layer \"{}\" is locked", l.name)));+ }+ let LayerContent::Text(t) = &mut l.content else { return Err(EngineError::Other("not a type layer".into())) };+ t.warp = tw.clone();+ crate::type_cmds::refresh(&snapshot, t);+ Ok(())+ })?;+ Ok(json!({"layer": id.0, "changed": true, "warp": tw}))+}+fn apply(s: &mut Session, p: &Value, cmd: &str) -> Result<Value> {let (id, rect) = target(s, cmd, p)?;let w = warp_from_params(cmd, p, rect_f(rect))?;+ if matches!(s.active().and_then(|d| d.doc.layer(id)).map(|l| &l.content), Some(LayerContent::Text(_))) {+ return warp_type_layer(s, cmd, id, &w);+ }let is_smart = matches!(s.active().and_then(|d| d.doc.layer(id)).map(|l| &l.content), Some(LayerContent::Smart(_)));if w.is_identity() && !is_smart {return Ok(json!({"layer": id.0, "changed": false}));@@ -407,7 +451,7 @@ fn grid(s: &mut Session, p: &Value) -> Result<Value> {}pub fn specs() -> Vec<CommandSpec> {- const P: &str = r##"{"layer":id?,"rect":[x0,y0,x1,y1]? (warp box; default = layer content ∩ selection),"style":"custom|none|arc|arcLower|arcUpper|arch|bulge|shellLower|shellUpper|flag|wave|fish|rise|fisheye|inflate|squeeze|twist","bend":%=50,"hDistort":%,"vDistort":%,"vertical":bool,"mesh":{"us":[0,…,1],"vs":[0,…,1],"points":[[x,y]…]} ((3c+1)×(3r+1) control points, row-major, document px),"grid":[cols,rows]?,"warp":{full warp object}?,"interpolation":"bicubic|bilinear|nearest"}"##;+ const P: &str = r##"{"layer":id?,"rect":[x0,y0,x1,y1]? (warp box; default = layer content ∩ selection),"style":"custom|none|arc|arcLower|arcUpper|arch|bulge|shellLower|shellUpper|flag|wave|fish|rise|fisheye|inflate|squeeze|twist","bend":%=50,"hDistort":%,"vDistort":%,"vertical":bool,"mesh":{"us":[0,…,1],"vs":[0,…,1],"points":[[x,y]…]} ((3c+1)×(3r+1) control points, row-major, document px),"grid":[cols,rows]?,"warp":{full warp object}?,"interpolation":"bicubic|bilinear|nearest"} — on a type layer a style (or none) sets its Warp Text and the type stays editable"##;const S: &str = r##"{"warp":{…}? (the warp being edited; returned split),"rect":[x0,y0,x1,y1]?,"at":[x,y]? (document point; default = middle of the patch)} — without `warp`, edits the active smart object's warp. A 1×1 custom mesh is divided at the thirds first (the guides drawn on the default grid), so splitWarpCrosswise on an identity custom warp returns a 4×4 mesh (knots at 0, 1/3, 1/2, 2/3 and 1), not a 2×2. A preset is fitted as one patch and split without that step."##;const G: &str = r##"{"warp":{…}? (the warp being edited; returned with the new mesh),"rect":[x0,y0,x1,y1]?,"size":n|"default"|"3"|"4"|"5" (square patches, 1..=64; 1 and "default" are the single-patch grid)} — without `warp`/`style`/`mesh`, edits the active smart object's warp. The surface is kept and the new lines are real splits at i/n."##;vec![@@ -512,6 +556,23 @@ mod tests {st.doc.layer(st.active_layer.unwrap()).unwrap().surface().unwrap().clone()}+ /// Warp on type sets its Warp Text (#3004): the layer stays type, one step; a custom mesh is+ /// refused rather than rasterizing.+ #[test]+ fn warp_style_on_type_is_warp_text() {+ let mut s = Session::new();+ s.execute("file.new", json!({"width": 200, "height": 100})).unwrap();+ s.execute("type.create", json!({"x": 10, "y": 60, "text": "Hi"})).unwrap();+ let n = s.active().unwrap().history.past_len();+ s.execute("edit.transform.warp", json!({"style": "arc", "bend": 30})).unwrap();+ let st = s.active().unwrap();+ let LayerContent::Text(t) = &st.doc.layer(st.active_layer.unwrap()).unwrap().content else { panic!("type") };+ assert_eq!(t.warp.as_ref().map(|w| (w.style.as_str(), w.value)), Some(("warpArc", 30.0)));+ assert_eq!(st.history.past_len(), n + 1);+ let mesh = BezierMesh::identity([0.0, 0.0, 10.0, 10.0], 1, 1).map_points(|p| [p[0] * 2.0, p[1]]);+ assert!(s.execute("edit.transform.warp", json!({"warp": Warp::custom(mesh, [0.0, 0.0, 10.0, 10.0])})).is_err());+ }+#[test]fn identity_and_bend_zero_are_no_ops_at_every_depth() {for depth in [8u64, 16, 32] {diff --git a/crates/ui-egui/src/enable_rules.rs b/crates/ui-egui/src/enable_rules.rsindex cee8e5472..e3712c1a9 100644--- a/crates/ui-egui/src/enable_rules.rs+++ b/crates/ui-egui/src/enable_rules.rs@@ -127,10 +127,18 @@ pub fn disabled(app: &crate::PhotocraftApp, id: &str) -> bool {return false;}// Editable type can be scaled, rotated and skewed but not distorted (#2630): Photoshop greys- // Distort and Perspective until the type is rasterized. A targeted unlinked mask or channel of- // the type layer is pixels, and can be.- if matches!(id, "edit.transform.distort" | "edit.transform.perspective")- && active.is_some_and(|l| matches!(l.content, LayerContent::Text(_)))+ // Distort and Perspective until the type is rasterized, and the split warps (Warp on type+ // offers only the warp styles, #3004). A targeted unlinked mask or channel of the type layer+ // is pixels, and can be.+ if matches!(+ id,+ "edit.transform.distort"+ | "edit.transform.perspective"+ | "edit.transform.splitWarpCrosswise"+ | "edit.transform.splitWarpHorizontally"+ | "edit.transform.splitWarpVertically"+ | "edit.transform.removeWarpSplit"+ ) && active.is_some_and(|l| matches!(l.content, LayerContent::Text(_)))&& photocraft_engine::transform_cmds::lone_target(&st.doc, st.active_layer, &serde_json::json!({ "target": crate::canvas::paint_target(app) })).is_ok_and(|t| t.is_none()){diff --git a/crates/ui-egui/src/transform_tool.rs b/crates/ui-egui/src/transform_tool.rsindex 0a2f8d3cd..b64d04cb6 100644--- a/crates/ui-egui/src/transform_tool.rs+++ b/crates/ui-egui/src/transform_tool.rs@@ -514,7 +514,7 @@ pub fn begin_warp(app: &mut PhotocraftApp, ctx: &egui::Context) -> Result<(), Stif fresh {begin(app, ctx)?;}- enter_warp(app);+ enter_warp(app, ctx);// Started in Warp: that is where Undo stops. Switching an open transform to Warp is a step.if fresh {start_steps(app);@@ -523,8 +523,12 @@ pub fn begin_warp(app: &mut PhotocraftApp, ctx: &egui::Context) -> Result<(), St}/// Switch to Warp mode: a smart object's existing warp (when the box is untouched), else a-/// custom mesh following the current box (so a transform made first carries over).-pub fn enter_warp(app: &mut PhotocraftApp) {+/// custom mesh following the current box (so a transform made first carries over). Editable type+/// gets its own Warp Text style instead ([`enter_type_warp`]).+pub fn enter_warp(app: &mut PhotocraftApp, ctx: &egui::Context) {+ if app.ui.transform.as_ref().is_some_and(|t| t.warp.is_none()) && warps_type(app) {+ return enter_type_warp(app, ctx);+ }let existing =app.session.active().and_then(|d| d.doc.layer(LayerId(app.ui.transform.as_ref()?.layer)).and_then(photocraft_engine::warp_cmds::smart_warp_doc_space));let Some(t) = app.ui.transform.as_mut() else { return };@@ -549,6 +553,65 @@ pub fn enter_warp(app: &mut PhotocraftApp) {t.warp = Some(Warp::custom(mesh, t.rect));}+/// The open transform moves an editable type layer as a whole (not a lone mask, channel, path or+/// the selection). Its Warp is Warp Text: only the styles, and the type stays editable (#3004).+pub fn warps_type(app: &PhotocraftApp) -> bool {+ let Some(t) = &app.ui.transform else { return false };+ if t.selection || t.target.is_some() || t.path.is_some() {+ return false;+ }+ app.session.active().and_then(|st| st.doc.layer(LayerId(t.layer))).is_some_and(|l| matches!(l.content, LayerContent::Text(_)))+}++/// Warp on editable type, as in Photoshop: no rasterizing, no mesh to drag, just the warp styles+/// of the options bar (Warp Text's). A box scaled or rotated first is applied first (that keeps+/// type editable). The preview shows the type without its current Warp Text, under that style.+fn enter_type_warp(app: &mut PhotocraftApp, ctx: &egui::Context) {+ if app.ui.transform.as_ref().is_some_and(|t| t.quad != corners(t.rect)) {+ commit(app);+ if let Err(e) = begin(app, ctx) {+ app.ui.status = e;+ return;+ }+ }+ let (Some(t), Some(st)) = (app.ui.transform.as_ref(), app.session.active()) else { return };+ let (id, session) = (LayerId(t.layer), t.session);+ let doc = st.doc.clone();+ let Some(LayerContent::Text(text)) = doc.layer(id).map(|l| &l.content) else { return };+ let current = text.warp.clone();+ let mut plain = (*doc).clone();+ if let Some(LayerContent::Text(tt)) = plain.layer_mut(id).map(|l| &mut l.content)+ && current.is_some()+ {+ tt.warp = None;+ photocraft_engine::type_cmds::refresh(&doc, tt);+ }+ let Some(b) = plain.layer(id).map(|l| photocraft_engine::transform_cmds::transform_bounds(&plain, l)).filter(|b| !b.is_empty()) else { return };+ let rect = [b.x0 as f64, b.y0 as f64, b.x1 as f64, b.y1 as f64];+ if current.is_some()+ && let Some(pv) = app.transform_preview.as_mut()+ {+ let max_side = ctx.input(|i| i.max_texture_side).max(app.gpu.as_ref().map_or(1, |g| g.max_texture_side()));+ let (image, uv) = preview_image(&plain, id, None, b, max_side);+ pv.texture = crate::transform_tex::PreviewTextures::new(ctx, format!("transform-{session}"), image, uv);+ }+ let warp =+ current.as_ref().and_then(|w| WarpStyle::parse(&w.style).filter(|s| s.is_preset()).map(|s| (w, s))).map_or(Warp::none(rect), |(w, style)| Warp {+ style,+ bend: f64::from(w.value),+ h_distort: f64::from(w.horizontal_distortion),+ v_distort: f64::from(w.vertical_distortion),+ vertical: !w.horizontal,+ ..Warp::none(rect)+ });+ if let Some(t) = app.ui.transform.as_mut() {+ t.rect = rect;+ t.quad = corners(rect);+ t.pivot = [(rect[0] + rect[2]) / 2.0, (rect[1] + rect[3]) / 2.0];+ t.warp = Some(warp);+ }+}+/// Leave Warp mode (back to the box; warp edits are dropped, like Photoshop's mode toggle on an/// untouched warp).pub fn leave_warp(app: &mut PhotocraftApp) {@@ -781,6 +844,7 @@ pub fn commit(app: &mut PhotocraftApp) {cancel(app);return;}+ let type_layer = warps_type(app);let Some(t) = app.ui.transform.take() else { return };app.transform_preview = None;if t.selection {@@ -813,7 +877,8 @@ pub fn commit(app: &mut PhotocraftApp) {}let made = t.made;let r = if let Some(w) = &t.warp {- if w.is_identity() {+ // Type with a Warp Text can be warped back to None; the engine skips an unchanged style.+ if w.is_identity() && !type_layer {return;}app.run("edit.transform.warp", json!({"layer": t.layer, "rect": t.rect, "warp": w, "interpolation": t.interpolation}))@@ -1483,6 +1548,10 @@ fn split_gesture(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers)/// Preset warps turn into a custom mesh when the press grabs something. An armed split tool, or/// Ctrl / Option held, places a split where the pointer is released instead.fn warp_pointer(app: &mut PhotocraftApp, ev: ToolEvent, tol: f64, mods: egui::Modifiers) {+ // Type takes only the warp styles: nothing on the canvas to drag or split (#3004).+ if warps_type(app) {+ return;+ }if split_gesture(app, ev, mods) {return;}@@ -1517,6 +1586,9 @@ fn warp_pointer(app: &mut PhotocraftApp, ev: ToolEvent, tol: f64, mods: egui::Mo/// Runs a warp-edit command against the mesh in the open Warp session and writes the mesh back.pub fn edit_session_warp(app: &mut PhotocraftApp, id: &str, params: &serde_json::Value) -> Result<(), String> {let Some(w) = app.ui.transform.as_ref().and_then(|t| t.warp.clone()) else { return Err("not warping".into()) };+ if warps_type(app) {+ return Err("Warp on type takes only the warp styles".into());+ }let mut p = if params.is_object() { params.clone() } else { json!({}) };if p.get("warp").is_none() {p["warp"] = serde_json::to_value(&w).map_err(|e| e.to_string())?;@@ -1594,6 +1666,9 @@ pub fn cursor(app: &PhotocraftApp, p: [f64; 2], quick_split: bool) -> Option<Curlet t = app.ui.transform.as_ref()?;let tol = handle_tolerance(app);if let Some(w) = &t.warp {+ if warps_type(app) {+ return Some(CursorIcon::Default);+ }if let Some(tool) = app.transform_preview.as_ref().and_then(|pv| pv.split_tool) {return Some(split_cursor(tool));}@@ -1632,7 +1707,7 @@ pub fn draw_overlay(app: &PhotocraftApp, painter: &egui::Painter, xf: &ViewXformlet over_canvas = painter.ctx().input(|i| i.pointer.hover_pos()).filter(|p| xf.rect.contains(*p)).map(|p| xf.to_doc(p));let at = pv.split_pointer.or(over_canvas);let alt = painter.ctx().input(|i| i.modifiers.alt || i.modifiers.command);- let guide = at.and_then(|p| {+ let guide = at.filter(|_| !warps_type(app)).and_then(|p| {let tool = pv.split_tool.or_else(|| (alt || pv.split_quick).then(|| quick_split_kind(&w.to_mesh(1, 1), w.bounds, p)));tool.map(|tool| (tool, p))});@@ -2130,7 +2205,58 @@ fn warp_fields(app: &mut PhotocraftApp, ui: &mut egui::Ui, w: &Warp) {let lbl = |ui: &mut egui::Ui, s: &str| {ui.label(egui::RichText::new(s).color(tk.text_dim).size(12.0));};+ // Type takes only the styles (#3004): Split and Grid are greyed, and there is no Custom.+ let on_type = warps_type(app);// Split, Grid, then the warp style with its bend fields.+ ui.add_enabled_ui(!on_type, |ui| warp_mesh_fields(app, ui, w));+ crate::widgets::vline(ui, 22.0);+ lbl(ui, tl!("Warp:"));+ let mut style = w.style;+ let opts: Vec<(WarpStyle, &str)> = WarpStyle::all().filter(|s| !(on_type && *s == WarpStyle::Custom)).map(|s| (s, s.label())).collect();+ if crate::widgets::dropdown(ui, "warp-style", &mut style, &opts, 120.0)+ && let Some(t) = app.ui.transform.as_mut()+ {+ let b = t.rect;+ t.warp = Some(match style {+ WarpStyle::Custom => Warp::custom(w.to_mesh(1, 1), b),+ WarpStyle::None if on_type => Warp::none(b),+ WarpStyle::None => Warp::custom(BezierMesh::identity(b, 1, 1), b),+ s => Warp { style: s, bend: if w.style.is_preset() { w.bend } else { 50.0 }, ..Warp::none(b) },+ });+ }+ // Orientation and the bend fields are always there, and only act on a preset style.+ let preset = w.style.is_preset();+ ui.add_enabled_ui(preset, |ui| {+ let orient = crate::icons::button(ui, "arrow-left-right", 26.0, w.vertical, tl!("Vertical"));+ orient.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, preset, "Change warp orientation"));+ if orient.clicked()+ && let Some(Some(cur)) = app.ui.transform.as_mut().map(|t| t.warp.as_mut())+ {+ cur.vertical = !cur.vertical;+ }+ let fields: [(&str, f64); 3] = [(tl!("Bend:"), w.bend), ("H:", w.h_distort), ("V:", w.v_distort)];+ for (k, (name, v)) in fields.iter().enumerate() {+ lbl(ui, name);+ let mut f = *v as f32;+ if crate::widgets::value_field(ui, &mut f, -100.0..=100.0, "%", 58.0).changed()+ && let Some(Some(cur)) = app.ui.transform.as_mut().map(|t| t.warp.as_mut())+ {+ match k {+ 0 => cur.bend = f64::from(f),+ 1 => cur.h_distort = f64::from(f),+ _ => cur.v_distort = f64::from(f),+ }+ }+ }+ });+}++/// The Split icons and the Grid menu of the Warp options bar.+fn warp_mesh_fields(app: &mut PhotocraftApp, ui: &mut egui::Ui, w: &Warp) {+ let tk = crate::theme::Tokens::get(ui.ctx());+ let lbl = |ui: &mut egui::Ui, s: &str| {+ ui.label(egui::RichText::new(s).color(tk.text_dim).size(12.0));+ };lbl(ui, tl!("Split:"));let armed = app.transform_preview.as_ref().and_then(|p| p.split_tool);for (tool, tip) in [@@ -2170,45 +2296,6 @@ fn warp_fields(app: &mut PhotocraftApp, ui: &mut egui::Ui, w: &Warp) {{let _ = edit_session_warp(app, "edit.transform.warpGrid", &json!({ "size": n }));}- crate::widgets::vline(ui, 22.0);- lbl(ui, tl!("Warp:"));- let mut style = w.style;- let opts: Vec<(WarpStyle, &str)> = WarpStyle::all().map(|s| (s, s.label())).collect();- if crate::widgets::dropdown(ui, "warp-style", &mut style, &opts, 120.0)- && let Some(t) = app.ui.transform.as_mut()- {- let b = t.rect;- t.warp = Some(match style {- WarpStyle::Custom => Warp::custom(w.to_mesh(1, 1), b),- WarpStyle::None => Warp::custom(BezierMesh::identity(b, 1, 1), b),- s => Warp { style: s, bend: if w.style.is_preset() { w.bend } else { 50.0 }, ..Warp::none(b) },- });- }- // Orientation and the bend fields are always there, and only act on a preset style.- let preset = w.style.is_preset();- ui.add_enabled_ui(preset, |ui| {- let orient = crate::icons::button(ui, "arrow-left-right", 26.0, w.vertical, tl!("Vertical"));- orient.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, preset, "Change warp orientation"));- if orient.clicked()- && let Some(Some(cur)) = app.ui.transform.as_mut().map(|t| t.warp.as_mut())- {- cur.vertical = !cur.vertical;- }- let fields: [(&str, f64); 3] = [(tl!("Bend:"), w.bend), ("H:", w.h_distort), ("V:", w.v_distort)];- for (k, (name, v)) in fields.iter().enumerate() {- lbl(ui, name);- let mut f = *v as f32;- if crate::widgets::value_field(ui, &mut f, -100.0..=100.0, "%", 58.0).changed()- && let Some(Some(cur)) = app.ui.transform.as_mut().map(|t| t.warp.as_mut())- {- match k {- 0 => cur.bend = f64::from(f),- 1 => cur.h_distort = f64::from(f),- _ => cur.v_distort = f64::from(f),- }- }- }- });}/// Back to the untouched box: the default one-patch grid over the box, no bend.@@ -2219,6 +2306,11 @@ pub fn reset_warp(app: &mut PhotocraftApp) {}let b = t.rect;t.warp = Some(Warp::custom(BezierMesh::identity(b, 1, 1), b));+ if warps_type(app)+ && let Some(t) = app.ui.transform.as_mut()+ {+ t.warp = Some(Warp::none(b));+ }if let Some(pv) = app.transform_preview.as_mut() {pv.warp_drag = None;pv.split_tool = None;@@ -2313,7 +2405,7 @@ fn transform_actions(app: &mut PhotocraftApp, ui: &mut egui::Ui, warping: bool)if warping {leave_warp(app);} else {- enter_warp(app);+ enter_warp(app, &ui.ctx().clone());}}}@@ -3982,7 +4074,7 @@ mod tests {// Warp mode doesn't apply to a lone mask.app.ui.mask_target = true;begin(&mut app, &ctx).unwrap();- enter_warp(&mut app);+ enter_warp(&mut app, &egui::Context::default());assert!(app.ui.transform.as_ref().unwrap().warp.is_none());}@@ -4035,4 +4127,51 @@ mod tests {app.run("layer.new.layer", json!({})).unwrap();assert!(crate::vector_ui::free_transform_path(&app).is_none());}++ /// Edit › Transform › Warp on editable type (#3004), as in Photoshop: no rasterize prompt, no+ /// mesh to drag, only the warp styles; the commit is the type's own Warp Text, one step, and+ /// the layer stays type.+ #[test]+ fn warp_on_type_takes_a_style_and_keeps_the_type_editable() {+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ app.session.execute("file.new", json!({"width": 200, "height": 100})).unwrap();+ app.sync_views();+ app.run("type.create", json!({"x": 10, "y": 60, "text": "Hello"})).unwrap();+ let ctx = egui::Context::default();+ let past = |app: &PhotocraftApp| app.session.active().unwrap().history.past_len();+ let before = past(&app);+ crate::menus::invoke(&mut app, &ctx, "edit.transform.warp", json!({})).unwrap();+ assert!(app.ui.dialogs.is_empty(), "no prompt");+ let w0 = app.ui.transform.as_ref().and_then(|t| t.warp.clone()).expect("Warp mode");+ assert_eq!(w0.style, WarpStyle::None);+ // A drag on the grid changes nothing: type takes only the styles.+ let c = [(w0.bounds[0] + w0.bounds[2]) / 2.0, (w0.bounds[1] + w0.bounds[3]) / 2.0];+ warp_pointer(&mut app, ToolEvent::Down { x: w0.bounds[2], y: w0.bounds[3], pressure: 1.0 }, 4.0, egui::Modifiers::NONE);+ warp_pointer(&mut app, ToolEvent::Up { x: w0.bounds[2] + 20.0, y: w0.bounds[3] + 15.0 }, 4.0, egui::Modifiers::NONE);+ warp_pointer(&mut app, ToolEvent::Down { x: c[0], y: c[1], pressure: 1.0 }, 4.0, egui::Modifiers::NONE);+ warp_pointer(&mut app, ToolEvent::Up { x: c[0], y: c[1] + 20.0 }, 4.0, egui::Modifiers::NONE);+ assert_eq!(app.ui.transform.as_ref().unwrap().warp.as_ref(), Some(&w0));+ assert!(split(&mut app, "edit.transform.splitWarpCrosswise", None).is_err());+ // Pick Flag in the options bar, then Enter.+ if let Some(w) = app.ui.transform.as_mut().and_then(|t| t.warp.as_mut()) {+ *w = Warp { style: WarpStyle::Flag, bend: 40.0, ..Warp::none(w.bounds) };+ }+ commit(&mut app);+ assert!(!app.ui.status_error, "{}", app.ui.status);+ let st = app.session.active().unwrap();+ let LayerContent::Text(t) = &st.doc.layer(st.active_layer.unwrap()).unwrap().content else { panic!("still type") };+ let tw = t.warp.as_ref().expect("Warp Text set");+ assert_eq!((tw.style.as_str(), tw.value, tw.horizontal), ("warpFlag", 40.0, true));+ assert_eq!(past(&app), before + 1, "one history step");+ // Warp again shows Flag; None takes it off in one more step.+ begin_warp(&mut app, &ctx).unwrap();+ assert_eq!(app.ui.transform.as_ref().unwrap().warp.as_ref().unwrap().style, WarpStyle::Flag);+ if let Some(t) = app.ui.transform.as_mut() {+ t.warp = Some(Warp::none(t.rect));+ }+ commit(&mut app);+ let st = app.session.active().unwrap();+ assert!(matches!(&st.doc.layer(st.active_layer.unwrap()).unwrap().content, LayerContent::Text(t) if t.warp.is_none()));+ assert_eq!(past(&app), before + 2);+ }}diff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex b8d38b558..87d1bbf65 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -62,6 +62,7 @@ The transport is `apps/photocraft/src/control_server.rs`, and the handlers are i- Preferences (`ui.menu.invoke {id: "edit.preferences.interface"}`) exposes the sections in its `values` field. Apply (`ui.dialog.apply`) and OK (`ui.dialog.confirm`) on Preferences are refused over control because automation denies whole-preferences updates and filesystem-bearing preference sections. A refused `ui.dialog.apply` returns an error and keeps the dialog open; a refused `ui.dialog.confirm` returns an error but closes and removes the dialog. `ui.dialog.cancel` closes the dialog without saving. Individual safe preferences can instead be changed with `engine.execute` using `prefs.set` (e.g. `{"command": "prefs.set", "params": {"path": "interface.showTooltips", "value": false}}`). Settings marked for the next launch still require a restart.- Edit › Fill… (`ui.menu.invoke {id: "edit.fill"}`, Shift+F5, Shift+Backspace) opens the Fill dialog; its fields are `edit.fill`'s params (`contents`, `color`, `pattern`, `colorAdaptation`, `mode`, `opacity`, `preserveTransparency`), and OK remembers them in the preferences (`dialogs["edit.fill"]`).- A pixel tool pressed on a type, shape, Smart Object or fill layer (e.g. through `ui.pointer`) opens the "Rasterize?" prompt instead of painting: a dialog with `__rasterize` (`type|shape|smartObject|fill`), `message`, `layer`, `tool` and `at`. `ui.dialog.confirm` runs the `layer.rasterize.*` command and then paints at `at` (two history states, `{"rasterized", "painted"}`); `ui.dialog.cancel` does nothing.+ - Edit › Transform › Warp on editable type (`ui.menu.invoke {"id":"edit.transform.warp"}`, or the warp toggle of an open transform box) opens Warp mode with no prompt, as in Photoshop: the mesh can't be dragged or split, only the options bar's warp style, Bend, H and V apply, and the commit sets the layer's Warp Text in one step, so the type stays editable. Directly: `engine.execute {"command":"edit.transform.warp","params":{"style":"flag","bend":40}}` on a type layer. Distort and Perspective stay greyed for type.- `ui.window.open {document?}` / `ui.window.close {window}`: extra document windows- `ui.pointer {events: [{kind: down|move|up, x, y, pressure?, tiltX?, tiltY?, rotation?}], tool?, modifiers?, button?}`: drive the active tool in document coordinates (pressure 0..1, tilt in degrees -90..90, barrel rotation 0..360: a simulated pen). Modifier flags (`shift`, `alt`, `command`, `ctrl`, `space`) go either at the top level or grouped under `modifiers`; when `modifiers` is present, top-level flags are ignored. `space: true` holds Space (the Crop frame, marquee, lasso or shape being drawn then moves instead of growing). With the Crop tool in its default mode (Use Classic Mode off) a drag inside the box moves the image and one outside turns it, the view panning and turning with it; a drag's `move`/`up` points are read as the view showed the document at its `down`, so an `up` where the last `move` was changes nothing more. `command: true` with a painting, retouching, eraser, gradient, eyedropper or other non-selection tool makes the gesture the Move tool's, as holding ⌘ (Ctrl off the Mac) does in the app: a drag moves the active layer (the selected pixels when there is a selection), with `alt: true` as well it duplicates the layer first, and a click picks the layer under the point; the tool is unchanged afterwards. The Hand, Rotate View, Zoom, Crop, Slice, Path Selection, Pen, shape, Type and selection tools keep `command` for themselves. `ctrl: true` with `alt: true` and a brush tool is the on-canvas brush resize instead (in the app, Ctrl+Alt-drag off the Mac). `button: "right"` (or `"secondary"`) is the right button: with the Move tool (or `command: true` with any tool) it opens the canvas layer menu (`layerMenu` in `ui.inspect` lists the layers there, topmost first; select one with `layer.select`); with Marquee, Lasso, Magic Wand, Object Selection, or Pen it opens a tool context menu (`canvasToolMenu` in `ui.inspect`, with ordered command ids, separators, and enabled states); with Zoom or Hand it opens the view menu there (Zoom In and Zoom Out step about the pressed point; `view.fillScreen` is its Fill Screen row); with a painting tool it opens the Brush Preset picker, or erases with Preferences › Tools › Right-click with painting tools = erase. The menus open at the screen position of the pressed document point. Use `ui.context.choose {id}` for enabled tool-context actions. The Pen menu is documented in `docs/context-menu-parity.md`. `button` is `left` (default), `right`, `secondary` or `middle`, and an event's `kind` is `down`, `move` (default) or `up`. With a Color Picker as the top dialog, `down` and `move` sample the image into its new colour instead (its eyedropper, like a click on the canvas) and the tool is not driven. A `down`/`up` at the same point with the Rectangle, Ellipse, Triangle or Polygon tool opens Create Rectangle / Ellipse / Triangle / Polygon (Photoshop's click-to-size dialog); set its `width` and `height` (document pixels), `fromCenter`, `radii` [tl, tr, br, bl] (Rectangle) or `sides` and `starRatio` (percent, Polygon) with `ui.dialog.set`, then `ui.dialog.confirm` runs `shape.create` at the clicked point.- Magnetic Lasso (`tool: "magneticLasso"`): a `down`/`up` pair is a click. The first sets the first fastening point (its modifiers set the selection mode); later clicks fasten a point, or close the border on the first point. `move` events trace the border with or without a button held, fastening points by themselves; with `alt: true` a click draws a straight segment and a drag a freehand one. `ui.inspect` shows the border in progress under `magnetic` (`path`, `anchors`, `live`, `mode`). `ui.key` Enter closes it along the edges, Backspace removes the last fastening point, Escape cancels. To select along edges in one call instead, use the `select.magneticLasso` command with rough points around the shape.diff --git a/docs/scorecard.md b/docs/scorecard.mdindex 06c959740..81e93ea2b 100644--- a/docs/scorecard.md+++ b/docs/scorecard.md@@ -10,7 +10,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js| [File compatibility](#file-compatibility) | 6 | 12 | 9 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 || [Tools](#tools) | 25 | 16 | 2 | || [Workspace and UI](#workspace-and-ui) | 9 | 8 | 6 | settings that do nothing: 31 of 154 (target 0) |-| [Type](#type) | 2 | 3 | 4 | |+| [Type](#type) | 3 | 3 | 3 | || [Automation](#automation) | 3 | 2 | 6 | 631 of 631 menu items live (100.0%) || [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present || [Distribution](#distribution) | 5 | 4 | 2 | |@@ -218,7 +218,7 @@ Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_w| TYPE-218-6 | Manual pair kerning (Alt+arrows), optical kerning rendered, both round-trip PSD (#206) | done | [#218](https://github.com/storytold/photocraft/issues/218) | Alt+Left/Right at a collapsed caret kerns the pair (type_tool.rs kern_pair, 20 per step and 100 with Cmd; type_tool_alt_arrows_kern_the_pair). Optical kerning is computed from the glyph outlines in text/src/optical.rs and applied by layout.rs when the run's mode is Optical (optical_matches_photoshop, optical_kerning_tightens_open_pairs). Both modes and manual values round-trip through PSD (io/tests/psd_kerning.rs; the optical mode travels in Txt2, txt2_carries_optical_kerning) || TYPE-218-7 | Warp Text dialog previews live and opens with the layer's current warp | missing | [#218](https://github.com/storytold/photocraft/issues/218) | view_cmds.rs:834 always seeds arc, bend 50 || TYPE-218-8 | Text editing: select all, double/triple/quadruple-click selection, paste, with tests | partial | [#218](https://github.com/storytold/photocraft/issues/218) | Cmd+A, paste and double-click exist; no triple/quadruple click, no tests |-| TYPE-218-9 | Offer 'Rasterize and continue?' for Distort/Perspective/Warp on live type | missing | [#218](https://github.com/storytold/photocraft/issues/218) | No such prompt |+| TYPE-218-9 | Distort/Perspective/Warp on live type as in Photoshop (was: offer 'Rasterize and continue?'; Photoshop doesn't prompt) | done | [#218](https://github.com/storytold/photocraft/issues/218) | Photoshop 2026 prompts for none of these: Edit › Transform › Warp on live type stays enabled with no rasterize prompt and offers only the warp styles (the mesh can't be dragged), so the type stays editable; Distort, Perspective and the split warps are greyed. PhotoCraft does the same: Warp on type commits the layer's Warp Text in one step (transform_tool.rs enter_type_warp, warp_cmds.rs warp_type_layer, #3004; warp_on_type_takes_a_style_and_keeps_the_type_editable), Distort/Perspective greyed (enable_rules.rs, #2701) |## Automationdiff --git a/scorecard/type.toml b/scorecard/type.tomlindex 98d3da07b..7a9682823 100644--- a/scorecard/type.toml+++ b/scorecard/type.toml@@ -62,7 +62,7 @@ note = "Cmd+A, paste and double-click exist; no triple/quadruple click, no tests[[item]]id = "TYPE-218-9"-target = "Offer 'Rasterize and continue?' for Distort/Perspective/Warp on live type"-status = "missing"+target = "Distort/Perspective/Warp on live type as in Photoshop (was: offer 'Rasterize and continue?'; Photoshop doesn't prompt)"+status = "done"issue = 218-note = "No such prompt"+note = "Photoshop 2026 prompts for none of these: Edit › Transform › Warp on live type stays enabled with no rasterize prompt and offers only the warp styles (the mesh can't be dragged), so the type stays editable; Distort, Perspective and the split warps are greyed. PhotoCraft does the same: Warp on type commits the layer's Warp Text in one step (transform_tool.rs enter_type_warp, warp_cmds.rs warp_type_layer, #3004; warp_on_type_takes_a_style_and_keeps_the_type_editable), Distort/Perspective greyed (enable_rules.rs, #2701)"