Format: Fill hides the kept group fill's editors with Slide background fill

A group that keeps a gradient, pattern or picture fill for its pictures
no longer shows that fill's editor while its shapes have the slide
background fill, so editing it cannot replace their fill.
This commit is contained in:
dotCooCoo
2026-10-28 04:15:58 -07:00
parent fca0492725
commit edbf542570
2 changed files with 12 additions and 9 deletions
+6 -6
View File
@@ -380,14 +380,11 @@ mod tests {
.unwrap();
let shape = s.execute("shape.insert", &json!({"preset": "rect", "rect": [500.0, 40.0, 120.0, 80.0]})).unwrap()["id"].as_u64().unwrap();
s.execute("edit.select", &json!({"ids": [pic, shape]})).unwrap();
let group = s.execute("arrange.group", &json!({})).unwrap()["id"].as_u64().unwrap();
let red = Some(Fill::solid(ColorRef::rgb(deckcraft_color::Rgba::rgb(255, 0, 0))));
s.execute("arrange.group", &json!({})).unwrap();
s.execute("shape.fill", &json!({"gradient": {"stops": [[0, "#ff0000"], [1, "#0000ff"]]}})).unwrap();
s.edit(|doc, _| {
for slide in &mut doc.slides {
let slide = std::sync::Arc::make_mut(slide);
if let Some(g) = slide.shape_mut(ShapeId(group as u32)) {
g.fill.clone_from(&red);
}
if let Some(p) = slide.shape_mut(ShapeId(pic as u32)) {
p.fill = Some(Fill::Group);
}
@@ -408,8 +405,11 @@ mod tests {
h.run_steps(3);
h.get_by_label("Slide background fill").click();
h.run_steps(3);
assert_eq!(h.state().session.active().unwrap().selected_shapes()[0].fill, red, "the group keeps the fill its picture uses");
let st = h.state().session.active().unwrap();
assert!(matches!(st.selected_shapes()[0].fill, Some(Fill::Gradient(_))), "the group keeps the fill its picture uses");
assert_eq!(st.shape(ShapeId(shape as u32)).unwrap().fill, Some(Fill::Background));
assert_eq!(h.get_by_label("Slide background fill").accesskit_node().toggled(), Some(egui::accesskit::Toggled::True));
assert!(h.query_by_label("Rotate with shape").is_none(), "no editor for the group's kept gradient");
assert_eq!(h.query_all_by_role_and_label(egui::accesskit::Role::Slider, "Transparency").count(), 0);
assert_eq!(color_buttons(&h), 1, "only the line's Color button");
}
+6 -3
View File
@@ -372,10 +372,13 @@ pub(super) fn format_shape(app: &mut SlideApp, ui: &mut Ui) {
ui.data_mut(|d| d.insert_temp(id, v));
}
});
if let Some(Fill::Picture(pf)) = &sh.fill {
// A group that keeps a fill for its pictures shows no editor for that fill while its
// shapes have the slide background fill.
let shown_fill = sh.fill.as_ref().filter(|_| !members_background);
if let Some(Fill::Picture(pf)) = shown_fill {
picture_fill_options(app, ui, sh.id.0, pf);
}
if let Some(Fill::Gradient(g)) = &sh.fill {
if let Some(Fill::Gradient(g)) = shown_fill {
let sc = scheme(app);
if let Some(ng) = crate::fillui::gradient_editor(ui, "shape-grad", g, &sc) {
run(app, "shape.fill", json!({"gradient": crate::fillui::gradient_json(&ng)}));
@@ -386,7 +389,7 @@ pub(super) fn format_shape(app: &mut SlideApp, ui: &mut Ui) {
run(app, "shape.fill", json!({"gradient": crate::fillui::gradient_json(&ng)}));
}
}
if let Some(Fill::Pattern(pt)) = &sh.fill
if let Some(Fill::Pattern(pt)) = shown_fill
&& let Some(np) = crate::fillui::pattern_editor(ui, pt, &scheme(app))
{
run(app, "shape.fill", json!({"pattern": crate::fillui::pattern_json(&np)}));