mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-27 13:57:35 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
superplay2021
Claude Opus 5.5
parent
742efd64fe
commit
e6b7ac6df3
@@ -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")]
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -123,9 +123,9 @@ fn whole_box(rect: &Rect, whole: bool) -> Option<Rect> {
|
||||
(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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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`).
|
||||
|
||||
Reference in New Issue
Block a user