diff --git a/crates/doc/src/corners.rs b/crates/doc/src/corners.rs index 24228604a6..3810bbb1f5 100644 --- a/crates/doc/src/corners.rs +++ b/crates/doc/src/corners.rs @@ -205,8 +205,8 @@ impl<'a> LiveCorners<'a> { /// Set `radius` (document units; negative: 0) and/or `kind` on the `corners` (anchor indices of /// the uncut outline, see [`LiveCorners`]) of a path and its live shape, then cut the path again. /// A path that isn't a live shape keeps its uncut outline as a [`LiveShape::Path`], which is a -/// plain path again once no corner is cut. Ellipses and lines have no corners: they stay as they -/// are. +/// plain path again once no corner is cut, unless its rounding is Relative. Ellipses and lines +/// have no corners: they stay as they are. pub fn set_corners(path: &mut PathData, live: &mut Option>, corners: &BTreeSet, radius: Option, kind: Option) { fn edit( base: &PathData, @@ -268,7 +268,8 @@ pub fn set_corners(path: &mut PathData, live: &mut Option>, corne LiveShape::Ellipse { .. } | LiveShape::Line { .. } => return, } match live.as_deref_mut() { - Some(LiveShape::Path { base, radii, kinds, .. }) if radii.is_empty() && kinds.is_empty() => { + // A path with Relative rounding keeps its record, and with it the rounding. + Some(LiveShape::Path { base, radii, kinds, radii_relative: false }) if radii.is_empty() && kinds.is_empty() => { *path = std::mem::take(base); *live = None; } diff --git a/crates/engine/src/cmd/object/commands.rs b/crates/engine/src/cmd/object/commands.rs index 0bc08c748e..98b5579cbb 100644 --- a/crates/engine/src/cmd/object/commands.rs +++ b/crates/engine/src/cmd/object/commands.rs @@ -305,7 +305,7 @@ pub fn specs() -> Vec { "Live Shape Properties", [], None, - "{id?, ids?, radius?: pt (or % of each corner's maximum when `relativeRadii` is true), kind?: \"round\"|\"invertedRound\"|\"chamfer\", relativeRadii?: bool (Relative rounding, as in the reference app: store radii as fractions of each corner's maximum so they scale with the shape), corners?: [i…], rectanglesOnly?: bool (only the live rectangles among the targets; the other objects stay as they are), items?: [{id, corners?: [i…]}] (several objects, each with its own corners, in place of ids and corners: the canvas's corner widgets across a selection), sides?: n, polygonAngle?: degrees (counter-clockwise from its first vertex straight up), polygonRadius?: pt (centre to vertex), sideLength?: pt (sets the radius), makeSidesEqual?: true (a polygon scaled unevenly: drops the uneven scale and shear, keeping its centre, angle and mean radius), pieStart?, pieEnd?: degrees (an ellipse's pie, counter-clockwise from 3 o'clock; 0 to 360 is the whole ellipse), invertPie?: true (swaps them: the other part of the ellipse), constrainPie?: bool (Constrain Pie Angle: with one of pieStart and pieEnd, not both and not with invertPie, the other angle moves by as much, so each ellipse keeps its span), lineLength?: pt (a live line's length, above 0; its first end stays), lineAngle?: degrees (a live line's angle, counter-clockwise from 3 o'clock, from its first end to its second; it turns about its midpoint), rectangleAngle?: degrees (a live rectangle's, counterclockwise from level), ellipseAngle?: degrees (a live ellipse's, counterclockwise from level; its pie turns with it)} (rectangleAngle, ellipseAngle and polygonAngle turn each shape of that kind about its own center and leave other objects as they are; a pixel-aligned shape then goes back on the pixel grid, as after other edits, which can move its center or change its size; an angle that is not a number is an error, and `null` counts as an omitted key; a shape that a turn would take past the coordinate limit (±4,000,000 pt) is an error that changes nothing; Live Corners on any path: radius and kind set its corners (anchors that aren't smooth, where two sides, straight or curved (#1144), meet at an angle): `corners` (anchor indices of the path with its corners uncut, counting every subpath's anchors in order: a rectangle's 0 top-left, 1 top-right, 2 bottom-right, 3 bottom-left; a polygon's from the first vertex clockwise), else the corners with a Direct-Selected anchor, else every corner; each radius is drawn no larger than half the corner's shorter side allows; a path that isn't a live shape keeps its uncut outline so its corners stay editable, and is plain again once none is cut; sides: a polygon's, which keep the radius they shared; the polygon params apply in that order: sides, makeSidesEqual, polygonAngle, then sideLength or else polygonRadius; a line's lineLength applies before its lineAngle)", + "{id?, ids?, radius?: pt (or % of each corner's maximum when `relativeRadii` is true), kind?: \"round\"|\"invertedRound\"|\"chamfer\", relativeRadii?: bool (Relative rounding: store radii as fractions of each corner's maximum so they scale with the shape; it applies to a whole path: a live rectangle, a live polygon or any path with a corner, which keeps its outline as the base of its Live Corners; a path without Live Corners is Absolute, and a path whose anchors are edited loses its Live Corners and is Absolute again; ellipses and lines are left as they are), corners?: [i…], rectanglesOnly?: bool (only the live rectangles among the targets; the other objects stay as they are), items?: [{id, corners?: [i…]}] (several objects, each with its own corners, in place of ids and corners: the canvas's corner widgets across a selection), sides?: n, polygonAngle?: degrees (counter-clockwise from its first vertex straight up), polygonRadius?: pt (centre to vertex), sideLength?: pt (sets the radius), makeSidesEqual?: true (a polygon scaled unevenly: drops the uneven scale and shear, keeping its centre, angle and mean radius), pieStart?, pieEnd?: degrees (an ellipse's pie, counter-clockwise from 3 o'clock; 0 to 360 is the whole ellipse), invertPie?: true (swaps them: the other part of the ellipse), constrainPie?: bool (Constrain Pie Angle: with one of pieStart and pieEnd, not both and not with invertPie, the other angle moves by as much, so each ellipse keeps its span), lineLength?: pt (a live line's length, above 0; its first end stays), lineAngle?: degrees (a live line's angle, counter-clockwise from 3 o'clock, from its first end to its second; it turns about its midpoint), rectangleAngle?: degrees (a live rectangle's, counterclockwise from level), ellipseAngle?: degrees (a live ellipse's, counterclockwise from level; its pie turns with it)} (rectangleAngle, ellipseAngle and polygonAngle turn each shape of that kind about its own center and leave other objects as they are; a pixel-aligned shape then goes back on the pixel grid, as after other edits, which can move its center or change its size; an angle that is not a number is an error, and `null` counts as an omitted key; a shape that a turn would take past the coordinate limit (±4,000,000 pt) is an error that changes nothing; Live Corners on any path: radius and kind set its corners (anchors that aren't smooth, where two sides, straight or curved (#1144), meet at an angle): `corners` (anchor indices of the path with its corners uncut, counting every subpath's anchors in order: a rectangle's 0 top-left, 1 top-right, 2 bottom-right, 3 bottom-left; a polygon's from the first vertex clockwise), else the corners with a Direct-Selected anchor, else every corner; each radius is drawn no larger than half the corner's shorter side allows; a path that isn't a live shape keeps its uncut outline so its corners stay editable, and is plain again once none is cut, unless its rounding is Relative; sides: a polygon's, which keep the radius they shared; the polygon params apply in that order: sides, makeSidesEqual, polygonAngle, then sideLength or else polygonRadius; a line's lineLength applies before its lineAngle)", has_selection, set_live_shape ), diff --git a/crates/engine/src/cmd/object/shape.rs b/crates/engine/src/cmd/object/shape.rs index a4cec6253c..24274782d8 100644 --- a/crates/engine/src/cmd/object/shape.rs +++ b/crates/engine/src/cmd/object/shape.rs @@ -99,6 +99,17 @@ fn corners_param(p: &Value) -> Result>> { list.iter().map(|k| k.as_u64().and_then(|k| usize::try_from(k).ok()).ok_or_else(err)).collect::>().map(Some) } +/// Whether `relativeRadii` applies to a path drawn as `path` with live shape `live`: a live +/// rectangle, a live polygon, a path with Live Corners, or a plain path with a corner. A plain +/// path's rounding is Absolute. +fn takes_rounding(path: &PathData, live: Option<&LiveShape>) -> bool { + match live { + Some(LiveShape::Rectangle { .. } | LiveShape::Polygon { .. } | LiveShape::Path { .. }) => true, + Some(LiveShape::Ellipse { .. } | LiveShape::Line { .. }) => false, + None => LiveCorners::new(path, None).is_some_and(|c| !c.all().is_empty()), + } +} + /// Live line `l` with Line Length `len` (its first end stays) and then Line Angle `angle` (about /// its midpoint; a line whose ends meet has none to turn), or None when neither changes it. fn line_edit(l: &LiveShape, len: Option, angle: Option) -> Option { @@ -277,7 +288,7 @@ pub(super) fn set_live_shape(s: &mut Session, p: &Value) -> Result { Some(l @ LiveShape::Rectangle { .. }) if rectangle_angle.is_some_and(|a| !at_angle(l.shape_angle(), a)) => return false, _ => {} } - if relative_radii.is_some_and(|on| live.as_deref().map(|l| l.radii_relative()) != Some(on)) { + if relative_radii.is_some_and(|on| takes_rounding(path, live.as_deref()) && live.as_deref().is_some_and(LiveShape::radii_relative) != on) { return false; } if radius.is_none() && kind.is_none() { @@ -291,10 +302,17 @@ pub(super) fn set_live_shape(s: &mut Session, p: &Value) -> Result { && picked.iter().all(|k| { *k < c.base.anchor_count() // A radius stored in document units can be larger than it draws; a relative - // one is a fraction, so it is compared as drawn. + // one is compared as the fraction `set_corners` would store for it, to a + // precision of 1e-9 pt on a corner whose maximum is 1 pt or more. && radius.is_none_or(|r| { - let now = if c.radii_relative() { c.drawn_radius(*k) } else { c.radius(*k) }; - (now - r.max(0.0)).abs() < 1e-9 + let r = r.max(0.0); + if c.radii_relative() { + let max = c.corner(*k).map_or(0.0, |c| c.max_radius()); + let fraction = if max > 1e-12 { (r / max).clamp(0.0, 1.0) } else { 0.0 }; + (c.radius(*k) - fraction).abs() * max.max(1.0) < 1e-9 + } else { + (c.radius(*k) - r).abs() < 1e-9 + } }) && kind.is_none_or(|kd| c.kind(*k) == kd) }) @@ -348,11 +366,23 @@ pub(super) fn set_live_shape(s: &mut Session, p: &Value) -> Result { *l = new.clone(); *path = l.to_path(); } + // A path with corners and no Live Corners yet keeps its outline as their base, so that + // Relative rounding has a record to go in. + if relative_radii == Some(true) && live.is_none() && takes_rounding(path, None) { + *live = Some(Box::new(LiveShape::Path { base: path.clone(), radii: vec![], kinds: vec![], radii_relative: false })); + } if let Some(on) = relative_radii && let Some(l) = live.as_deref_mut() { convert_radii_relative(l, on); *path = l.to_path(); + // Absolute with no corner cut: a plain path again, as `set_corners` leaves one. + if let LiveShape::Path { radii, kinds, radii_relative: false, .. } = l + && radii.is_empty() + && kinds.is_empty() + { + *live = None; + } } if radius.is_none() && kind.is_none() { continue; diff --git a/crates/engine/src/tests/livecorners.rs b/crates/engine/src/tests/livecorners.rs index 288f0236d1..35d4f061ec 100644 --- a/crates/engine/src/tests/livecorners.rs +++ b/crates/engine/src/tests/livecorners.rs @@ -910,6 +910,69 @@ fn relative_corner_rounding_keeps_fraction_on_resize() { assert!((c.drawn_radius(0) / drawn - 2.0).abs() < 0.05, "drawn radius doubled with the shape"); } +/// Relative rounding on a path with corners and no Live Corners yet takes effect in one undo step, +/// a radius set afterwards is stored as a fraction, and the rounding stays when no corner is cut +/// any more. Absolute, which such a path already has, and Relative on an ellipse, which has no +/// corners, add no undo step. +#[test] +fn relative_rounding_takes_on_a_plain_path() { + let (mut s, id) = session(); + s.execute("select.set", &json!({"ids": [id.0]})).unwrap(); + s.execute("object.expandShape", &json!({})).unwrap(); + assert!(s.doc().unwrap().doc.node(id).unwrap().live_shape().is_none(), "a plain path"); + let steps = |s: &Session| s.doc().unwrap().history.undo.len(); + let n = steps(&s); + run(&mut s, json!({"ids": [id.0], "relativeRadii": false})); + assert_eq!(steps(&s), n, "Absolute: no change"); + run(&mut s, json!({"ids": [id.0], "relativeRadii": true})); + assert_eq!(steps(&s), n + 1, "Relative: one undo step"); + let node = s.doc().unwrap().doc.node(id).unwrap(); + assert!(LiveCorners::of(node).unwrap().radii_relative()); + let max = LiveCorners::of(node).unwrap().corner(0).unwrap().max_radius(); + run(&mut s, json!({"ids": [id.0], "corners": [0], "radius": max / 2.0})); + let c = LiveCorners::of(s.doc().unwrap().doc.node(id).unwrap()).unwrap(); + assert!(c.radii_relative() && (c.radius(0) - 0.5).abs() < 1e-9, "stored fraction: {}", c.radius(0)); + // With no corner cut again, the path keeps its Relative rounding. + run(&mut s, json!({"ids": [id.0], "corners": [0], "radius": 0})); + let c = LiveCorners::of(s.doc().unwrap().doc.node(id).unwrap()).unwrap(); + assert!(c.radii_relative() && c.radius(0) == 0.0, "still Relative"); + // Absolute again with no corner cut: a plain path again. + run(&mut s, json!({"ids": [id.0], "relativeRadii": false})); + assert!(s.doc().unwrap().doc.node(id).unwrap().live_shape().is_none(), "a plain path again"); + let e = s.execute("shape.ellipse", &json!({"x": 200, "y": 200, "width": 50, "height": 30})).unwrap()["id"].as_u64().unwrap(); + let n = steps(&s); + run(&mut s, json!({"ids": [e], "relativeRadii": true})); + assert_eq!(steps(&s), n, "an ellipse: no change"); +} + +/// With Relative rounding, a radius is compared as the fraction it would store: a radius past the +/// corner's maximum, typed again, and the maximum the field then shows add no undo step, while a +/// smaller one adds one. +#[test] +fn a_relative_radius_that_stores_the_same_fraction_adds_no_undo_step() { + let (mut s, id) = session(); + run(&mut s, json!({"relativeRadii": true})); + let steps = |s: &Session| s.doc().unwrap().history.undo.len(); + let max = LiveCorners::of(s.doc().unwrap().doc.node(id).unwrap()).unwrap().corner(0).unwrap().max_radius(); + let n = steps(&s); + run(&mut s, json!({"corners": [0], "radius": max + 20.0})); + assert_eq!(steps(&s), n + 1, "past the maximum: one undo step"); + let c = LiveCorners::of(s.doc().unwrap().doc.node(id).unwrap()).unwrap(); + assert!((c.radius(0) - 1.0).abs() < 1e-9, "stored as the whole maximum: {}", c.radius(0)); + run(&mut s, json!({"corners": [0], "radius": max + 20.0})); + assert_eq!(steps(&s), n + 1, "the same radius again: no undo step"); + run(&mut s, json!({"corners": [0], "radius": max})); + assert_eq!(steps(&s), n + 1, "the maximum, as shown: no undo step"); + run(&mut s, json!({"corners": [0], "radius": max / 2.0})); + assert_eq!(steps(&s), n + 2, "a smaller radius: one undo step"); + // On a large shape a small radius is a fraction below 1e-9, and still a change. + let big = s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 3_000_000, "height": 3_000_000})).unwrap()["id"].as_u64().unwrap(); + run(&mut s, json!({"ids": [big], "relativeRadii": true})); + let n = steps(&s); + run(&mut s, json!({"ids": [big], "corners": [0], "radius": 0.001})); + assert_eq!(steps(&s), n + 1, "a small radius on a large shape: one undo step"); +} + /// #2898: while a corner widget is pressed or dragged, Up and Down step the corners' kind (round, /// inverted round, chamfer, in turn) along with the radius, as one undo step with the drag. #[test] diff --git a/crates/ui-egui/src/chrome/control_bar.rs b/crates/ui-egui/src/chrome/control_bar.rs index ce7f95808d..8831816527 100644 --- a/crates/ui-egui/src/chrome/control_bar.rs +++ b/crates/ui-egui/src/chrome/control_bar.rs @@ -78,45 +78,18 @@ pub fn anchor_buttons(app: &mut VectorcraftApp, ui: &mut Ui, controls: AnchorCon } } -/// The selected paths' eligible corners, as document lengths, beside the anchor controls. -/// Explicit partial selections with no corners contribute no target (unlike `picked`'s fallback). -fn corner_radius(app: &mut VectorcraftApp, ui: &mut Ui, t: &Tokens, reserve: f32) { - let Some(st) = app.session.active() else { return }; - let mut items = Vec::new(); - let mut radius: Option = None; - let mut mixed = false; - for &id in &st.selection.objects { - let Some(lc) = st.doc.node(id).and_then(vectorcraft_doc::LiveCorners::of) else { continue }; - let corners = st.selection.partial(id).map_or_else(|| lc.all(), |anchors| lc.corners_of(anchors)); - if corners.is_empty() { - continue; - } - for &k in &corners { - // Keep absolute requested radii, even when their drawing is fitted smaller. Relative - // storage is a fraction, but the field and setLiveShape both consume document lengths. - let value = if lc.radii_relative() { lc.radius(k) * lc.corner(k).map_or(0.0, |c| c.max_radius()) } else { lc.radius(k) }; - if let Some(first) = radius { - mixed |= (first - value).abs() >= 1e-9; - } else { - radius = Some(value); - } - } - items.push(json!({"id": id, "corners": corners})); - } - if items.is_empty() { +/// The Corners link and the radius of the selected paths' picked corners +/// ([`crate::panels::picked_corners`]), beside the anchor controls. The link opens the Corners +/// pop-up for those corners. +fn corner_radius(app: &mut VectorcraftApp, ui: &mut Ui, reserve: f32) { + let Some(picked) = crate::panels::picked_corners(app) else { return }; + if ui.available_width() < row_width(ui, &[crate::panels::corners_link_width(ui), INLINE_FIELD_WIDTH]) + reserve { return; } - let label = tl!("Corner Radius:"); - let text = egui::RichText::new(label).size(12.0).color(t.text); - if ui.available_width() < row_width(ui, &[widgets::text_width(ui, text.clone()), INLINE_FIELD_WIDTH]) + reserve { - return; - } - widgets::field_label(ui, text); - let shown = if mixed { None } else { radius }; + crate::panels::corners_link(app, ui, "cb-corners"); let unit = app.session.general_unit(); - if let Some(radius) = widgets::num_field_named(ui, "cb-corner-radius", Some(label), shown, unit, INLINE_FIELD_WIDTH) { - // App::run reports any command failure in the status bar, as the other inline fields do. - app.run("object.setLiveShape", json!({"items": items, "radius": radius.max(0.0)})).ok(); + if let Some(radius) = widgets::num_field_named(ui, "cb-corner-radius", Some(tl!("Corner Radius:")), picked.radius, unit, INLINE_FIELD_WIDTH) { + crate::panels::set_picked_corners(app, &picked, json!({"radius": radius.max(0.0)})); } } @@ -1083,7 +1056,7 @@ fn contents(app: &mut VectorcraftApp, ui: &mut Ui, t: &Tokens, bar: egui::Rect, if anchors != AnchorControls::None && group_on(app, "anchors") { anchor_buttons(app, ui, anchors); let reserve = transform_reserve(app, ui, count > 0); - corner_radius(app, ui, t, reserve); + corner_radius(app, ui, reserve); } let object_options = group_on(app, "objectOptions"); if object_options { diff --git a/crates/ui-egui/src/chrome/tests.rs b/crates/ui-egui/src/chrome/tests.rs index 3b889b1f09..b6c7a47015 100644 --- a/crates/ui-egui/src/chrome/tests.rs +++ b/crates/ui-egui/src/chrome/tests.rs @@ -4383,6 +4383,47 @@ fn the_anchor_points_group_holds_convert_and_anchors() { assert!(has(&bar, "Anchor Point") && has(&bar, "Stroke:"), "{bar:?}"); } +/// With three corners of a path Direct-Selected, the Control bar's Corners link opens the Corners +/// pop-up; a kind picked there sets those three corners and leaves the fourth, in one undo step. +#[test] +fn the_control_bar_corners_link_opens_the_pop_up_for_the_picked_corners() { + use vectorcraft_geom::shapes::CornerKind; + crate::i18n::set_current(crate::i18n::Lang::EN); + let mut app = crate::VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + let id = app.run("shape.rectangle", json!({"x": 50, "y": 50, "width": 100, "height": 100})).unwrap()["id"].clone(); + app.run("select.set", json!({"ids": [id]})).unwrap(); + app.run("object.expandShape", json!({})).unwrap(); + app.select_tool("directSelection"); + app.run("select.anchors", json!({"id": id, "anchors": [[0, 0], [0, 1], [0, 2]], "mode": "set"})).unwrap(); + let ctx = egui::Context::default(); + ctx.enable_accesskit(); + crate::theme::install_fonts(&ctx); + let mut frame = |app: &mut crate::VectorcraftApp, events| control_bar_frame(app, &ctx, events); + let click = |frame: &mut dyn FnMut(&mut crate::VectorcraftApp, Vec) -> Vec, + app: &mut crate::VectorcraftApp, + name: &str| { + let at = node_center(&frame(app, vec![]), name).unwrap_or_else(|| panic!("{name} shows")); + frame(app, vec![egui::Event::PointerMoved(at), press_at(at, true)]); + frame(app, vec![press_at(at, false)]); + frame(app, vec![]); + frame(app, vec![]) + }; + frame(&mut app, vec![]); + let nodes = frame(&mut app, vec![]); + assert!(node_center(&nodes, "Chamfer").is_none(), "the pop-up starts closed"); + let nodes = click(&mut frame, &mut app, "Corners"); + for name in ["Round", "Inverted Round", "Chamfer", "Radius:", "Relative", "Absolute"] { + assert!(node_center(&nodes, name).is_some(), "the pop-up has {name}"); + } + let depth = app.session.doc().unwrap().history.undo.len(); + click(&mut frame, &mut app, "Chamfer"); + assert_eq!(app.session.doc().unwrap().history.undo.len(), depth + 1, "one undo step"); + let n = app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(id.as_u64().unwrap())).unwrap().clone(); + let lc = vectorcraft_doc::LiveCorners::of(&n).unwrap(); + assert_eq!((0..4).map(|k| lc.kind(k)).collect::>(), [CornerKind::Chamfer, CornerKind::Chamfer, CornerKind::Chamfer, CornerKind::Round]); +} + /// Menus stop above a Control bar docked at the bottom when the status bar is hidden, above the /// status and hint bars when they show, and at the bottom of the window when the bar is docked at /// the top or a screen mode hides it. diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 6c4d7860e7..d7f4c6327a 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -216,6 +216,118 @@ pub(crate) fn corner_radius_field(app: &mut VectorcraftApp, ui: &mut Ui, n: &Nod } } +/// The corners that the Corners link, its pop-up and the Corner Radius field beside it edit: +/// [`picked_corners`]. +pub(crate) struct PickedCorners { + /// `object.setLiveShape`'s `items`: `{id, corners}` for each path. + pub items: Vec, + /// The radius the corners share, as a document length; None when they differ. + pub radius: Option, + /// The kind the corners share; None when they differ. + pub kind: Option, + /// Whether their paths store relative radii; None when the paths differ. + pub relative: Option, +} + +/// The picked corners of the selection: for each selected path with Live Corners, the corners +/// holding a Direct-Selected anchor, or every corner of a path selected whole. A path whose +/// selected anchors hold no corner adds none. None when no path adds a corner. +pub(crate) fn picked_corners(app: &VectorcraftApp) -> Option { + fn shared(values: &[T], same: impl Fn(T, T) -> bool) -> Option { + let (&first, rest) = values.split_first()?; + rest.iter().all(|v| same(*v, first)).then_some(first) + } + let st = app.session.active()?; + let (mut items, mut radii, mut kinds, mut relative) = (Vec::new(), Vec::new(), Vec::new(), Vec::new()); + for &id in &st.selection.objects { + let Some(lc) = st.doc.node(id).and_then(LiveCorners::of) else { continue }; + let corners = st.selection.partial(id).map_or_else(|| lc.all(), |anchors| lc.corners_of(anchors)); + if corners.is_empty() { + continue; + } + for &k in &corners { + // The radius asked for, even where it draws smaller. A relative radius is stored as a + // fraction of the corner's largest; the field and `object.setLiveShape` take lengths. + radii.push(if lc.radii_relative() { lc.radius(k) * lc.corner(k).map_or(0.0, |c| c.max_radius()) } else { lc.radius(k) }); + kinds.push(lc.kind(k)); + } + relative.push(lc.radii_relative()); + items.push(json!({"id": id, "corners": corners})); + } + if items.is_empty() { + return None; + } + Some(PickedCorners { + items, + radius: shared(&radii, |a, b| (a - b).abs() < 1e-9), + kind: shared(&kinds, |a, b| a == b), + relative: shared(&relative, |a, b| a == b), + }) +} + +/// Run `object.setLiveShape` with `p` (a `kind`, `radius` or `relativeRadii`) on `picked`'s +/// corners: one undo step, or none when nothing changes. `App::run` reports a failure in the +/// status bar. +pub(crate) fn set_picked_corners(app: &mut VectorcraftApp, picked: &PickedCorners, mut p: Value) { + p["items"] = json!(picked.items); + app.run("object.setLiveShape", p).ok(); +} + +/// The Corners link's text, as [`corners_link`] draws it and [`corners_link_width`] measures it. +fn corners_link_text(ui: &Ui) -> egui::RichText { + egui::RichText::new(tl!("Corners")).size(12.0).color(Tokens::get(ui.ctx()).text).underline() +} + +/// The width of [`corners_link`] in `ui`, with the point that the underline can add at its end. +pub(crate) fn corners_link_width(ui: &Ui) -> f32 { + crate::widgets::text_width(ui, corners_link_text(ui)) + 1.0 +} + +/// The Corners link of the Control bar and the Properties panel: a click on it opens or closes +/// [`corners_popup`] under it. `id` tells the two places apart. +pub(crate) fn corners_link(app: &mut VectorcraftApp, ui: &mut Ui, id: &str) { + let resp = ui.link(corners_link_text(ui)); + crate::widgets::popover(&resp, resp.clicked(), |ui| corners_popup(app, ui, id)); +} + +/// The Corners pop-up: the corner kind, the radius (blank while the picked corners differ) and +/// the rounding, Relative or Absolute (neither while their paths differ), of the picked corners +/// ([`picked_corners`]). Each change sets them on those corners alone, in one undo step. +fn corners_popup(app: &mut VectorcraftApp, ui: &mut Ui, id: &str) { + let Some(picked) = picked_corners(app) else { return }; + let unit = app.session.general_unit(); + let mut set = None; + egui::Grid::new((id, "corners-popup")).num_columns(2).spacing([6.0, 6.0]).show(ui, |ui| { + dim_label(ui, tl!("Corner:")); + ui.vertical(|ui| { + for k in CornerKind::ALL { + if crate::widgets::radio(ui, crate::dialogs::corners::kind_label(k), picked.kind == Some(k), true) { + set = Some(json!({"kind": k})); + } + } + }); + ui.end_row(); + dim_label(ui, tl!("Radius:")); + if let Some(r) = crate::widgets::num_field_named(ui, (id, "radius"), Some(tl!("Radius:")), picked.radius, unit, 100.0) { + // A negative radius typed in rounds nothing: the command takes 0 or more. + set = Some(json!({"radius": r.max(0.0)})); + } + ui.end_row(); + ui.label(""); + ui.horizontal(|ui| { + for (label, on) in [(tl!("Relative"), true), (tl!("Absolute"), false)] { + if crate::widgets::radio(ui, label, picked.relative == Some(on), true) { + set = Some(json!({"relativeRadii": on})); + } + } + }); + ui.end_row(); + }); + if let Some(p) = set { + set_picked_corners(app, &picked, p); + } +} + /// Number of selected objects. pub(crate) fn selection_len(app: &VectorcraftApp) -> usize { app.session.active().map(|d| d.selection.len()).unwrap_or(0) diff --git a/crates/ui-egui/src/panels/properties.rs b/crates/ui-egui/src/panels/properties.rs index 94b4edc638..0c2313c8f0 100644 --- a/crates/ui-egui/src/panels/properties.rs +++ b/crates/ui-egui/src/panels/properties.rs @@ -202,38 +202,50 @@ fn can_merge_live_paint(app: &VectorcraftApp) -> bool { }) } -/// The Corners of the one path whose corners Direct Selection has selected: their kind and radius, -/// which `object.setLiveShape` sets on those corners. The Properties panel overview shows the -/// control while the Direct Selection tool is chosen and a corner of an object is selected -/// (). -/// A live rectangle's and a live polygon's own rows already set the selected corners. +/// The Corners of the paths whose corners Direct Selection has selected: their kind, and the +/// Corners link with their radius, which `object.setLiveShape` sets on those corners +/// ([`super::picked_corners`]); the link opens the Corners pop-up for them. The Properties panel +/// overview shows the control while the Direct Selection tool is chosen and a corner of an object +/// is selected +/// (), +/// and the Corners link opens the corner settings +/// (). One live +/// rectangle or live polygon selected alone has its own kind and radius rows, which already set +/// the selected corners: it shows the Corners link alone. fn corner_rows(app: &mut VectorcraftApp, ui: &mut Ui) { if app.session.tool_id() != "directSelection" { return; } let Some(st) = app.session.active() else { return }; - let [id] = st.selection.objects[..] else { return }; - let Some(n) = st.doc.node(id) else { return }; - if matches!(n.live_shape(), Some(LiveShape::Rectangle { .. } | LiveShape::Polygon { .. })) { + let own_rows = matches!(st.selection.objects[..], [id] + if st.doc.node(id).is_some_and(|n| matches!(n.live_shape(), Some(LiveShape::Rectangle { .. } | LiveShape::Polygon { .. })))); + // A corner of a path is Direct-Selected. + let corner_selected = st.selection.objects.iter().any(|id| { + st.doc.node(*id).and_then(LiveCorners::of).is_some_and(|lc| st.selection.partial(*id).is_some_and(|a| !lc.corners_of(a).is_empty())) + }); + if !corner_selected { return; } - let Some(lc) = LiveCorners::of(n) else { return }; - if st.selection.partial(id).is_none_or(|a| lc.corners_of(a).is_empty()) { + let Some(picked) = super::picked_corners(app) else { return }; + if own_rows { + ui.horizontal(|ui| super::corners_link(app, ui, "props-corners")); return; } - let n = n.clone(); - let kind = super::corner_style(app, &n).1; let kinds: Vec<&str> = vectorcraft_geom::shapes::CornerKind::ALL.iter().map(|k| crate::dialogs::corners::kind_label(*k)).collect(); let fw = super::field_width(ui); + let unit = app.session.general_unit(); egui::Grid::new("props-corners").num_columns(2).spacing([6.0, 6.0]).show(ui, |ui| { dim_label(ui, tl!("Corner:")); - let picked = widgets::dropdown_names(ui, ("props-corners", "kind"), kind.map_or("", crate::dialogs::corners::kind_label), &kinds, fw); - if let Some(k) = picked.and_then(|i| vectorcraft_geom::shapes::CornerKind::ALL.get(i)) { - app.run("object.setLiveShape", json!({"kind": k})).ok(); + let kind = widgets::dropdown_names(ui, ("props-corners", "kind"), picked.kind.map_or("", crate::dialogs::corners::kind_label), &kinds, fw); + if let Some(k) = kind.and_then(|i| vectorcraft_geom::shapes::CornerKind::ALL.get(i)) { + super::set_picked_corners(app, &picked, json!({"kind": k})); } ui.end_row(); - dim_label(ui, tl!("Corner Radius:")); - super::corner_radius_field(app, ui, &n, ("props-corners", "radius"), fw); + super::corners_link(app, ui, "props-corners"); + let name = Some(tl!("Corner Radius:")); + if let Some(r) = widgets::num_field_named(ui, ("props-corners", "radius"), name, picked.radius, unit, fw) { + super::set_picked_corners(app, &picked, json!({"radius": r.max(0.0)})); + } ui.end_row(); }); } diff --git a/crates/ui-egui/src/panels/properties/tests.rs b/crates/ui-egui/src/panels/properties/tests.rs index bc41fef557..668bb97d2a 100644 --- a/crates/ui-egui/src/panels/properties/tests.rs +++ b/crates/ui-egui/src/panels/properties/tests.rs @@ -1548,14 +1548,14 @@ fn direct_selected_corners_show_their_kind_and_radius() { app.select_tool("directSelection"); app.run("select.anchors", json!({"id": star, "anchors": [[0, 2]], "mode": "set"})).unwrap(); let texts = tall(&mut app, &ctx, vec![]); - assert!(shows(&texts, "Corner:") && shows(&texts, "Corner Radius:"), "{texts:?}"); + assert!(shows(&texts, "Corner:") && shows(&texts, "Corners"), "{texts:?}"); let corners = |app: &VectorcraftApp| { let n = app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(star)).unwrap().clone(); let lc = LiveCorners::of(&n).unwrap(); (lc.radius(0), lc.radius(2), lc.kind(0), lc.kind(2)) }; - // The radius: the field right of its label. - let label = text_at(&texts, "Corner Radius:"); + // The radius: the field right of the Corners link. + let label = text_at(&texts, "Corners"); let field = texts.iter().find(|(t, r)| t == "0 pt" && r.left() > label.right() && (r.center().y - label.center().y).abs() < 6.0).unwrap().1; press(&mut app, &ctx, field.center()); let depth = undo_depth(&app); @@ -1581,6 +1581,125 @@ fn direct_selected_corners_show_their_kind_and_radius() { let texts = tall(&mut app, &ctx, vec![]); assert_eq!(texts.iter().filter(|(t, _)| t == "Corner:").count(), 1, "{texts:?}"); assert_eq!(texts.iter().filter(|(t, _)| t == "Corner Radius:").count(), 1, "{texts:?}"); + // And the Corners link, for the pop-up's rounding: Relative on the picked corner's rectangle. + let texts = press(&mut app, &ctx, text_at(&texts, "Corners").center()); + press(&mut app, &ctx, text_at(&texts, "Relative").center()); + let n = app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(r)).unwrap().clone(); + assert!(LiveCorners::of(&n).unwrap().radii_relative()); +} + +/// A square path, not a live shape, its top-left corner at (`x`, 50) → its id. +fn square_path(app: &mut VectorcraftApp, x: f64) -> u64 { + let id = rect(app, x, 50.0, 100.0, 100.0); + app.run("select.set", json!({"ids": [id]})).unwrap(); + app.run("object.expandShape", json!({})).unwrap(); + id.as_u64().unwrap() +} + +/// The radius and kind of each corner of path `id`, from the top-left clockwise. +fn path_corners(app: &VectorcraftApp, id: u64) -> Vec<(f64, vectorcraft_geom::shapes::CornerKind)> { + let n = app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(id)).unwrap().clone(); + let lc = LiveCorners::of(&n).unwrap(); + (0..4).map(|k| (lc.radius(k), lc.kind(k))).collect() +} + +/// Types `text` into the field under `at` and presses Enter → the texts of the frame after. +fn type_into(app: &mut VectorcraftApp, ctx: &egui::Context, at: Pos2, text: &str) -> Vec<(String, Rect)> { + let key = |key, modifiers| Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers }; + press(app, ctx, at); + tall(app, ctx, vec![key(egui::Key::A, egui::Modifiers::COMMAND)]); + tall(app, ctx, vec![Event::Text(text.into())]); + tall(app, ctx, vec![key(egui::Key::Enter, egui::Modifiers::NONE)]); + tall(app, ctx, vec![]) +} + +/// The Corners link opens a pop-up with the corner kind, the radius and the rounding of the +/// Direct-Selected corners. A radius typed there, or a kind or rounding picked, sets the three +/// picked corners and leaves the fourth as it is, each in one undo step. +#[test] +fn the_corners_link_opens_the_settings_of_the_picked_corners() { + let mut app = new_app(); + let id = square_path(&mut app, 50.0); + app.select_tool("directSelection"); + app.run("select.anchors", json!({"id": id, "anchors": [[0, 0], [0, 1], [0, 2]], "mode": "set"})).unwrap(); + let ctx = egui::Context::default(); + let texts = tall(&mut app, &ctx, vec![]); + assert!(!shows(&texts, "Relative") && !shows(&texts, "Chamfer"), "closed: {texts:?}"); + let texts = press(&mut app, &ctx, text_at(&texts, "Corners").center()); + for t in ["Inverted Round", "Chamfer", "Radius:", "Relative", "Absolute"] { + assert!(shows(&texts, t), "{t} in {texts:?}"); + } + // The radius field, right of its label in the pop-up. + let label = text_at(&texts, "Radius:"); + let field = texts.iter().find(|(t, r)| t == "0 pt" && r.left() > label.right() && (r.center().y - label.center().y).abs() < 6.0).unwrap().1; + let depth = undo_depth(&app); + let texts = type_into(&mut app, &ctx, field.center(), "18"); + assert_eq!(undo_depth(&app), depth + 1, "one undo step"); + let (round, chamfer) = (vectorcraft_geom::shapes::CornerKind::Round, vectorcraft_geom::shapes::CornerKind::Chamfer); + assert_eq!(path_corners(&app, id), vec![(18.0, round), (18.0, round), (18.0, round), (0.0, round)]); + // A kind, picked in the pop-up. + let texts = press(&mut app, &ctx, text_at(&texts, "Chamfer").center()); + assert_eq!(undo_depth(&app), depth + 2, "one undo step"); + assert_eq!(path_corners(&app, id), vec![(18.0, chamfer), (18.0, chamfer), (18.0, chamfer), (0.0, round)]); + // Relative rounding, for the path the corners are on. + press(&mut app, &ctx, text_at(&texts, "Relative").center()); + assert_eq!(undo_depth(&app), depth + 3, "one undo step"); + let n = app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(id)).unwrap().clone(); + assert!(LiveCorners::of(&n).unwrap().radii_relative()); +} + +/// With a corner of each of two paths Direct-Selected and their radii different, the pop-up's +/// radius is blank; a radius typed there sets both corners, and no other, in one undo step. +#[test] +fn the_corners_pop_up_sets_picked_corners_across_paths() { + let mut app = new_app(); + let (a, b) = (square_path(&mut app, 20.0), square_path(&mut app, 200.0)); + app.run("object.setLiveShape", json!({"ids": [a], "corners": [0], "radius": 5})).unwrap(); + app.select_tool("directSelection"); + app.run("select.anchors", json!({"id": a, "anchors": [[0, 0]], "mode": "set"})).unwrap(); + app.run("select.anchors", json!({"id": b, "anchors": [[0, 1]], "mode": "add"})).unwrap(); + let ctx = egui::Context::default(); + let texts = tall(&mut app, &ctx, vec![]); + let texts = press(&mut app, &ctx, text_at(&texts, "Corners").center()); + let label = text_at(&texts, "Radius:"); + // Blank: no value right of the label. + assert!(!texts.iter().any(|(t, r)| t.ends_with("pt") && r.left() > label.right() && (r.center().y - label.center().y).abs() < 6.0), "{texts:?}"); + let depth = undo_depth(&app); + type_into(&mut app, &ctx, egui::pos2(label.right() + 40.0, label.center().y), "7"); + assert_eq!(undo_depth(&app), depth + 1, "one undo step"); + let round = vectorcraft_geom::shapes::CornerKind::Round; + assert_eq!(path_corners(&app, a), vec![(7.0, round), (0.0, round), (0.0, round), (0.0, round)]); + assert_eq!(path_corners(&app, b), vec![(0.0, round), (7.0, round), (0.0, round), (0.0, round)]); +} + +/// With a corner of one path Direct-Selected and a second path selected whole, the pop-up picks +/// that corner and every corner of the second path. While one path is Relative and the other +/// Absolute, no rounding is chosen; picking Absolute sets both paths in one undo step. +#[test] +fn the_corners_pop_up_takes_every_corner_of_a_whole_path_and_mixed_rounding() { + let mut app = new_app(); + let (a, b) = (square_path(&mut app, 20.0), square_path(&mut app, 200.0)); + app.run("object.setLiveShape", json!({"ids": [a], "corners": [0], "radius": 5})).unwrap(); + app.run("object.setLiveShape", json!({"ids": [a], "relativeRadii": true})).unwrap(); + app.select_tool("directSelection"); + app.run("select.set", json!({"ids": [b]})).unwrap(); + app.run("select.anchors", json!({"id": a, "anchors": [[0, 0]], "mode": "add"})).unwrap(); + let picked = crate::panels::picked_corners(&app).unwrap(); + assert_eq!(picked.relative, None, "no rounding while the paths differ"); + assert_eq!(picked.items.len(), 2); + let ctx = egui::Context::default(); + let texts = tall(&mut app, &ctx, vec![]); + let texts = press(&mut app, &ctx, text_at(&texts, "Corners").center()); + let depth = undo_depth(&app); + let texts = press(&mut app, &ctx, text_at(&texts, "Absolute").center()); + assert_eq!(undo_depth(&app), depth + 1, "one undo step"); + assert_eq!(crate::panels::picked_corners(&app).unwrap().relative, Some(false), "both Absolute"); + let label = text_at(&texts, "Radius:"); + type_into(&mut app, &ctx, egui::pos2(label.right() + 40.0, label.center().y), "7"); + assert_eq!(undo_depth(&app), depth + 2, "one undo step"); + let round = vectorcraft_geom::shapes::CornerKind::Round; + assert_eq!(path_corners(&app, a), vec![(7.0, round), (0.0, round), (0.0, round), (0.0, round)]); + assert_eq!(path_corners(&app, b), vec![(7.0, round); 4], "every corner of the path selected whole"); } /// One effect on the one selected object shows its name and a Delete icon beside the fx button, diff --git a/crates/ui-egui/tests/control_bar_corners.rs b/crates/ui-egui/tests/control_bar_corners.rs index 7386e44a8c..2f7189efdc 100644 --- a/crates/ui-egui/tests/control_bar_corners.rs +++ b/crates/ui-egui/tests/control_bar_corners.rs @@ -127,7 +127,7 @@ fn corner_radius_existing_anchor_controls_and_properties_remain_available() { assert!(bar.has_text("Convert:") && bar.has_text("Anchors:"), "{:?}", bar.texts); assert!(bar.nodes.iter().any(|node| node.label() == Some("Remove Anchor Points"))); let properties = Frames::new(360.0, true).settled(&mut app); - assert!(properties.has_text("Corner Radius:"), "{:?}", properties.texts); + assert!(properties.has_text("Corners"), "{:?}", properties.texts); assert!(properties.texts.iter().any(|(text, _)| text == "0 pt")); } diff --git a/docs/mcp.md b/docs/mcp.md index e7abf476a9..a4b4a75882 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -7682,8 +7682,8 @@ polygon's from its first vertex clockwise; a star's from its first tip; an index Each corner keeps its own radius and kind (the shape's `live` in queries has `radii` and, when a corner isn't round, `kinds`); a corner with no radius is one anchor, a cut one two, and Direct-Selected corners stay selected as that changes. A path that isn't a live shape keeps its uncut outline (`live` `{"shape": "path", "base", "radii"}`) so its -corners stay editable, and is a plain path again once no corner is cut; a polygon stays a live polygon, its corners -keeping the radius they shared when `sides` changes. Every corner is a circular arc tangent to both sides: a radius +corners stay editable, and is a plain path again once no corner is cut, unless its rounding is Relative; a polygon +stays a live polygon, its corners keeping the radius they shared when `sides` changes. Every corner is a circular arc tangent to both sides: a radius draws no larger than takes the cut halfway along the corner's shorter side (half the shorter side of a rectangle, the same limit for its four corners), the corners stay circular through uneven scales (the radius scales by the mean scale, or keeps its size with Scale Corners off), and a rectangle from a file that kept an uneven scale in its transform @@ -7702,6 +7702,17 @@ and those shape tools: hidden widgets are not drawn, and those tools do not answ on them. `on`, when given and not `null`, must be `true` or `false` and sets the state; without it, or with `null`, the command toggles. The reply is the new state (`true` when shown, the default). The bounding box, the center point and Direct Selection's corner widgets, which follow `view.cornerWidget` alone, stay as they are, and no undo step is added. +In the desktop app, the Corners link in the Control bar (beside the anchor controls) and in the Properties panel (with +Direct Selection, while a corner is selected) opens the Corners pop-up for the picked corners of every selected path: +the corners holding a Direct-Selected anchor, or every corner of a path selected whole; a path whose selected anchors +hold no corner is left out. The pop-up has the corner kind, the radius (blank while the picked corners differ) and the +rounding, Relative or Absolute (`relativeRadii`, which applies to each path as a whole; neither is chosen while the +paths differ). A path without Live Corners is Absolute, and Relative on a path with a corner keeps its outline as the +base of its Live Corners, as a radius does; ellipses and lines are left as they are. Editing a path's anchors (for +example `path.moveAnchors`) ends its Live Corners, so it is Absolute again. With Relative rounding, a radius is +compared as the fraction it stores (its share of the corner's maximum, at most all of it), so typing the radius +shown again adds no undo step. The Corner Radius field beside the link sets the same corners. Each change runs one +`object.setLiveShape` with `items`, one undo step, and the corners that were not picked keep their radius and kind. ```json {"name":"run_command","arguments":{"command":"object.setLiveShape","params":{"id":12,"corners":[1],"radius":16}}} diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index b1d981428a..bf9ca2c662 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1481,6 +1481,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur With Direct Selection, Shift pressed during the drag of a curved segment keeps both of its handles at right angles to the line between its anchors, on the same side and at the same length (`path.reshapeSegment {perpendicular}`). Shift held while any segment is dragged with the Anchor Point tool or the Pen with Alt does the same. With the Anchor Point tool, Shift held at the press on an anchor (or a selected blend's spine point) moves it, handles and all, instead of pulling out handles; Shift kept down keeps the move at 45° steps, and a Shift-click that doesn't move leaves the anchor as it was (`path.moveAnchor`). A selected blend spine's segment dragged with the Anchor Point tool, or a curved one dragged with Direct Selection, bends the same way (`object.blend.spine.reshapeSegment`). - **Live Corners:** drag a live rectangle's corner widgets (Selection or Direct Selection) to round all corners, with a radius readout; with Direct Selection, select corner anchors to show and round just those corners (#381). Each corner keeps its own radius and kind (Round, Inverted Round, Chamfer): Alt-click a widget to cycle the kind, double-click it for the Corners dialog, and the Properties and Transform radius fields set the selected corners (`object.setLiveShape {corners, radius, kind}`). A link toggle behind Corner Radius (the `singleCornerRadius` preference) switches the panels to a field for each corner of a live rectangle: Top Left, Top Right, Bottom Right and Bottom Left. Corners stay circular when the rectangle is scaled unevenly or along its own sides when rotated (the radius keeps its size, or scales by the mean scale with Scale Corners on); only a shear distorts them. On a rectangle that isn't square every corner is the same circle: a radius past half the shorter side stops there for all of them, the widgets sit on the corners as drawn and turn the edited corners red at that limit, CSS export writes the drawn radii, and rectangles saved stretched by older versions get circular corners when their corners are next set (#442). Live Corners work on any path's corners too, as on a rectangle's (#511): a star's, a live polygon's (which also shows them to the Selection tool, has a Corner Radius field in the Properties and Transform panels and keeps its radius as its sides change) and a pen path's, wherever two sides meet at an angle at an anchor that isn't smooth: curved sides too, trimmed to what the cut leaves of them (#1144). Direct Selection shows the widgets of every corner, or of the corners holding selected anchors; each corner is a circle tangent to both sides, drawn no larger than takes its cut halfway along its shorter side; a path keeps its uncut outline so its corners stay editable, and the same command, dialog, angle preference and View › Hide Corner Widget apply. With Direct Selection a click on a widget (no drag) selects its corner, as a click on the corner's anchor does, so the next drag on it rounds that corner alone; Shift-click toggles it (#1239). While a corner widget is dragged with the Selection tool the bounding box hides, so the rounding shows against the path alone (#1229). A round corner next to a curved side curves smoothly instead of sticking out of the shape (#1547, fixes #1512). View › Hide Edges hides the Live Corners widgets, the bounding box and the type widget, and the selection tools then do not answer a press on them or change the cursor over them. + - **Corners link:** the Control bar and the Properties panel have a Corners link beside the radius field, which opens the Corners pop-up with the corner kind, the radius and the type of rounding of the selected corners; [the archived help page](https://web.archive.org/web/20200308215011/https://helpx.adobe.com/illustrator/using/reshape-with-live-corners.html) describes the link and these three settings. The pop-up picks corners across every selected path, names the rounding Relative or Absolute, shows the radius blank while the picked corners differ and no rounding while their paths differ, sets a typed value on the picked corners alone, and makes each change one undo step; these are VectorCraft's own rules. Relative rounding also works on a plain path with corners (`the_corners_link_opens_the_settings_of_the_picked_corners`, `the_corners_pop_up_sets_picked_corners_across_paths`, `the_control_bar_corners_link_opens_the_pop_up_for_the_picked_corners`, `relative_rounding_takes_on_a_plain_path`, `a_relative_radius_that_stores_the_same_fraction_adds_no_undo_step`; part of #1232). - **Rectangle Properties corner type:** a live rectangle's Rectangle Properties (Transform panel, the Properties panel's Transform section and the Contextual Task Bar's Shape Properties) have a Corner menu with Round, Inverted Round and Chamfer. With Corner Radius linked, one menu sets the kind of every corner of each selected rectangle, also corners with no radius, and shows blank when the shown rectangle's kinds differ; unlinked, each corner's row has its own menu beside its radius field, or under it in a panel too narrow for both; the unlinked radius fields and menus leave other selected paths and polygons as they are. A pick is one undo step, and picking the kind the corners already have adds none (`object.setLiveShape {kind, rectanglesOnly, corners}`); an action that records them acts on the rectangles selected when it plays. The help page says a rectangle's corner type can be set for each corner or for all of them at once ([the help page](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-live-shapes/live-shape-properties.html)); tying the number of menus to the Corner Radius link, the blank value and the undo steps are VectorCraft's own rules (`a_rectangle_shows_linked_and_unlinked_corner_types`, `the_shape_properties_popup_changes_a_rectangle_corner_type`, `the_linked_corner_menu_sets_every_selected_rectangle`, `the_unlinked_corner_menus_fit_a_narrow_panel`, `an_unlinked_corner_radius_leaves_other_selected_shapes`, `a_rectangle_corner_kind_without_a_selected_rectangle_changes_nothing`, `rectangle_kind_menu_targets_all_or_one_corner_and_skips_noop_undo`, `rectangles_only_sets_the_selected_rectangles_when_an_action_plays`, `a_radius_reaches_a_rectangle_that_already_draws_it`). - **Polygon side widget:** a selected live polygon shows a small diamond beside the middle of the right side of its bounding box, with the Selection tool and with the Rectangle, Rounded Rectangle, Ellipse, Polygon and Star tools, while the bounding box and the edges are shown. Dragging the widget sets the polygon's side count, from 3 to 11, as [the help page](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-live-shapes/add-or-remove-sides-from-polygons.html) describes; typed counts in the Transform panel and `object.setLiveShape` still go from 3 to 1000. A drag down adds one side and a drag up removes one for every 12 screen pixels along the box's own vertical axis, and the pointer shows the count while measurement labels are on. A polygon of more than 11 sides keeps its count until the drag goes up, which gives it 11. The drag sends `object.setLiveShape {sides}`, so the polygon keeps its center, radius and rotation; the release adds one undo step when the count changed and none when it ends where it began, and Escape puts the count back. The widget's look and place, the drag direction, the step and the rule for more than 11 sides are VectorCraft's own (`crates/tools/src/sidewidget.rs`). - **Hide/Show Shape Widgets:** with the Rectangle, Rounded Rectangle, Ellipse, Polygon or Star tool, the Control bar shows a Hide Shape Widgets button, which reads Show Shape Widgets while the widgets are hidden (`view.shapeWidgets {on?}`). [The help page](https://helpx.adobe.com/illustrator/using/live-shapes.html) describes this Control panel button, offered with any live shape drawing tool, as switching the on-canvas widgets of selected shapes off and on. While they are hidden, a selected live rectangle's or polygon's corner widgets, a live ellipse's pie widgets and a live polygon's side widget are not drawn, and the Selection tool and those shape tools do not answer a press, a double-click or the cursor on their place (a shape tool draws from there). The bounding box and its handles, the center point and Direct Selection's corner widgets (View › Hide Corner Widget) stay as they are. The setting is on by default, kept with the interface state across sessions and tool switches, and adds no undo step. Its scope beyond the shape tools, its default and what it leaves shown are VectorCraft's own rules (tests `hidden_shape_widgets_leave_the_bounding_box`, `the_shape_tools_control_bar_hides_and_shows_the_shape_widgets`, `shape_widgets_command_toggles_and_takes_on`, `hidden_shape_widgets_do_not_answer_a_shape_tool` and `hidden_shape_widgets_leave_direct_selections_corners`). diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 911f08d192..c0d8d424ff 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -490,6 +490,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po | Select › Start Global Edit / Stop Global Edit; Properties › Quick Actions with the Global Edit Options popover (Match: Appearance, Size; On Artboards: All Artboards or a range, Include Objects On Canvas; Result(s)); Escape stops it; the matched objects are highlighted in their layer colour while it runs; a Shift-click on a highlighted match leaves it out | partial | #3521, `select.globalEdit` / `select.globalEditOptions` / `select.globalEditExclude`, `crates/engine/src/tests/globaledit.rs`; paths, compound paths, symbol instances and groups of them (similar groups, #4939: edits inside one group reach the same object in the others; [public source](https://helpx.adobe.com/illustrator/desktop/manage-objects/edit-objects/edit-groups-with-similar-objects.html)); a group holding type or an image is not taken, as Global Edit does not take images or text; Shift-click to leave a match out ([public source](https://helpx.adobe.com/ph_fil/illustrator/how-to/global-editing-sensei.html)); the Control bar's Global Edit Options dropdown opens the same options; the matches are highlighted before the start (`selecting_one_object_highlights_the_similar_objects_before_global_edit_starts`); rotated copies are matched and take an edit turned by their angle ([public source](https://helpx.adobe.com/vn_vi/illustrator/how-to/modern-logo-design.html); `start_global_edit_takes_rotated_copies_and_an_edit_reaches_each_turned_by_its_angle`); reflected copies are not matched (VectorCraft's own rule) | | Contextual task bar | done | | | Control bar with Transform and Stroke popovers | done | | +| Control bar and Properties panel: Corners link and pop-up for the picked corners (part of #1232) | done | the link opens the corner kind, the radius (blank while the picked corners differ) and the Relative or Absolute rounding; each change sets the picked corners of every selected path in one `object.setLiveShape {items}`, one undo step | | Control bar: numeric Corner Radius for eligible selected ordinary and live corners (part of #7238, request 3 only) | done | Anchor Points visibility group; common/mixed values, general document units and multi-object edits through `object.setLiveShape`, one Undo. A partial selection containing no eligible corners contributes no target. Corner kind and relative mode are retained; existing corner-widget selection, widget visibility and maximum-radius behavior are unchanged. Requests 1/2 remain open. | | Stroke panel: custom arrowheads after the built-in ones in both arrowhead menus, from the arrowheads file that the panel menu's Edit Arrowheads… opens; saving the file reloads the menus, and a stroke keeps a copy of its custom head's art | done | [Apply stroke on an object](https://helpx.adobe.com/illustrator/using/stroke-object.html) (Customize arrowheads); the file's layout (one symbol per head, pointing right, tip at the registration point, height drawn as wide as the built-in heads) is VectorCraft's own; `stroke.arrowheads.edit`, `stroke.arrowheads.list`, `stroke.arrowheads.reload`, `stroke.set` `{custom: name}`; engine `tests::arrowheads`, `stroke::tests_arrows::custom_heads_draw_their_own_art_at_the_tip` | | Control bar: Paragraph: link and Align left/center/right while type is selected (#5372) | done | After the Character controls, as the public documentation has the Control panel format paragraphs ([Paragraph panel overview](https://helpx.adobe.com/illustrator/using/formatting-paragraphs.html), [Align text](https://helpx.adobe.com/illustrator/using/align-text.html)); the link opens the Paragraph panel in a popover, as Character: does with the Character panel. The bar trims from its right end: X/Y/W/H, Distribute, Align, area type vertical alignment, then these buttons, then the link. The three-button set is our choice for room; all seven alignments are in the popover. `panels/paragraph/tests.rs` headless tests (`the_control_bar_shows_the_paragraph_alignment_of_the_selected_type`, `the_control_bar_trims_its_paragraph_section_after_the_controls_to_its_right`) |