panels-w5: net change of 3 commits

- panels-w5: written by an agent
- panels-w5: finished by an agent
- panels-w5: finished by an agent
This commit is contained in:
Dylan M. Taylor committed 2026-11-27 14:51:31 +00:00
1 parent 05b194b42c
commit 025155d603
2 files changed
+579 -968

No files matched your search

+179 -403
View File
@@ -1,446 +1,222 @@
//! Task panes on the right: Format Shape, Format Background, Animation, Selection, Comments and
//! Design Ideas.
//! The editor's thumbnail, outline, notes and task panes.
use deckcraft_model::{AnimClass, AnimStart, Fill, ShapeKind};
use egui::{Align2, Color32, CornerRadius, Rect, Sense, Stroke, Ui, pos2, vec2};
use std::cell::RefCell;
use craft::ui::contract::{BodyCx, PaneEdge, SizeLimits};
use craft::ui::patterns::dock::{PaneArea, PaneContent, PaneEdges, PaneRequest, PaneSpec, PaneState, SidePolicy};
use craft::ui::runtime::env::{Env, Label};
use egui::{Ui, vec2};
use serde_json::{Value, json};
use crate::icons::{self, Icon};
use crate::ribbon::{cref_param, paint_anim_tile};
use crate::theme::{self, Tokens};
use crate::{SlideApp, widgets};
use crate::SlideApp;
use crate::ribbon::cref_param;
use crate::state::ViewMode;
pub mod animation;
mod background;
pub(crate) mod color_row;
mod comments;
mod designer;
mod effect_presets;
pub mod format_shape;
mod preset_grid;
// PLAN: plan error: panels-w13 must supply panels/revisions.rs and revisions(app, ui).
mod revisions;
mod smartart;
mod thesaurus;
use animation::animation;
use background::background;
use comments::{comments, revisions};
use comments::comments;
use designer::designer;
use format_shape::format_shape;
pub(crate) use format_shape::text_transparency_slider;
#[cfg(test)]
use format_shape::{fill_transparency_to_apply, solid_fill_transparency_percent};
use revisions::revisions;
use smartart::smartart;
use thesaurus::thesaurus;
pub fn show(app: &mut SlideApp, ui: &mut Ui) {
let t = Tokens::get(ui.ctx());
let Some(pane) = app.ui.pane.clone() else { return };
egui::Panel::right("task_pane")
.resizable(true)
.default_size(app.ui.pane_width)
.size_range(240.0..=520.0)
.frame(egui::Frame::NONE.fill(t.card).inner_margin(egui::Margin::same(10)))
.show(ui, |ui| {
app.ui.pane_width = ui.available_width() + 20.0;
let title = match pane.as_str() {
"format" => "Format Shape",
"background" => "Format Background",
"animation" => "Animation Pane",
"selection" => "Selection",
"comments" => "Comments",
"designer" => "Design Ideas",
"smartart" => "Text Pane",
"thesaurus" => "Thesaurus",
"revisions" => "Revisions",
_ => "Pane",
};
ui.horizontal(|ui| {
ui.label(egui::RichText::new(title).font(theme::bold(16.0)));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
let (r, resp) = ui.allocate_exact_size(vec2(20.0, 20.0), Sense::click());
if resp.hovered() {
ui.painter().rect_filled(r, CornerRadius::same(4), t.hover);
}
icons::paint(ui.painter(), r.shrink(3.0), Icon::Close, t.text_dim, false);
if resp.clicked() {
app.ui.pane = None;
}
});
});
ui.add_space(6.0);
egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| match pane.as_str() {
"format" => format_shape(app, ui),
"background" => background(app, ui),
"animation" => animation(app, ui),
"selection" => crate::selpane::show(app, ui),
"comments" => comments(app, ui),
"designer" => designer(app, ui),
"smartart" => smartart(app, ui),
"thesaurus" => thesaurus(app, ui),
"revisions" => revisions(app, ui),
craft::ui::words! {
/// Titles of the editor panes, resolved in the editor's language.
struct TaskPaneWords {
format: plain = "Format Shape";
background: plain = "Format Background";
animation: plain = "Animation Pane";
selection: plain = "Selection";
comments: plain = "Comments";
designer: plain = "Design Ideas";
smartart: plain = "Text Pane";
thesaurus: plain = "Thesaurus";
revisions: plain = "Revisions";
pane: plain = "Pane";
slides: plain = "Slides";
outline: plain = "Outline";
notes: plain = "Notes";
editor: plain = "Editor";
}
}
/// An editor pane or named task pane.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub(crate) enum Pane {
/// Slide or master thumbnails at the start edge.
Thumbs,
/// The presentation's text outline at the start edge.
Outline,
/// Speaker notes below the canvas.
Notes,
/// The task identified by the saved `view.pane` parameter.
Task(String),
}
struct Content<'a, 'b> {
app: &'a RefCell<&'b mut SlideApp>,
words: &'a TaskPaneWords,
}
impl Content<'_, '_> {
fn title(&self, pane: &Pane) -> Label {
let words = self.words;
match pane {
Pane::Thumbs => &words.slides,
Pane::Outline => &words.outline,
Pane::Notes => &words.notes,
Pane::Task(id) => match id.as_str() {
"format" => &words.format,
"background" => &words.background,
"animation" => &words.animation,
"selection" => &words.selection,
"comments" => &words.comments,
"designer" => &words.designer,
"smartart" => &words.smartart,
"thesaurus" => &words.thesaurus,
"revisions" => &words.revisions,
_ => &words.pane,
},
}
.clone()
}
fn apply(&self, requests: Vec<PaneRequest<Pane>>) {
let mut app = self.app.borrow_mut();
for request in requests {
match request {
PaneRequest::Close(Pane::Task(_)) => run(&mut app, "view.pane", json!({"pane": null})),
PaneRequest::Resize(Pane::Thumbs, size) => app.ui.thumbs_width = size,
PaneRequest::Resize(Pane::Notes, size) => app.ui.notes_height = size,
PaneRequest::Resize(Pane::Task(_), size) => app.ui.pane_width = size,
_ => {}
});
}
}
}
}
impl PaneContent<Pane> for Content<'_, '_> {
fn spec(&self, pane: &Pane) -> PaneSpec {
let (edge, size, min, max) = match pane {
Pane::Thumbs => (PaneEdge::Start, 236.0, 150.0, 420.0),
Pane::Outline => (PaneEdge::Start, 360.0, 240.0, 520.0),
Pane::Notes => (PaneEdge::Bottom, 160.0, 36.0, 400.0),
Pane::Task(_) => (PaneEdge::End, 300.0, 240.0, 520.0),
};
let mut spec = PaneSpec::new(self.title(pane), PaneState::docked(edge, size), vec2(size, size));
spec.movable = false;
spec.closable = matches!(pane, Pane::Task(_));
spec.title_bar = spec.closable;
spec.menu = false;
spec.collection_body = matches!(pane, Pane::Thumbs | Pane::Outline);
if matches!(pane, Pane::Task(_)) {
spec.edges = PaneEdges::SIDES;
}
spec.limits = if matches!(pane, Pane::Notes) {
SizeLimits { min: vec2(0.0, min), max: Some(vec2(SizeLimits::BOUND, max)) }
} else {
SizeLimits { min: vec2(min, 0.0), max: Some(vec2(max, SizeLimits::BOUND)) }
};
spec
}
fn state(&self, pane: &Pane) -> Option<PaneState> {
let app = self.app.borrow();
Some(match pane {
Pane::Thumbs => PaneState::docked(PaneEdge::Start, app.ui.thumbs_width),
Pane::Outline => PaneState::docked(PaneEdge::Start, 360.0),
Pane::Notes => PaneState::docked(PaneEdge::Bottom, app.ui.notes_height),
Pane::Task(_) => PaneState::docked(PaneEdge::End, app.ui.pane_width),
})
}
fn body(&mut self, pane: &Pane, ui: &mut Ui, cx: &mut BodyCx<'_>) {
let mut app = self.app.borrow_mut();
match pane {
Pane::Thumbs => thumbs::body(&mut app, ui, cx),
Pane::Outline => crate::sorter::outline_body(&mut app, ui, cx),
// PLAN: plan error: notes::pane_body remains a panels-w7 stub despite its pn.A2 id.
Pane::Notes => notes::pane_body(&mut app, ui, cx),
Pane::Task(id) => match id.as_str() {
"format" => format_shape(&mut app, ui),
"background" => background(&mut app, ui),
"animation" => animation(&mut app, ui),
"selection" => selpane::show(&mut app, ui),
"comments" => comments(&mut app, ui),
"designer" => designer(&mut app, ui),
"smartart" => smartart(&mut app, ui),
"thesaurus" => thesaurus(&mut app, ui),
"revisions" => revisions(&mut app, ui),
_ => {}
},
}
}
}
/// Shows the editor panes around the canvas, with notes inside the side panes.
pub(crate) fn show_editor(app: &mut SlideApp, ui: &mut Ui) {
let words = Env::of(ui).view().words::<TaskPaneWords>();
let mut outer = Vec::new();
if app.ui.view == ViewMode::Outline {
outer.push(Pane::Outline);
} else if app.session.active().is_some_and(|doc| !doc.selection.target.is_page_master()) {
outer.push(Pane::Thumbs);
}
if let Some(id) = &app.ui.pane {
outer.push(Pane::Task(id.clone()));
}
let inner = if app.ui.notes && app.session.active().is_some_and(|doc| doc.selection.target == deckcraft_engine::Target::Slides) {
vec![Pane::Notes]
} else {
Vec::new()
};
let shared = RefCell::new(app);
let mut content = Content { app: &shared, words: &words };
let out = PaneArea::new(words.editor.clone(), &outer, &mut content).policy(SidePolicy::OneSlot).show(ui, |ui, _| {
let mut notes = Content { app: &shared, words: &words };
let out = PaneArea::new(words.notes.clone(), &inner, &mut notes).policy(SidePolicy::OneSlot).show(ui, |ui, _| {
crate::canvas::show(&mut shared.borrow_mut(), ui);
});
notes.apply(out.requests);
});
content.apply(out.requests);
}
fn run(app: &mut SlideApp, id: &str, p: Value) {
let _ = app.run(id, p);
}
fn scheme(app: &SlideApp) -> deckcraft_color::ColorScheme {
app.session.active().and_then(|d| d.doc.masters.first().map(|m| m.scheme())).unwrap_or_else(|| deckcraft_model::Theme::default().colors)
}
fn color_button(
app: &mut SlideApp,
ui: &mut Ui,
label: &str,
none_label: Option<&str>,
on_pick: impl Fn(Option<deckcraft_model::ColorRef>) -> (String, Value),
) {
let sc = scheme(app);
ui.horizontal(|ui| {
ui.label(label);
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
let r = widgets::drop_button(ui, "Color", vec2(70.0, 22.0), true);
widgets::color_popup(&r).show(|ui| {
if let Some(c) = widgets::color_grid(ui, &sc, none_label) {
let (id, p) = on_pick(c);
run(app, &id, p);
}
});
});
});
}
pub mod animtimeline;
pub mod fillui;
pub mod notes;
pub mod selpane;
#[cfg(test)]
mod smartart_tests;
pub mod thumbs;
#[cfg(test)]
mod smartart_tests;
#[cfg(test)]
mod background_tests;
#[cfg(test)]
mod effect_presets_tests;
#[cfg(test)]
mod pattern_fill_tests;
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
use deckcraft_color::{ColorTransform, SchemeSlot};
use deckcraft_engine::Session;
use deckcraft_model::{ColorRef, Fill, ShapeId};
use egui_kittest::Harness;
use egui_kittest::kittest::{NodeT, Queryable};
use serde_json::json;
use super::{fill_transparency_to_apply, solid_fill_transparency_percent};
use crate::{Services, SlideApp};
#[test]
fn solid_fill_transparency_reads_the_alpha_shape_fill_writes() {
assert_eq!(solid_fill_transparency_percent(None), 0.0);
assert_eq!(solid_fill_transparency_percent(Some(&Fill::None)), 0.0);
assert_eq!(solid_fill_transparency_percent(Some(&Fill::Group)), 0.0);
let plain = Fill::solid(ColorRef::scheme(SchemeSlot::Accent1));
assert_eq!(solid_fill_transparency_percent(Some(&plain)), 0.0);
// `shape.fill` transparency 0.4 stores Alpha((1 - 0.4) * 100_000).
let forty = Fill::solid(ColorRef::scheme(SchemeSlot::Accent1).with(ColorTransform::Alpha(60_000)));
let p = solid_fill_transparency_percent(Some(&forty));
assert!((p - 40.0).abs() < 0.01, "{p}");
let clear = Fill::solid(ColorRef::scheme(SchemeSlot::Accent1).with(ColorTransform::Alpha(0)));
assert!((solid_fill_transparency_percent(Some(&clear)) - 100.0).abs() < 0.01);
// A later alpha wins, matching ColorRef::alpha.
let layered = Fill::solid(ColorRef::scheme(SchemeSlot::Accent1).with(ColorTransform::Alpha(0)).with(ColorTransform::Alpha(60_000)));
assert!((solid_fill_transparency_percent(Some(&layered)) - 40.0).abs() < 0.01);
assert_eq!(fill_transparency_to_apply(40.0, 40.0), None);
assert_eq!(fill_transparency_to_apply(40.005, 40.0), None);
assert_eq!(fill_transparency_to_apply(f32::NAN, 40.0), None);
assert_eq!(fill_transparency_to_apply(55.0, 40.0), Some(0.55));
assert_eq!(fill_transparency_to_apply(0.0, 40.0), Some(0.0));
}
fn solid_alpha(app: &SlideApp, id: u32) -> Option<i32> {
let sh = app.session.active()?.shape(ShapeId(id))?;
let Fill::Solid { color } = sh.fill.as_ref()? else { return None };
color.mods.iter().find_map(|m| match m {
ColorTransform::Alpha(v) => Some(*v),
_ => None,
})
}
fn slider_values(h: &Harness<'_, SlideApp>) -> Vec<f64> {
h.query_all_by_role(egui::accesskit::Role::Slider).filter_map(|n| n.accesskit_node().numeric_value()).collect()
}
/// The Fill slider shows the selected solid's transparency, and opening the pane
/// (or looking at another shape first) does not write 0% over it.
#[test]
fn fill_transparency_slider_follows_the_selection() {
let mut s = Session::with_new();
s.execute("slide.new", &json!({"layout": "blank"})).unwrap();
let a = s.execute("shape.insert", &json!({"preset": "rect", "rect": [40.0, 40.0, 120.0, 80.0]})).unwrap()["id"].as_u64().unwrap() as u32;
let b = s.execute("shape.insert", &json!({"preset": "rect", "rect": [200.0, 40.0, 120.0, 80.0]})).unwrap()["id"].as_u64().unwrap() as u32;
s.execute("shape.fill", &json!({"id": a, "color": "accent1", "transparency": 0.0})).unwrap();
s.execute("shape.fill", &json!({"id": b, "color": "accent1", "transparency": 0.4})).unwrap();
s.execute("edit.select", &json!({"ids": [a]})).unwrap();
// P3(panels-w5): sh.A2
let mut app = SlideApp::new_base(s, Services::default());
app.ui.pane = Some("format".into());
app.ui.format_tab = "fill".into();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
let opaque: Vec<f64> = slider_values(&h);
assert!(opaque.iter().any(|v| (*v - 0.0).abs() < 0.5), "opaque shape should show 0%, got {opaque:?}");
assert!(opaque.iter().all(|v| (*v - 40.0).abs() > 0.5), "opaque shape should not show 40%, got {opaque:?}");
h.state_mut().session.execute("edit.select", &json!({"ids": [b]})).unwrap();
h.run_steps(3);
let clear: Vec<f64> = slider_values(&h);
assert!(clear.iter().any(|v| (*v - 40.0).abs() < 0.5), "40% fill should show 40%, got {clear:?}");
assert_eq!(solid_alpha(h.state(), b), Some(60_000));
// 0.37 exposes the slider's numeric entry as a SpinButton with the same name; target the
// Slider itself so the click lands on the slider, not its text field. A click at its
// middle is a real edit (50%), not a side effect of opening the pane or selecting b.
h.get_by_role_and_label(egui::accesskit::Role::Slider, "Transparency").click();
h.run_steps(2);
assert_eq!(solid_alpha(h.state(), b), Some(50_000));
let changed: Vec<f64> = slider_values(&h);
assert!(changed.iter().any(|v| (*v - 50.0).abs() < 0.5), "the changed slider shows 50%, got {changed:?}");
}
/// A blank slide with one selected rectangle, its fill set by `fill` (none for an automatic fill),
/// in Format Shape ▸ Fill.
fn fill_pane(fill: Option<serde_json::Value>) -> Harness<'static, SlideApp> {
let mut s = Session::with_new();
s.execute("slide.new", &json!({"layout": "blank"})).unwrap();
let id = s.execute("shape.insert", &json!({"preset": "rect", "rect": [40.0, 40.0, 120.0, 80.0]})).unwrap()["id"].as_u64().unwrap();
s.execute("edit.select", &json!({"ids": [id]})).unwrap();
if let Some(p) = fill {
s.execute("shape.fill", &p).unwrap();
}
// P3(panels-w5): sh.A2
let mut app = SlideApp::new_base(s, Services::default());
app.ui.pane = Some("format".into());
app.ui.format_tab = "fill".into();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h
}
fn picture_fill(transparency: f64) -> serde_json::Value {
let png = deckcraft_render::Image { width: 2, height: 2, pixels: [255, 0, 0, 255].repeat(4) }.to_png();
json!({"picture": deckcraft_engine::cmd::base64_encode(&png), "transparency": transparency})
}
/// The "Color" drop buttons in the pane: the fill's, when it shows, and the line's.
fn color_buttons(h: &Harness<'_, SlideApp>) -> usize {
h.query_all_by_role(egui::accesskit::Role::Button).filter(|n| n.accesskit_node().label().is_some_and(|l| l.trim() == "Color")).count()
}
/// Fill colour and transparency controls appear only for fill kinds they can actually modify.
#[test]
fn fill_color_and_transparency_show_only_where_they_change_the_fill() {
let gradient = json!({"gradient": {"stops": [[0, "accent1"], [1, "accent2"]], "angle": 90}});
for (name, fill, color, transparency) in [
("automatic", None, true, 1),
("solid", Some(json!({"color": "accent2"})), true, 1),
("no fill", Some(json!({"none": true})), false, 0),
// The one Transparency row left is the selected gradient stop's.
("gradient", Some(gradient), false, 1),
("picture", Some(picture_fill(0.0)), false, 1),
] {
let h = fill_pane(fill);
let fill_color = color_buttons(&h) == 2;
assert_eq!(fill_color, color, "{name}: fill Color button");
// 0.37 gives each slider's numeric entry its own SpinButton with the same name, so count
// the sliders themselves: one per visible Transparency row.
assert_eq!(
h.query_all_by_role_and_label(egui::accesskit::Role::Slider, "Transparency").count(),
transparency,
"{name}: Transparency rows"
);
}
}
/// The picture-fill transparency slider reflects and edits the picture fill's own transparency.
#[test]
fn picture_fill_transparency_slider_shows_the_picture_transparency() {
let mut h = fill_pane(Some(picture_fill(0.4)));
let alpha = |h: &Harness<'_, SlideApp>| {
let doc = h.state().session.active().unwrap();
match &doc.selected_shapes()[0].fill {
Some(Fill::Picture(pf)) => pf.alpha,
other => panic!("expected a picture fill, got {other:?}"),
}
};
let shown = slider_values(&h);
assert!(shown.iter().any(|v| (*v - 40.0).abs() < 0.5), "a 40% transparent picture should show 40%, got {shown:?}");
// 0.37 exposes the slider's numeric entry as a SpinButton with the same name and excludes
// a label that names another control from label queries, so find the painted label itself:
// clicking it must leave the picture's transparency alone.
let label = h
.get_all_by_role(egui::accesskit::Role::Label)
.find(|n| n.value().as_deref() == Some("Transparency"))
.expect("the Transparency label is there");
label.click();
h.run_steps(2);
assert!(alpha(&h).is_some_and(|a| (a - 0.6).abs() < 1e-9), "{:?}", alpha(&h));
}
/// Slide background fill is one of the Fill options. It has no Color button or Transparency
/// slider of its own.
#[test]
fn slide_background_fill_is_a_fill_option() {
let mut h = fill_pane(None);
let fill = |h: &Harness<'_, SlideApp>| h.state().session.active().unwrap().selected_shapes()[0].fill.clone();
let undo = h.state().session.active().unwrap().history.undo.len();
h.get_by_label("Slide background fill").click();
h.run_steps(3);
assert_eq!(fill(&h), Some(Fill::Background));
assert_eq!(h.state().session.active().unwrap().history.undo.len(), undo + 1, "one undo step");
assert_eq!(h.get_by_label("Slide background fill").accesskit_node().toggled(), Some(egui::accesskit::Toggled::True));
assert_eq!(color_buttons(&h), 1, "only the line's Color button");
assert_eq!(h.query_all_by_role_and_label(egui::accesskit::Role::Slider, "Transparency").count(), 0);
// A shape that already has the background fill shows this option chosen, not Automatic.
let h = fill_pane(Some(json!({"background": true})));
assert_eq!(h.get_by_label("Slide background fill").accesskit_node().toggled(), Some(egui::accesskit::Toggled::True));
let automatic = h.query_all_by_label("Automatic").filter(|n| n.accesskit_node().toggled() == Some(egui::accesskit::Toggled::True)).count();
assert_eq!(automatic, 1, "only the line's Automatic is chosen");
}
/// A picture cannot save a slide background fill, so its Fill options leave it out. A group
/// that holds a shape keeps the option.
#[test]
fn a_picture_has_no_slide_background_fill_option() {
let pane = |group: bool| {
let mut s = Session::with_new();
s.execute("slide.new", &json!({"layout": "blank"})).unwrap();
let png = deckcraft_render::Image { width: 2, height: 2, pixels: [255, 0, 0, 255].repeat(4) }.to_png();
let pic =
s.execute("insert.picture", &json!({"data": deckcraft_engine::cmd::base64_encode(&png), "name": "red.png"})).unwrap()["id"].clone();
if group {
let shape = s.execute("shape.insert", &json!({"preset": "rect", "rect": [500.0, 40.0, 120.0, 80.0]})).unwrap()["id"].clone();
s.execute("edit.select", &json!({"ids": [pic, shape]})).unwrap();
s.execute("arrange.group", &json!({})).unwrap();
s.execute("shape.fill", &json!({"color": "#ff0000"})).unwrap();
}
// P3(panels-w5): sh.A2
let mut app = SlideApp::new_base(s, Services::default());
app.ui.pane = Some("format".into());
app.ui.format_tab = "fill".into();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h
};
let h = pane(false);
assert!(h.query_by_label("Pattern fill").is_some(), "the Fill options are shown");
assert!(h.query_by_label("Slide background fill").is_none());
let mut h = pane(true);
h.get_by_label("Slide background fill").click();
h.run_steps(3);
let st = h.state().session.active().unwrap();
let group = st.selected_shapes()[0];
let fills: Vec<_> = group.children().iter().map(|m| m.fill.clone()).collect();
assert_eq!(fills[1], Some(Fill::Background), "the group's shape takes the fill");
assert!(matches!(fills[0], Some(Fill::Solid { .. })), "the picture keeps its fill: {:?}", fills[0]);
assert_eq!(group.fill, None, "the group's own fill is cleared");
assert_eq!(h.get_by_label("Slide background fill").accesskit_node().toggled(), Some(egui::accesskit::Toggled::True));
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");
}
/// A group whose picture uses the group's fill keeps that fill, and still shows Slide
/// background fill chosen once its shapes have it.
#[test]
fn a_group_that_keeps_its_fill_shows_slide_background_fill() {
let mut s = Session::with_new();
s.execute("slide.new", &json!({"layout": "blank"})).unwrap();
let png = deckcraft_render::Image { width: 2, height: 2, pixels: [0, 0, 0, 0].repeat(4) }.to_png();
let pic = s.execute("insert.picture", &json!({"data": deckcraft_engine::cmd::base64_encode(&png), "name": "clear.png"})).unwrap()["id"]
.as_u64()
.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();
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(p) = slide.shape_mut(ShapeId(pic as u32)) {
p.fill = Some(Fill::Group);
}
}
Ok(())
})
.unwrap();
// P3(panels-w5): sh.A2
let mut app = SlideApp::new_base(s, Services::default());
app.ui.pane = Some("format".into());
app.ui.format_tab = "fill".into();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h.get_by_label("Slide background fill").click();
h.run_steps(3);
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");
}
}
#[cfg(test)]
mod thesaurus_tests;
/// An editor pane or named task pane.
#[allow(dead_code)] // P3(panels-w5): pn.A2
pub(crate) enum Pane {
Thumbs,
Outline,
Notes,
Task(String),
}
/// Shows the editor panes and canvas.
#[allow(dead_code)] // P3(panels-w5): pn.A2
pub(crate) fn show_editor(app: &mut SlideApp, ui: &mut Ui) {
let _ = (app, ui);
todo!("pn.A2")
}
pub(crate) mod color_row;
pub(crate) mod preset_grid;
// PLAN: plan error: panels-w8 must supply panels/format_shape_tests.rs with the moved tests.
#[cfg(test)]
mod format_shape_tests;
File diff suppressed because it is too large. Load diff