From e6b7ac6df3f9ff12e2a7639bfc404ee5e6be2396 Mon Sep 17 00:00:00 2001 From: David Mann Date: Tue, 24 Nov 2026 14:17:09 +0100 Subject: [PATCH] Fix-up for #11756: no Align Edges on the Star tool, as main's Polygon change says Main's #13326 tests keep the Star tool without the checkbox (the reference application has no Star tool; its stars are the Polygon tool's). Keep that, and the comments and docs that name the Polygon drag. Co-Authored-By: superplay2021 <347501738+superplay2021@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/state/tool_options.rs | 3 ++- crates/ui-egui/src/tools/vector_ui/options.rs | 8 +++++--- .../src/tools/vector_ui/polygon_align_edges_tests.rs | 4 ++-- crates/ui-egui/src/tools/vector_ui/shapes.rs | 6 +++--- .../src/tools/vector_ui/triangle_align_edges_tests.rs | 2 +- docs/pixel-aligned-strokes.md | 4 ++-- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/crates/ui-egui/src/state/tool_options.rs b/crates/ui-egui/src/state/tool_options.rs index 22de65fac7..3f4b369f72 100644 --- a/crates/ui-egui/src/state/tool_options.rs +++ b/crates/ui-egui/src/state/tool_options.rs @@ -155,7 +155,8 @@ pub struct ToolOptions { pub corner_radius: f32, /// The shape tools' and the Pen's (Shape mode) one Align Edges checkbox, as in the reference /// application: a drag lands on whole pixels, and the new shape layer gets Align Edges - /// (`ShapeLayer::use_aligned_rendering`), which fits it to whole pixels at render time. On by + /// (`ShapeLayer::use_aligned_rendering`), which fits it to whole pixels at render time. With it off, the Rectangle (#13346), + /// Triangle (#13370) and Polygon (#13326) drags keep their fractions. On by /// default and after Reset Tool; enabled in Shape mode only. Scripted and stored by the /// reference's name, `useAlignedRendering` (`align_edges` in older settings and presets). #[serde(rename = "useAlignedRendering", alias = "align_edges")] diff --git a/crates/ui-egui/src/tools/vector_ui/options.rs b/crates/ui-egui/src/tools/vector_ui/options.rs index 216f12f76e..48c1bd2259 100644 --- a/crates/ui-egui/src/tools/vector_ui/options.rs +++ b/crates/ui-egui/src/tools/vector_ui/options.rs @@ -156,9 +156,11 @@ fn bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool, open: &mut BarOpe crate::option_cells::range_alert(app, ui, &alert); } } - // Every shape tool's one Align Edges, at the bar's right end after the gear (#13346, #13370). - // Only a shape layer has pixel edges to align: greyed in Path mode (and in a pixels mode). - if is_shape_tool(tool) { + // Every shape tool's one Align Edges, at the bar's right end after the gear (#13346, #13370, + // #13326). Not the Star tool's, which the reference application doesn't have (its stars are the + // Polygon tool's). Only a shape layer has pixel edges to align: greyed in Path mode (and in a + // pixels mode). + if is_shape_tool(tool) && tool != Tool::Star { Divider::vertical().show(ui); super::alignment::shape_tool_option(app, ui); } diff --git a/crates/ui-egui/src/tools/vector_ui/polygon_align_edges_tests.rs b/crates/ui-egui/src/tools/vector_ui/polygon_align_edges_tests.rs index 0f0a5b4dea..770a5bba06 100644 --- a/crates/ui-egui/src/tools/vector_ui/polygon_align_edges_tests.rs +++ b/crates/ui-egui/src/tools/vector_ui/polygon_align_edges_tests.rs @@ -72,7 +72,7 @@ fn path_and_pixels_mode_keep_snapping_with_the_greyed_checkbox_off() { } app.ui.tool_options.shape_mode = VectorMode::Shape; assert!(!super::shapes::snaps_to_pixels(&app, ShapeKind::Polygon), "Shape mode with Align Edges off keeps fractions"); - assert!(super::shapes::snaps_to_pixels(&app, ShapeKind::Star), "the Star tool still snaps its drag geometry"); + assert!(super::shapes::snaps_to_pixels(&app, ShapeKind::Star), "the Star tool has no Align Edges and still snaps"); } #[test] @@ -134,5 +134,5 @@ fn the_bar_ends_with_align_edges_enabled_only_in_shape_mode() { } let h = harness(Tool::Star); - assert_eq!(h.query_all_by_label("Align Edges").count(), 1, "Star has one Align Edges checkbox"); + assert!(h.query_by_label("Align Edges").is_none(), "the Star tool has no Align Edges"); } diff --git a/crates/ui-egui/src/tools/vector_ui/shapes.rs b/crates/ui-egui/src/tools/vector_ui/shapes.rs index 2216b42379..a716dbc973 100644 --- a/crates/ui-egui/src/tools/vector_ui/shapes.rs +++ b/crates/ui-egui/src/tools/vector_ui/shapes.rs @@ -123,9 +123,9 @@ fn whole_box(rect: &Rect, whole: bool) -> Option { (w >= 1.0 && h >= 1.0).then(|| Rect::new(x0, y0, x0 + w, y0 + h)) } -/// Whether a drag of `kind` lands on whole pixels. Align Edges is the Triangle (#13370), Rectangle -/// (#13346) and Polygon (#13326) tools' option, and only in Shape mode, where its checkbox is -/// enabled; the other Shape tools, and a greyed checkbox, still snap. +/// Whether a drag of `kind` lands on whole pixels. The Triangle (#13370), Rectangle (#13346) and +/// Polygon (#13326) drags keep their fractions with Align Edges off in Shape mode; the other Shape +/// tools' drags (the framework's drag lands them on pixels), and a greyed checkbox, still snap. pub(super) fn snaps_to_pixels(app: &PhotocraftApp, kind: ShapeKind) -> bool { let o = &app.ui.tool_options; !(matches!(kind, ShapeKind::Triangle | ShapeKind::Rectangle | ShapeKind::Polygon) && o.shape_mode == super::VectorMode::Shape && !o.align_edges) diff --git a/crates/ui-egui/src/tools/vector_ui/triangle_align_edges_tests.rs b/crates/ui-egui/src/tools/vector_ui/triangle_align_edges_tests.rs index 4ca52fc39c..352b8dac21 100644 --- a/crates/ui-egui/src/tools/vector_ui/triangle_align_edges_tests.rs +++ b/crates/ui-egui/src/tools/vector_ui/triangle_align_edges_tests.rs @@ -91,7 +91,7 @@ fn options_bar_shows_align_edges_for_the_triangle() { /// options bar, on after Reset Tool: here too, exactly one, on, enabled in Shape mode. #[test] fn every_shape_tool_and_the_pen_show_one_align_edges_checkbox() { - for tool in [Tool::Rectangle, Tool::EllipseShape, Tool::Triangle, Tool::Polygon, Tool::Star, Tool::Line, Tool::CustomShape, Tool::Pen] { + for tool in [Tool::Rectangle, Tool::EllipseShape, Tool::Triangle, Tool::Polygon, Tool::Line, Tool::CustomShape, Tool::Pen] { let mut h = harness(tool); h.state_mut().ui.tool_options.vector_mode = VectorMode::Shape; h.run_steps(3); diff --git a/docs/pixel-aligned-strokes.md b/docs/pixel-aligned-strokes.md index c0afe0b728..436253f91c 100644 --- a/docs/pixel-aligned-strokes.md +++ b/docs/pixel-aligned-strokes.md @@ -39,9 +39,9 @@ starts from `align_edges::aligned_shape` so both parts move together), previews ## The checkbox -The shape tools and the Pen (in Shape mode) have one **Align Edges** checkbox at the options bar's +The shape tools (not the Star tool, which the reference application lacks) and the Pen (in Shape mode) have one **Align Edges** checkbox at the options bar's right end, on by default and after Reset Tool, greyed in Path mode. It does both: the drag lands on -whole pixels (with it off, the Rectangle's and Triangle's drags keep their fractions; the other +whole pixels (with it off, the Rectangle's, Triangle's and Polygon's drags keep their fractions; the other tools' drags always land on whole pixels), and the new shape layer gets Align Edges. With a shape layer selected the checkbox shows and edits that layer's flag, as Fill and Stroke do; the Properties panel has it too. Tool presets store it as `useAlignedRendering` (older settings and presets as `align_edges`).