mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-31 15:48:18 +00:00
[HH9] picture.reset: document and pin what it keeps (frame shape, size, position)
PowerPoint: Reset Picture discards the picture's formatting changes (corrections, recolor, artistic effect, picture-style effects and outline); Reset Picture & Size also restores the size. The frame shape set by Change Shape is not touched. Ours already left the geometry alone (the reported geometry wipe does not reproduce); effects, outline and crop are picture formatting that PowerPoint discards too, so they stay reset (declined: parity). Added the regression test and the command doc. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
55e5ee56b4
commit
7b424a463b
2 files changed
+35
-1
No files matched your search
@@ -165,7 +165,15 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
has_selection,
|
||||
picture_adjust
|
||||
),
|
||||
cmd!("picture.reset", "Reset Picture", ["Picture Format", "Adjust"], None, "{ids?}", has_selection, picture_reset),
|
||||
cmd!(
|
||||
"picture.reset",
|
||||
"Reset Picture",
|
||||
["Picture Format", "Adjust"],
|
||||
None,
|
||||
"{ids?} (discards the picture's formatting: adjustments, artistic effect, crop, transparency, picture-style effects and outline; the frame shape from Change Shape or Crop to Shape, the size and the position stay)",
|
||||
has_selection,
|
||||
picture_reset
|
||||
),
|
||||
cmd!(
|
||||
"picture.change",
|
||||
"Change Picture",
|
||||
|
||||
@@ -5646,3 +5646,29 @@ fn invalid_ids_array_never_falls_back_to_the_selection() {
|
||||
assert!(s.doc().unwrap().shape(deckcraft_model::ShapeId(a as u32)).is_some(), "shape deleted for {ids}");
|
||||
}
|
||||
}
|
||||
|
||||
/// HH9: Reset Picture discards the picture's formatting (adjustments, artistic effect, picture
|
||||
/// style effects and outline) but not the frame's shape (Change Shape / Crop to Shape).
|
||||
#[test]
|
||||
fn picture_reset_keeps_the_frame_shape() {
|
||||
let mut img = image::RgbaImage::new(40, 30);
|
||||
img.pixels_mut().for_each(|p| *p = image::Rgba([200, 30, 30, 255]));
|
||||
let mut png = Vec::new();
|
||||
image::DynamicImage::ImageRgba8(img).write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png).unwrap();
|
||||
let mut s = Session::with_new();
|
||||
s.execute("slide.new", &json!({"layout": "blank"})).unwrap();
|
||||
s.execute("insert.picture", &json!({"name": "a.png", "data": cmd::base64_encode(&png)})).unwrap();
|
||||
s.execute("shape.change", &json!({"preset": "roundRect"})).unwrap();
|
||||
s.execute("picture.adjust", &json!({"brightness": 0.3})).unwrap();
|
||||
let geom = s.doc().unwrap().selected_shapes()[0].geom.clone();
|
||||
assert_ne!(geom, deckcraft_model::Geom::preset("rect"));
|
||||
s.execute("picture.reset", &json!({})).unwrap();
|
||||
let sh = s.doc().unwrap().selected_shapes()[0].clone();
|
||||
assert_eq!(sh.geom, geom, "the frame shape stays");
|
||||
match &sh.kind {
|
||||
deckcraft_model::ShapeKind::Picture { fill } => assert_eq!(fill.adjust, Default::default()),
|
||||
_ => panic!("not a picture"),
|
||||
}
|
||||
let doc = command_specs().iter().find(|c| c.id == "picture.reset").unwrap().params;
|
||||
assert!(doc.contains("frame shape"), "{doc}");
|
||||
}
|
||||
Reference in new issue
Block a user