mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Path mode's Radius sets the next outline only
CodeRabbit on #9456: with a shape layer active, the Radius field in Path mode read and edited that layer. In Path mode the options bar now has no selected-shape target, so Radius only sets the next outline's radius. Test: path_mode_radius_leaves_the_active_shape_layer_alone Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
10ac3e3753
commit
a8a3c39ea6
2 files changed
+28
-1
No files matched your search
@@ -42,7 +42,8 @@ pub(crate) fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool
|
||||
crate::widgets::scrub_option_label(ui, &label);
|
||||
};
|
||||
let o = &mut app.ui.tool_options;
|
||||
let target = selected_shape(&app.session);
|
||||
// Path mode edits only the next outline: an active shape layer is not the target.
|
||||
let target = if paint { selected_shape(&app.session) } else { None };
|
||||
// Fill and Stroke edit the selected shape layer too (#3347), and still set the next shape's.
|
||||
let (fg, bg) = (app.session.tools.foreground, app.session.tools.background);
|
||||
let (mut has_fill, fill, stroke) = match &target {
|
||||
|
||||
@@ -1009,3 +1009,29 @@ fn path_mode_keeps_the_geometry_options_and_hides_paint() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// CodeRabbit on #9456: in Path mode the Radius field sets the next outline's radius only; it
|
||||
/// must not edit a shape layer that happens to be active.
|
||||
#[test]
|
||||
fn path_mode_radius_leaves_the_active_shape_layer_alone() {
|
||||
let mut app = app("rgb", 8);
|
||||
app.run("shape.create", json!({"kind": "rect", "rect": [20, 20, 60, 40], "radii": 10})).unwrap();
|
||||
let radii = |app: &PhotocraftApp| match &shape(app).live {
|
||||
Some(photocraft_doc::LiveShape::Rect { radii, .. }) => *radii,
|
||||
other => panic!("expected a live rectangle, got {other:?}"),
|
||||
};
|
||||
assert_eq!(radii(&app), [10.0; 4]);
|
||||
app.ui.tool_options.corner_radius = 3.0;
|
||||
app.ui.tool_options.shape_mode = "path".into();
|
||||
let history = app.session.active().unwrap().history.past_len();
|
||||
let mut h = harness(app, false);
|
||||
h.get_all_by_role(egui::accesskit::Role::SpinButton).next().expect("the radius").click();
|
||||
h.run();
|
||||
h.key_press_modifiers(Modifiers::COMMAND, Key::A);
|
||||
h.event(Event::Text("20".into()));
|
||||
h.key_press(Key::Enter);
|
||||
h.run_steps(3);
|
||||
assert_eq!(h.state().ui.tool_options.corner_radius, 20.0, "the next outline's radius");
|
||||
assert_eq!(radii(h.state()), [10.0; 4], "the shape layer keeps its radius");
|
||||
assert_eq!(h.state().session.active().unwrap().history.past_len(), history, "no edit");
|
||||
}
|
||||
Reference in new issue
Block a user