PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Shapes: on-canvas corner radius widgets for live rectangles (TOOL-214-12) (#5276)
baz9df067b297d1
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rsindex 8f3360106..e21a7e76a 100644--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@ -3731,6 +3731,11 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:ui.ctx().set_cursor_icon(c);} else if let Some(c) = response.hover_pos().and_then(|p| crate::cam_transform::cursor(app, &ctx, &xf, p)) {ui.ctx().set_cursor_icon(c);+ } else if let Some(p) = response.hover_pos().filter(|p| crate::corner_radius::hovers(app, xf.to_doc(*p))) {+ // Over a live rectangle's corner widget (or dragging one): the arrow with a rounded+ // corner badge, as Photoshop's corner radius cursor.+ ui.ctx().set_cursor_icon(egui::CursorIcon::Default);+ crate::icons::cursor_badge(&ctx, "scan", p);} else if let Some((r, p, c)) =response.hover_pos().and_then(|p| transform_controls_rect(app, &xf).and_then(|r| transform_controls_cursor(r, p).map(|c| (r, p, c)))){@@ -4543,7 +4548,13 @@ pub(crate) fn layer_edges_rect(app: &PhotocraftApp, idx: usize) -> Option<photoc/// Move tool › Show Transform Controls: the box Free Transform would open on the active layer.fn transform_controls_rect(app: &PhotocraftApp, xf: &ViewXform) -> Option<Rect> {- if app.ui.tool != Tool::Move || !app.ui.tool_options.move_show_transform || app.ui.transform.is_some() || app.drag.is_some() {+ // A corner radius drag hides the box, as in Photoshop.+ if app.ui.tool != Tool::Move+ || !app.ui.tool_options.move_show_transform+ || app.ui.transform.is_some()+ || app.drag.is_some()+ || app.ui.corner_radius.is_some()+ {return None;}let st = app.session.active()?;@@ -4957,6 +4968,10 @@ pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers)}// Move tool: ⇧ locks the axis, ⌥ duplicates (move_mods.rs).let ev = crate::move_mods::filter_event(app, ev, mods);+ // A live rectangle's corner radius widgets (Path Selection, Rectangle tool).+ if crate::corner_radius::pointer(app, ev, mods) {+ return;+ }// Direct Selection, and the Pen's ⌘ (Direct Selection) and ⌥ (Convert Point) modes (#790).if crate::direct_select::pointer(app, ev, mods) {return;diff --git a/crates/ui-egui/src/corner_radius.rs b/crates/ui-egui/src/corner_radius.rsnew file mode 100644index 000000000..b02e4d0ee--- /dev/null+++ b/crates/ui-egui/src/corner_radius.rs@@ -0,0 +1,232 @@+//! On-canvas corner radius widgets for live rectangles (TOOL-214-12), as in Photoshop: with Path+//! Selection, the Rectangle tool, or the Move tool showing its transform controls, every selected+//! shape layer that is a live rectangle shows a round widget inside each corner, at the centre of+//! its arc. Dragging one rounds every corner of every selected rectangle to the same radius;+//! ⌥/Alt changes that corner only, on each of them. The drag previews the new outlines and+//! commits one `shape.edit` with `radii` per changed layer on release, as one history step; a+//! click without movement changes nothing.++use egui::{Color32, Modifiers, Pos2, Stroke};+use photocraft_doc::LayerContent;+use photocraft_doc::vector::LiveShape;++use crate::PhotocraftApp;+use crate::canvas::ToolEvent;+use crate::state::Tool;++/// A widget sits at least this many screen points inside its corner, so a sharp corner's widget+/// can still be grabbed.+const MIN_INSET: f64 = 10.0;++/// A selected live rectangle: its layer, `[x, y, w, h]` with a positive size, and its radii.+#[derive(Clone, Copy, Debug, PartialEq)]+pub struct Target {+ layer: u64,+ rect: [f64; 4],+ radii: [f64; 4],+}++/// A corner radius drag in progress.+#[derive(Clone, Debug, PartialEq)]+pub struct Drag {+ /// Every selected live rectangle, as at the press.+ targets: Vec<Target>,+ /// The rectangle whose widget was pressed (an index into `targets`) and its corner,+ /// `[tl, tr, br, bl]` order.+ grabbed: usize,+ corner: usize,+ /// Every corner (no ⌥) or the dragged one only.+ all: bool,+ /// Where the press was.+ start: [f64; 2],+ /// Each target's radii so far.+ now: Vec<[f64; 4]>,+}++/// Do the widgets show with the current tool?+fn shows(app: &PhotocraftApp) -> bool {+ app.ui.transform.is_none()+ && match app.ui.tool {+ Tool::PathSelection | Tool::Rectangle => true,+ Tool::Move => app.ui.tool_options.move_show_transform,+ _ => false,+ }+}++/// The selected layers that are live rectangles, front first.+fn targets(app: &PhotocraftApp) -> Vec<Target> {+ if !shows(app) {+ return Vec::new();+ }+ let Some(st) = app.session.active() else { return Vec::new() };+ let mut out: Vec<Target> = st+ .selected_layers()+ .into_iter()+ .filter_map(|id| {+ let l = st.doc.layer(id)?;+ let LayerContent::Shape(sh) = &l.content else { return None };+ let Some(LiveShape::Rect { rect: [x, y, w, h], radii }) = sh.live else { return None };+ let (x, w) = if w < 0.0 { (x + w, -w) } else { (x, w) };+ let (y, h) = if h < 0.0 { (y + h, -h) } else { (y, h) };+ (w > 0.0 && h > 0.0 && [x, y, w, h].iter().chain(&radii).all(|v| v.is_finite())).then_some(Target { layer: l.id.0, rect: [x, y, w, h], radii })+ })+ .collect();+ // `selected_layers` lists bottom to top; the topmost widget wins a press.+ out.reverse();+ out+}++/// The largest radius a corner of `rect` takes.+fn max_radius(rect: [f64; 4]) -> f64 {+ rect[2].min(rect[3]) / 2.0+}++/// Corner `i` of `rect` and the unit-step direction pointing inside from it.+fn corner(rect: [f64; 4], i: usize) -> ([f64; 2], [f64; 2]) {+ let [x, y, w, h] = rect;+ match i {+ 0 => ([x, y], [1.0, 1.0]),+ 1 => ([x + w, y], [-1.0, 1.0]),+ 2 => ([x + w, y + h], [-1.0, -1.0]),+ _ => ([x, y + h], [1.0, -1.0]),+ }+}++/// Where corner `i`'s widget is drawn: the centre of its arc, or a few screen points inside a+/// sharper corner.+fn widget(rect: [f64; 4], radii: [f64; 4], i: usize, zoom: f64) -> [f64; 2] {+ let (c, d) = corner(rect, i);+ let r = radii.get(i).copied().unwrap_or(0.0).max(MIN_INSET / zoom).min(max_radius(rect));+ [c[0] + d[0] * r, c[1] + d[1] * r]+}++/// The radius the pressed corner `i` asks for when the pointer has moved from `start` to `p`: its+/// radius at the press plus the move projected onto the corner's diagonal (inward rounds more),+/// at least 0. Relative, so a click on a sharp corner's inset widget changes nothing. Each+/// rectangle then caps it at half its own shorter side.+fn radius_after(rect: [f64; 4], i: usize, from: f64, start: [f64; 2], p: [f64; 2]) -> f64 {+ let (_, d) = corner(rect, i);+ let r = from + ((p[0] - start[0]) * d[0] + (p[1] - start[1]) * d[1]) / 2.0;+ if r.is_finite() { r.max(0.0) } else { from }+}++fn zoom(app: &PhotocraftApp) -> f64 {+ f64::from(app.point_zoom().max(0.01))+}++/// The widget of `targets` within grabbing distance of document point `p`: the rectangle (an+/// index into `targets`) and its corner, the nearest when several are close.+fn hit(app: &PhotocraftApp, targets: &[Target], p: [f64; 2]) -> Option<(usize, usize)> {+ let z = zoom(app);+ let tol = 7.0 / z;+ targets+ .iter()+ .enumerate()+ .flat_map(|(t, g)| {+ (0..4).map(move |i| {+ let w = widget(g.rect, g.radii, i, z);+ (t, i, (w[0] - p[0]).hypot(w[1] - p[1]))+ })+ })+ .filter(|(.., d)| *d <= tol)+ .min_by(|a, b| a.2.total_cmp(&b.2))+ .map(|(t, i, _)| (t, i))+}++/// Is a widget under document point `p`, or one being dragged? The canvas then shows the corner+/// radius cursor.+pub fn hovers(app: &PhotocraftApp, p: [f64; 2]) -> bool {+ app.ui.corner_radius.is_some() || hit(app, &targets(app), p).is_some()+}++/// Canvas pointer events for the corner widgets; false when the event is not theirs.+pub fn pointer(app: &mut PhotocraftApp, ev: ToolEvent, mods: Modifiers) -> bool {+ match ev {+ ToolEvent::Down { x, y, .. } => {+ if mods.command {+ return false;+ }+ let targets = targets(app);+ let Some((grabbed, corner)) = hit(app, &targets, [x, y]) else { return false };+ let now = targets.iter().map(|t| t.radii).collect();+ app.ui.corner_radius = Some(Drag { targets, grabbed, corner, all: !mods.alt, start: [x, y], now });+ // The press may have started the Move tool's snapping, which a radius drag has none of.+ app.prefs_rt.snap = None;+ app.prefs_rt.snap_lines.clear();+ app.move_mods = Default::default();+ true+ }+ ToolEvent::Move { x, y, .. } => {+ let Some(d) = app.ui.corner_radius.as_mut() else { return false };+ let Some(g) = d.targets.get(d.grabbed) else { return true };+ let from = g.radii.get(d.corner).copied().unwrap_or(0.0).clamp(0.0, max_radius(g.rect));+ let r = radius_after(g.rect, d.corner, from, d.start, [x, y]);+ // Every selected rectangle takes the same radius, within its own size.+ for (t, now) in d.targets.iter().zip(d.now.iter_mut()) {+ let r = r.min(max_radius(t.rect));+ if d.all {+ *now = [r; 4];+ } else {+ *now = t.radii;+ if let Some(v) = now.get_mut(d.corner) {+ *v = r;+ }+ }+ }+ true+ }+ ToolEvent::Up { x, y } => {+ if app.ui.corner_radius.is_none() {+ return false;+ }+ pointer(app, ToolEvent::Move { x, y, pressure: 1.0 }, mods);+ let Some(d) = app.ui.corner_radius.take() else { return true };+ // One history step for every layer changed.+ let key = format!("corner-radius-{}", app.ui.alloc_id());+ for (t, now) in d.targets.iter().zip(&d.now) {+ if *now != t.radii+ && let Err(e) = app.run("shape.edit", serde_json::json!({"layer": t.layer, "radii": now, "coalesce": key}))+ {+ app.ui.status = e;+ app.ui.status_error = true;+ break;+ }+ }+ true+ }+ }+}++/// The radius the dragged corner shows in the readout.+fn dragged_radius(d: &Drag) -> Option<f64> {+ d.now.get(d.grabbed).and_then(|r| r.get(d.corner)).copied()+}++/// The widgets of every selected live rectangle; while one is dragged, the new outlines and the+/// radius beside the pointer (`R: 25.0 px`), as in Photoshop.+pub fn draw(app: &PhotocraftApp, painter: &egui::Painter, to_scr: &dyn Fn([f64; 2]) -> Pos2, accent: Color32) {+ let drag = app.ui.corner_radius.as_ref();+ if let Some(r) = drag.and_then(dragged_radius)+ && let Some(at) = painter.ctx().input(|i| i.pointer.hover_pos())+ {+ crate::canvas::draw_value_readout(app, painter.ctx(), "corner-radius-readout", at, ["R:"], [format!("{r:.1} px")]);+ }+ let z = zoom(app);+ for t in targets(app) {+ let now = drag.and_then(|d| d.targets.iter().position(|g| g.layer == t.layer).and_then(|i| d.now.get(i)));+ let radii = now.copied().unwrap_or(t.radii);+ if now.is_some() {+ let path = photocraft_vector::shapes::rounded_rect(t.rect[0], t.rect[1], t.rect[2], t.rect[3], radii);+ crate::vector_ui::draw_outline(painter, &path, to_scr, accent);+ }+ for i in 0..4 {+ let p = to_scr(widget(t.rect, radii, i, z));+ painter.circle(p, 5.0, Color32::WHITE, Stroke::new(1.5, accent));+ painter.circle_filled(p, 2.5, accent);+ }+ }+}++#[cfg(test)]+#[path = "corner_radius_tests.rs"]+mod tests;diff --git a/crates/ui-egui/src/corner_radius_tests.rs b/crates/ui-egui/src/corner_radius_tests.rsnew file mode 100644index 000000000..b0b47c45b--- /dev/null+++ b/crates/ui-egui/src/corner_radius_tests.rs@@ -0,0 +1,186 @@+//! TOOL-214-12: a live rectangle's corner radius widgets, as in Photoshop.++use egui::Modifiers;+use photocraft_doc::LayerContent;+use photocraft_doc::vector::LiveShape;+use serde_json::json;++use crate::PhotocraftApp;+use crate::canvas::{ToolEvent, tool_event};+use crate::state::Tool;++/// A 200 × 200 document at 100 % with a live rectangle at (40, 40), 120 × 80, radii 10.+fn app(tool: Tool) -> PhotocraftApp {+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ app.session.execute("file.new", json!({"width": 200, "height": 200})).unwrap();+ app.sync_views();+ app.run("shape.create", json!({"kind": "roundedRect", "rect": [40, 40, 120, 80], "radii": 10})).unwrap();+ app.ui.tool = tool;+ app+}++fn radii(app: &PhotocraftApp) -> Option<[f64; 4]> {+ let st = app.session.active()?;+ let l = st.active_layer.and_then(|id| st.doc.layer(id))?;+ match &l.content {+ LayerContent::Shape(sh) => match sh.live {+ Some(LiveShape::Rect { radii, .. }) => Some(radii),+ _ => None,+ },+ _ => None,+ }+}++fn steps(app: &PhotocraftApp) -> usize {+ app.session.active().unwrap().history.entries().len()+}++fn drag(app: &mut PhotocraftApp, from: [f64; 2], to: [f64; 2], mods: Modifiers) {+ tool_event(app, ToolEvent::Down { x: from[0], y: from[1], pressure: 1.0 }, mods);+ tool_event(app, ToolEvent::Move { x: to[0], y: to[1], pressure: 1.0 }, mods);+ tool_event(app, ToolEvent::Up { x: to[0], y: to[1] }, mods);+}++#[test]+fn dragging_a_widget_rounds_every_corner_in_one_step() {+ let mut app = app(Tool::PathSelection);+ let n = steps(&app);+ // The top-left widget sits at the arc centre (50, 50); dragging it 15 px along the diagonal+ // adds 15 to the radius.+ drag(&mut app, [50.0, 50.0], [65.0, 65.0], Modifiers::NONE);+ assert_eq!(radii(&app), Some([25.0; 4]));+ assert_eq!(steps(&app), n + 1, "one history step");+ assert!(app.ui.corner_radius.is_none());+ assert!(app.session.undo());+ assert_eq!(radii(&app), Some([10.0; 4]));+}++#[test]+fn alt_drags_one_corner_and_radii_stay_within_half_the_short_side() {+ let mut app = app(Tool::Rectangle);+ // The bottom-right widget, with ⌥: only that corner, capped at 40 (half of the height 80).+ drag(&mut app, [150.0, 110.0], [20.0, 20.0], Modifiers::ALT);+ assert_eq!(radii(&app), Some([10.0, 10.0, 40.0, 10.0]));+ // Dragging out past the corner makes it sharp.+ drag(&mut app, [150.0, 50.0], [190.0, 10.0], Modifiers::ALT);+ assert_eq!(radii(&app), Some([10.0, 0.0, 40.0, 10.0]));+ // The Rectangle tool drew no new shape.+ assert_eq!(app.session.active().unwrap().doc.layers.len(), 2);+}++#[test]+fn a_sharp_corner_keeps_a_grabbable_widget_and_a_click_changes_nothing() {+ let mut app = app(Tool::PathSelection);+ let id = app.session.active().unwrap().active_layer.unwrap().0;+ app.run("shape.edit", json!({"layer": id, "radii": 0})).unwrap();+ let n = steps(&app);+ // At 100 % the widget of a sharp corner is 10 px inside it.+ drag(&mut app, [50.0, 50.0], [50.0, 50.0], Modifiers::NONE);+ assert_eq!((radii(&app), steps(&app)), (Some([0.0; 4]), n), "a click commits nothing");+ drag(&mut app, [50.0, 50.0], [60.0, 60.0], Modifiers::NONE);+ assert_eq!(radii(&app), Some([10.0; 4]));+}++#[test]+fn only_live_rectangles_with_the_right_tools_take_the_press() {+ for tool in [Tool::Move, Tool::DirectSelection, Tool::Brush] {+ let mut a = app(tool);+ assert!(!super::pointer(&mut a, ToolEvent::Down { x: 50.0, y: 50.0, pressure: 1.0 }, Modifiers::NONE), "{tool:?}");+ }+ // ⌘/Ctrl leaves the press to the tool.+ let mut a = app(Tool::PathSelection);+ assert!(!super::pointer(&mut a, ToolEvent::Down { x: 50.0, y: 50.0, pressure: 1.0 }, Modifiers::COMMAND));+ // An ellipse has no corners.+ let mut a = app_with(json!({"kind": "ellipse", "rect": [40, 40, 120, 80]}));+ assert!(!super::pointer(&mut a, ToolEvent::Down { x: 50.0, y: 50.0, pressure: 1.0 }, Modifiers::NONE));+ // A press off the widgets is the tool's.+ let mut a = app(Tool::PathSelection);+ assert!(!super::pointer(&mut a, ToolEvent::Down { x: 100.0, y: 80.0, pressure: 1.0 }, Modifiers::NONE));+}++fn app_with(shape: serde_json::Value) -> PhotocraftApp {+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ app.session.execute("file.new", json!({"width": 200, "height": 200})).unwrap();+ app.sync_views();+ app.run("shape.create", shape).unwrap();+ app.ui.tool = Tool::PathSelection;+ app+}++/// Three live rectangles: (20, 20) 60 × 40 radii 5, (110, 20) 70 × 50 radii 0, and (20, 120)+/// 80 × 60 radii 0, the last one left unselected. Returns the ids, bottom first.+fn three(tool: Tool) -> (PhotocraftApp, Vec<photocraft_doc::LayerId>) {+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ app.session.execute("file.new", json!({"width": 200, "height": 200})).unwrap();+ app.sync_views();+ let mut ids = Vec::new();+ for (rect, r) in [([20, 20, 60, 40], 5), ([110, 20, 70, 50], 0), ([20, 120, 80, 60], 0)] {+ app.run("shape.create", json!({"kind": "rect", "rect": rect, "radii": r})).unwrap();+ ids.push(app.session.active().unwrap().active_layer.unwrap());+ }+ app.run("layer.select", json!({"layer": ids[0].0})).unwrap();+ app.run("layer.select", json!({"layer": ids[1].0, "mode": "add"})).unwrap();+ app.ui.tool = tool;+ (app, ids)+}++fn radii_of(app: &PhotocraftApp, id: photocraft_doc::LayerId) -> [f64; 4] {+ match &app.session.active().unwrap().doc.layer(id).unwrap().content {+ LayerContent::Shape(sh) => match sh.live {+ Some(LiveShape::Rect { radii, .. }) => radii,+ _ => panic!("live rect"),+ },+ _ => panic!("shape"),+ }+}++#[test]+fn one_widget_rounds_every_selected_rectangle_alike_in_one_step() {+ let (mut app, ids) = three(Tool::PathSelection);+ let n = steps(&app);+ // The second rectangle's top-left widget (sharp: 10 px inside, at (120, 30)), dragged 15 px+ // in each direction: radius 15 on every corner of both selected rectangles.+ drag(&mut app, [120.0, 30.0], [135.0, 45.0], Modifiers::NONE);+ assert_eq!(radii_of(&app, ids[0]), [15.0; 4]);+ assert_eq!(radii_of(&app, ids[1]), [15.0; 4]);+ assert_eq!(radii_of(&app, ids[2]), [0.0; 4], "the unselected one is untouched");+ assert_eq!(steps(&app), n + 1, "one history step for both layers");+ assert!(app.session.undo());+ assert_eq!((radii_of(&app, ids[0]), radii_of(&app, ids[1])), ([5.0; 4], [0.0; 4]));+}++#[test]+fn alt_changes_that_corner_on_each_and_each_stays_within_its_own_size() {+ let (mut app, ids) = three(Tool::Rectangle);+ // ⌥ on the first rectangle's top-left widget (radius 5, so drawn 10 px inside at (30, 30)),+ // dragged far in: each rectangle's top-left corner only, capped at half of its own short side.+ drag(&mut app, [30.0, 30.0], [100.0, 100.0], Modifiers::ALT);+ assert_eq!(radii_of(&app, ids[0]), [20.0, 5.0, 5.0, 5.0]);+ assert_eq!(radii_of(&app, ids[1]), [25.0, 0.0, 0.0, 0.0]);+}++#[test]+fn the_move_tool_shows_and_drags_the_widgets_with_its_transform_controls() {+ let (mut app, ids) = three(Tool::Move);+ assert!(!super::pointer(&mut app, ToolEvent::Down { x: 120.0, y: 30.0, pressure: 1.0 }, Modifiers::NONE), "not without the controls");+ app.ui.tool_options.move_show_transform = true;+ let before = app.session.active().unwrap().selected_layers();+ drag(&mut app, [120.0, 30.0], [130.0, 40.0], Modifiers::NONE);+ assert_eq!((radii_of(&app, ids[0]), radii_of(&app, ids[1])), ([10.0; 4], [10.0; 4]));+ assert_eq!(app.session.active().unwrap().selected_layers(), before, "the press neither moved nor reselected layers");+}++#[test]+fn the_cursor_and_readout_follow_the_widgets() {+ let mut app = app(Tool::PathSelection);+ // The corner radius cursor shows over a widget, not elsewhere.+ assert!(super::hovers(&app, [50.0, 50.0]));+ assert!(!super::hovers(&app, [100.0, 80.0]));+ // While dragging it stays, and the readout shows the dragged corner's radius.+ tool_event(&mut app, ToolEvent::Down { x: 50.0, y: 50.0, pressure: 1.0 }, Modifiers::NONE);+ tool_event(&mut app, ToolEvent::Move { x: 62.0, y: 62.0, pressure: 1.0 }, Modifiers::NONE);+ assert!(super::hovers(&app, [100.0, 80.0]));+ assert_eq!(app.ui.corner_radius.as_ref().and_then(super::dragged_radius), Some(22.0));+ tool_event(&mut app, ToolEvent::Up { x: 62.0, y: 62.0 }, Modifiers::NONE);+ assert!(!super::hovers(&app, [100.0, 80.0]));+}diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 5e7ab5e87..82797cb2b 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -58,6 +58,7 @@ pub mod color_picker_ui;pub mod color_range_ui;pub mod comps_ui;pub mod control;+pub mod corner_radius;pub mod credits;pub mod crop_mode;pub mod crop_overlay;diff --git a/crates/ui-egui/src/move_hover.rs b/crates/ui-egui/src/move_hover.rsindex 0db1a5c80..d94015fbd 100644--- a/crates/ui-egui/src/move_hover.rs+++ b/crates/ui-egui/src/move_hover.rs@@ -95,6 +95,11 @@ pub(crate) fn active_outline(app: &mut PhotocraftApp, at: Option<[f64; 2]>, commapp.canvas_hover_layer = None;return None;}+ // A live rectangle's corner widget under the pointer (or being dragged) isn't a layer to pick.+ if at.is_some_and(|p| crate::corner_radius::hovers(app, p)) {+ app.canvas_hover_layer = None;+ return None;+ }// A layer hovered in the Layers panel takes precedence over canvas rollover.if let Some(id) = app.hover_layer&& app.drag.is_none()diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rsindex df168648e..ba92b2a1d 100644--- a/crates/ui-egui/src/state.rs+++ b/crates/ui-egui/src/state.rs@@ -1144,6 +1144,9 @@ pub struct UiState {/// Direct Selection tool: selected anchors and the drag in progress (#790).#[serde(default)]pub direct_selection: crate::direct_select::DirectSelection,+ /// A live rectangle's corner radius widget being dragged (TOOL-214-12).+ #[serde(skip)]+ pub corner_radius: Option<crate::corner_radius::Drag>,/// Selected row in the Paths panel ("work" or a saved path name).#[serde(default)]pub selected_path: Option<String>,@@ -1332,6 +1335,7 @@ impl Default for UiState {pen: None,stroke_editor: None,direct_selection: Default::default(),+ corner_radius: None,selected_path: None,panels: Panels::default(),views: Vec::new(),diff --git a/crates/ui-egui/src/vector_ui.rs b/crates/ui-egui/src/vector_ui.rsindex d4df992fe..fe6db7407 100644--- a/crates/ui-egui/src/vector_ui.rs+++ b/crates/ui-egui/src/vector_ui.rs@@ -993,6 +993,7 @@ pub fn draw_overlay(app: &PhotocraftApp, painter: &egui::Painter, xf: &ViewXform}// The segment the Pen's Auto Add/Delete would add an anchor to, or the anchor it would delete.crate::anchor_tools::draw_pen_hover(app, painter, &to_scr, accent, painter.ctx().input(|i| i.modifiers));+ crate::corner_radius::draw(app, painter, &to_scr, accent);}// Pen path in progress, with handles of the last knot and a rubber band to the pointer. While// ⌘/Ctrl drags it, Direct Selection draws its preview instead.diff --git a/docs/scorecard.md b/docs/scorecard.mdindex 4b1022658..4a30e147a 100644--- a/docs/scorecard.md+++ b/docs/scorecard.md@@ -156,7 +156,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t| TOOL-214-9 | Crop: W x H x Resolution with units, saved crop presets, Straighten in the options bar | done | [#214](https://github.com/storytold/photocraft/issues/214) | Ratio dropdown and fields, Straighten (TOOL-214-21); W x H x Resolution with units, built-in size presets and Front Image (crop_size.rs, image.crop targetWidth/targetHeight/resolution, #2443); New / Delete Crop Preset save and delete crop tool presets (crop_presets.rs, tool.presets.* with tool crop, persisted with the preferences) || TOOL-214-10 | Pen: Alt breaks a handle, Shift 45 deg, Ctrl direct-selects, Backspace, close-drag handle | done | [#214](https://github.com/storytold/photocraft/issues/214) | Ctrl/Cmd = Direct Selection and Alt = Convert Point on existing paths (direct_select.rs, #790); Backspace/Delete retracts the last point while drawing (#1466); Alt during a drag breaks the handle pair, Alt-drag turns the last anchor's outgoing handle alone, and dragging on the first anchor closes with that anchor's handles (vector_ui.rs, #3306); Shift-click puts the next anchor on the nearest 45 deg ray from the previous one and Shift-drag turns the handles to 45 deg steps, live (vector_ui.rs pen_shift_click_puts_the_next_anchor_on_a_45_degree_ray, pen_shift_drag_turns_handles_to_45_degrees_live, #3751) || TOOL-214-11 | Stroke Path dialog: pick any brush-based tool, Simulate Pressure | done | [#214](https://github.com/storytold/photocraft/issues/214) | path.stroke tool: Brush, Pencil, Eraser and every other brush-based tool (Background Eraser, Clone/Pattern Stamp, Healing/Spot Healing Brush, History Brush, Blur, Sharpen, Smudge, Dodge, Burn, Sponge, Color Replacement, Mixer Brush: their paint.* command along the path, one step) plus simulatePressure (taper both ends); Stroke Path dialog from the Pen menu, the Paths panel menu and Alt-click on its Stroke button (#2978) |-| TOOL-214-12 | Shapes: on-canvas corner radius handles, shape feather, selection to shape with tolerance | partial | [#214](https://github.com/storytold/photocraft/issues/214) | select.convertToShape with tolerance (vector_cmds.rs:1256); radius as a field only |+| TOOL-214-12 | Shapes: on-canvas corner radius handles, shape feather, selection to shape with tolerance | partial | [#214](https://github.com/storytold/photocraft/issues/214) | On-canvas corner radius widgets on every selected live rectangle with Path Selection, the Rectangle tool and Move + Show Transform Controls: drag rounds every corner of every selected rectangle alike, Alt that corner on each, corner radius cursor and R: readout, one history step (corner_radius.rs, 2026-10-13); select.convertToShape with tolerance (vector_cmds.rs:1256). Missing: shape feather || TOOL-214-13 | Mask Properties: Density and Feather controls | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Vector-mask density/feather in the engine (vector_cmds.rs:948); no UI controls || TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | partial | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15); on-canvas plane editor (vp_ui.rs: Create/Edit Plane, edge nodes, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane on OK); clone stamp, marquee and tear-off planes in the window still missing || TOOL-214-15 | Content-Aware Fill workspace: paint the sampling area, preview, rotate/scale/mirror, new layer | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Engine sampling auto, rect, custom (edit_menu_cmds.rs:324); generic dialog |diff --git a/docs/target-app-parity.md b/docs/target-app-parity.mdindex c11ad8aff..c798116f8 100644--- a/docs/target-app-parity.md+++ b/docs/target-app-parity.md@@ -1,6 +1,6 @@# PhotoCraft vs Adobe Photoshop: target-app parity-> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-13 · **Change:** minor (`.atn` import maps 112 events; Free Transform H/V skew fields; stale rows corrected against `main` and the scorecard, estimates unchanged; Photoshop Actions `.atn` load and save; 2026-10-10: Tilt-Shift measurements added; earlier the same day: major, full re-measure against Photoshop 2026 27.11.0; merged `parity-estimate.md` and the roadmap's honest assessment; stale missing-tool rows corrected: Color Replacement and Red Eye are live toolbar tools, Frame landed; percentages unchanged) · **Target:** Adobe Photoshop 2026+> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-13 · **Change:** minor (on-canvas corner radius widgets, TOOL-214-12; `.atn` import maps 112 events; Free Transform H/V skew fields; stale rows corrected against `main` and the scorecard, estimates unchanged; Photoshop Actions `.atn` load and save; 2026-10-10: Tilt-Shift measurements added; earlier the same day: major, full re-measure against Photoshop 2026 27.11.0; merged `parity-estimate.md` and the roadmap's honest assessment; stale missing-tool rows corrected: Color Replacement and Red Eye are live toolbar tools, Frame landed; percentages unchanged) · **Target:** Adobe Photoshop 2026The authoritative answer to "how close is PhotoCraft to Photoshop, and how much work is left". Theone-page summary is [`ROADMAP.md`](../ROADMAP.md); the ranked work list is [`gaps.md`](gaps.md);@@ -174,7 +174,7 @@ parity for the area and are already contained in the dimension rows above.| Transform, warp, puppet, perspective, liquify | 55% | 100–180 | Free Transform modifiers right, with a right-click transform menu (TOOL-214-5) and H/V skew fields; Puppet Warp mesh follows the object outline (TOOL-214-6); Liquify called "useless" by a user (#2606) || Adjustments and filters | 70% | 120–200 | All present; smart-filter re-render matches Photoshop on 5 of 30 files; Filter Gallery looks approximate; no Neural Filters || Type | 40% | 120–200 | Engine works; no type on a path, manual kerning, RTL paragraphs, OpenType panel UI, live Warp Text preview; Type tool freeze on macOS (#2518) |-| Vector shapes and paths | 55% | 80–140 | Pen, Direct/Path Selection, shapes, shape strokes. Freeform and Curvature Pen (#1054). Add/Delete Anchor Point and Convert Point tools exist (`Tool` enum); missing on-canvas corner radius (TOOL-214-12), path-point nudge; shape parity tracking issue #2496 |+| Vector shapes and paths | 55% | 80–140 | Pen, Direct/Path Selection, shapes, shape strokes. Freeform and Curvature Pen (#1054). Add/Delete Anchor Point and Convert Point tools exist (`Tool` enum); on-canvas corner radius widgets on live rectangles (TOOL-214-12, 2026-10-13); missing path-point nudge; shape parity tracking issue #2496 || Colour management and modes | 70% | 60–100 | Own ICC engine, soft proof, CMYK/Lab/Indexed/Duotone/Multichannel; no Adobe CMYK profiles, no spot plates (FILE-215-17), monitor profile only at launch || Camera Raw and computational photo (Photomerge, HDR, lens) | 45% | 120–200 | Raw for DNG/CR2/NEF/ARW/RW2/ORF/RAF(uncompressed)/PEF; no CR3; ACR dialog partial (no masking, calibration); generic lens profiles only || Automation, actions, batch, scripting | 45% | 120–200 | CLI/MCP/control channel ahead of Photoshop; Actions panel and recording not document-independent (AUTO-219-1/2); `.atn` load/save since 2026-10-12 (112 events mapped, the rest kept verbatim); no ExtendScript/UXP |@@ -565,6 +565,7 @@ See [method, raw measurements and reproduction](five-algorithm-performance.md).| Date | Change | Summary ||---|---|---|+| 2026-10-13 | minor | Vector shapes: on-canvas corner radius widgets on live rectangles (TOOL-214-12); estimates unchanged || 2026-10-13 | minor | Stale "missing tool" rows corrected against main: Color Replacement (`paint.colorReplacement`), Red Eye (`paint.redEye`) and Add/Delete Anchor Point (the Pen flyout) are live toolbar tools and Frame landed, so Art History Brush is the only tool still missing; percentages unchanged || 2026-10-12 | minor | Free Transform options bar H/V skew fields; percentages unchanged || 2026-10-12 | minor | `.atn` import: 112 events mapped (TrueGrit Texture Supply sets play end to end); percentages unchanged |diff --git a/docs/ui-parity.md b/docs/ui-parity.mdindex d723d86f3..8f7748815 100644--- a/docs/ui-parity.md+++ b/docs/ui-parity.md@@ -1,6 +1,6 @@# UI parity: tools, handles, modifiers and feel-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed) · **Target:** Adobe Photoshop 2026+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed) · **Target:** Adobe Photoshop 2026How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, thehandles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation,@@ -123,7 +123,7 @@ Triangle and Curvature Pen (minus legacy Rounded Rectangle and Targeted Adjustme| Pen Auto Add/Delete: click a segment of the active path to add, an anchor to delete; ⇧ suspends it | done | #4144 || Curvature Pen edits the active path with no modifier: drag an anchor (the curve reflows), click a segment to add an anchor, double-click smooth ↔ corner; cursor badge + on segments, four arrows on anchors | done: `direct_select.rs` (`curvature_press`, `curvature_hover`), `path.moveAnchors`/`path.convertPoint` with `curvature`, `direct_select_tests.rs` | || Path operations in the options bar (combine, subtract, intersect, exclude) | partial | `layer.combineShapes.*`; Pen options #1397 |-| On-canvas corner-radius handles on live shapes | missing | TOOL-214-12 |+| On-canvas corner-radius handles on live shapes | done: every selected live rectangle shows a widget at each arc centre with Path Selection, the Rectangle tool and Move with Show Transform Controls; a drag rounds every corner of every selected rectangle to the same radius, ⌥ that corner on each, with the corner radius cursor and an `R:` readout, previewed and committed as one history step (`corner_radius.rs`, `corner_radius_tests.rs`) | TOOL-214-12 || Shape stroke controls (dash, caps, joins, align) | done | TOOL-1053-1, [`shape-strokes.md`](shape-strokes.md) || Rotated shape selection hints correct | partial | #2512 || Curved shape bounds exact | partial | one pixel too wide (#2537) |@@ -242,6 +242,7 @@ Paragraph; the rest open as in-app floating windows.| 2026-10-12 | minor | Free Transform options bar: H and V skew fields; a sheared box reads as skew instead of a taller H || 2026-10-12 | minor | Layers panel: Clip Thumbnails to Layer Bounds frames each layer's pixels instead of the canvas (#4281) || 2026-10-13 | minor | Smart filter rows can be dragged up or down their stack to reorder the filters |+| 2026-10-13 | minor | On-canvas corner radius widgets on live rectangles (TOOL-214-12) || 2026-10-13 | minor | Curvature Pen edits the active path: drag anchors, click a segment to add, double-click smooth/corner, cursor badges || 2026-10-11 | minor | Pen ⇧ 45° done: ⇧-click puts the next anchor on the nearest 45° ray, ⇧-drag turns its handles in 45° steps (TOOL-214-10 done, #3751) || 2026-10-14 | minor | Last selected tool restored across launches; temporary overrides excluded, explicit Eraser choices retained, and final selection flushed on normal exit |diff --git a/scorecard/tools.toml b/scorecard/tools.tomlindex bc33d2009..ac7b43368 100644--- a/scorecard/tools.toml+++ b/scorecard/tools.toml@@ -192,7 +192,7 @@ id = "TOOL-214-12"target = "Shapes: on-canvas corner radius handles, shape feather, selection to shape with tolerance"status = "partial"issue = 214-note = "select.convertToShape with tolerance (vector_cmds.rs:1256); radius as a field only"+note = "On-canvas corner radius widgets on every selected live rectangle with Path Selection, the Rectangle tool and Move + Show Transform Controls: drag rounds every corner of every selected rectangle alike, Alt that corner on each, corner radius cursor and R: readout, one history step (corner_radius.rs, 2026-10-13); select.convertToShape with tolerance (vector_cmds.rs:1256). Missing: shape feather"[[item]]id = "TOOL-214-13"