From 837475a126fbcb27161a5c7cda311742c27656f7 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 27 Nov 2026 15:15:49 +0000 Subject: [PATCH] app compile group 1: callers use the owners' current names and signatures Opening overlay takes the Ui; palette gate reads palette_open; glyph cells opt in through glyph_layout; dialog option helpers take 'static labels; Font keeps its own colour label (dialogs-w4 deleted the shared one); album words use craft::ui::words!; preferences tests reply through craft::automation::control::Reply; hyperlink test maps shapes to their clicks; caretBlink writes SlideApp::caret_blink as pinned. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/app.rs | 4 ++-- crates/ui-egui/src/canvas/tool.rs | 2 +- crates/ui-egui/src/control.rs | 5 ++--- crates/ui-egui/src/dialogs.rs | 3 ++- crates/ui-egui/src/dialogs/action.rs | 4 ++-- crates/ui-egui/src/dialogs/bullets.rs | 5 +++-- crates/ui-egui/src/dialogs/chart_data.rs | 2 +- crates/ui-egui/src/dialogs/export.rs | 2 +- crates/ui-egui/src/dialogs/font.rs | 13 +++++++++++-- crates/ui-egui/src/dialogs/photo_album.rs | 2 +- crates/ui-egui/src/dialogs/preferences_tests.rs | 6 ++++-- crates/ui-egui/src/dialogs/tests.rs | 10 +++++----- 12 files changed, 35 insertions(+), 23 deletions(-) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index fcd4a9a97..7fc1122c9 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -159,7 +159,7 @@ impl SlideApp { picture: Default::default(), ruler_tab_kind: Default::default(), canvas_menu: None, - editor_motion: None, + caret_blink: None, last_fill: json!("accent1"), last_outline: json!("tx1"), table_pen: json!({"width": 1.0}), @@ -432,7 +432,7 @@ impl SlideApp { fn shell_body_end(&mut self, ui: &mut egui::Ui, _cx: &mut craft::ui::contract::BodyCx<'_>) { let ctx = ui.ctx().clone(); - self.opening_ui(&ctx); + self.opening_ui(ui); // PLAN: assumed doc_window::show(&mut SlideApp, &mut Ui) (shell-w3) doc_window::show(self, ui); toast::note_missing_fonts(self); diff --git a/crates/ui-egui/src/canvas/tool.rs b/crates/ui-egui/src/canvas/tool.rs index d2680ac70..6e1515d61 100644 --- a/crates/ui-egui/src/canvas/tool.rs +++ b/crates/ui-egui/src/canvas/tool.rs @@ -163,7 +163,7 @@ impl CanvasTool for EngineTool<'_> { && rotatable && !self.app.backstage_open() && self.app.show.is_none() - && self.app.palette.is_none() + && !self.app.palette_open { let delta = wheel.rotation.clamp(-std::f32::consts::PI, std::f32::consts::PI); self.run("shape.rotate", json!({"by": f64::from(delta.to_degrees()), "gesture": "move"})); diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index 8ed9db6a0..077f850b5 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -710,7 +710,7 @@ fn set_pane_and_mode_state(app: &mut SlideApp, params: &Value) -> Result<(), Str if index >= comments { return Err(format!("slide {slide} has no comment {index}")); } - crate::panels::focus_comment(app, slide, index); + crate::panels::comments::focus_comment(app, slide, index); } } Ok(()) @@ -819,8 +819,7 @@ fn set_state_hooks(app: &mut SlideApp, params: &Value) -> Result<(), String> { app.ui.notes_height = pane_sizes.notes_height; } if let Some(on) = caret_blink { - // PLAN: assumed SlideApp::editor_motion: Option (canvas-w8) - app.editor_motion = (!on).then_some(craft::behavior::MotionMode::Off); + app.caret_blink = Some(on); } if let Some(paths) = recent { app.recent_checked.clear(); diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index 47b6dc8f4..7adfa8fe4 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -326,7 +326,8 @@ pub(crate) fn control(app: &mut SlideApp, ctx: &Context, method: &str, params: & WindowDialogs::of(ctx, &WindowKey::main()).with(|host| match method { "ui.dialog.open" => Some((|| { let params = Params(params).only(None, &["id", "params", "fields"])?; - let id = Params(¶ms).str_field("id")?.ok_or("missing `id`")?; + let params_view = Params(¶ms); + let id = params_view.str_field("id")?.ok_or("missing `id`")?; let fields = match params.get("fields") { Some(Value::Object(fields)) => fields.iter().map(|(key, value)| (key.clone(), value.clone())).collect::>(), Some(_) => return Err("fields must be an object".into()), diff --git a/crates/ui-egui/src/dialogs/action.rs b/crates/ui-egui/src/dialogs/action.rs index f8846ec46..100c07b51 100644 --- a/crates/ui-egui/src/dialogs/action.rs +++ b/crates/ui-egui/src/dialogs/action.rs @@ -80,7 +80,7 @@ fn seed(fields: &mut DialogFields, on: &str, link: Option<&Hyperlink>, slides: & fields.set(format!("{on}.highlight"), link.is_none_or(|link| link.highlight_click)); } -fn options(values: [(&str, &str); N]) -> Vec<(String, craft::ui::runtime::env::Label)> { +fn options(values: [(&'static str, &'static str); N]) -> Vec<(String, craft::ui::runtime::env::Label)> { values.into_iter().map(|(key, label)| (key.into(), label.into())).collect() } @@ -90,7 +90,7 @@ fn rows(on: &str, caption: &str, slides: &[(deckcraft_model::SlideId, String)], vec![ Param::new( key("kind"), - caption, + caption.to_owned(), ParamKind::radio( options([("none", "None"), ("link", "Hyperlink to:"), ("program", "Run program:"), ("playMedia", "Play the shape's media")]), None, diff --git a/crates/ui-egui/src/dialogs/bullets.rs b/crates/ui-egui/src/dialogs/bullets.rs index 8f520ca72..e01232c89 100644 --- a/crates/ui-egui/src/dialogs/bullets.rs +++ b/crates/ui-egui/src/dialogs/bullets.rs @@ -6,6 +6,7 @@ use craft::ui::patterns::form_dialogs::{ use craft::ui::pickers::{IconPicker, IconPickerGroup, IconPickerItem, IconPickerSearch}; use craft::ui::runtime::env::UnitKind; use craft::ui::sections::{DialogRole, FooterButton}; +use craft::ui::tile_grid::GlyphLayout; use egui::Context; use serde_json::{Value, json}; @@ -30,8 +31,8 @@ fn styles( cells .iter() .map(|(key, glyph)| { - // PLAN: assumed IconPickerItem::wide_glyph(self, wide: bool) -> Self (dialogs-w2) - IconPickerItem::new((*key).to_owned(), *glyph).glyph((*glyph).to_owned()).wide_glyph(wide) + let item = IconPickerItem::new((*key).to_owned(), *glyph).glyph((*glyph).to_owned()); + if wide { item.glyph_layout(GlyphLayout::Wide) } else { item } }) .collect(), )]; diff --git a/crates/ui-egui/src/dialogs/chart_data.rs b/crates/ui-egui/src/dialogs/chart_data.rs index d35f214ad..0d4349f41 100644 --- a/crates/ui-egui/src/dialogs/chart_data.rs +++ b/crates/ui-egui/src/dialogs/chart_data.rs @@ -82,7 +82,7 @@ pub(crate) fn open(app: &crate::SlideApp, ctx: &egui::Context, _params: &Value) .close_unchanged(true) }); }; - let mut cells = vec![std::iter::once(String::new()).chain(chart.series.iter().map(|series| series.name.clone())).collect()]; + let mut cells: Vec> = vec![std::iter::once(String::new()).chain(chart.series.iter().map(|series| series.name.clone())).collect()]; for (at, category) in chart.categories.iter().enumerate() { let values = chart .series diff --git a/crates/ui-egui/src/dialogs/export.rs b/crates/ui-egui/src/dialogs/export.rs index 818b59ed3..13fb23ec7 100644 --- a/crates/ui-egui/src/dialogs/export.rs +++ b/crates/ui-egui/src/dialogs/export.rs @@ -8,7 +8,7 @@ use serde_json::{Value, json}; use crate::SlideApp; -fn options(values: [(&str, &str); N]) -> Vec<(String, Label)> { +fn options(values: [(&'static str, &'static str); N]) -> Vec<(String, Label)> { values.into_iter().map(|(key, label)| (key.into(), label.into())).collect() } diff --git a/crates/ui-egui/src/dialogs/font.rs b/crates/ui-egui/src/dialogs/font.rs index eb256b415..f80bc2a78 100644 --- a/crates/ui-egui/src/dialogs/font.rs +++ b/crates/ui-egui/src/dialogs/font.rs @@ -14,6 +14,15 @@ use serde_json::{Value, json}; use crate::SlideApp; +/// The colour box's text for the engine's colour value: a scheme name or an RGB string. +fn color_label(value: &Value) -> String { + match value { + Value::String(text) => text.clone(), + Value::Object(object) => object.get("scheme").or_else(|| object.get("rgb")).and_then(Value::as_str).unwrap_or("").to_owned(), + _ => String::new(), + } +} + /// The sizes the sample shows at: small enough to fit the form, large enough to read. const SAMPLE_PT: std::ops::RangeInclusive = 12.0..=28.0; @@ -30,7 +39,7 @@ pub(crate) fn open(app: &SlideApp, ctx: &egui::Context, params: &Value) -> Hoste fields.set(key, params[key].as_str().unwrap_or("none")); } let color = params.get("color").cloned().unwrap_or(Value::Null); - fields.set("color", super::color_label(&color)); + fields.set("color", color_label(&color)); fields.set("colorWas", FieldValue::Json(color)); let theme_rows = Arc::new(crate::ribbon::fonts::theme_font_rows(app)); HostedParamDialog::new(ctx, "font", fields, move |fields| { @@ -149,7 +158,7 @@ pub(crate) fn finish(app: &mut SlideApp, result: &ParamResult, _host: &mut Dialo Some(FieldValue::Json(value)) => value, _ => &Value::Null, }; - if color == super::color_label(original) { + if color == color_label(original) { if !original.is_null() { params["color"] = original.clone(); } diff --git a/crates/ui-egui/src/dialogs/photo_album.rs b/crates/ui-egui/src/dialogs/photo_album.rs index 3218b0289..f6a44e098 100644 --- a/crates/ui-egui/src/dialogs/photo_album.rs +++ b/crates/ui-egui/src/dialogs/photo_album.rs @@ -14,7 +14,7 @@ use serde_json::{Value, json}; use crate::SlideApp; -craft_ui::words! { +craft::ui::words! { /// The sentences the album's custom rows write themselves; `{rot}`, `{brightness}` and `{contrast}` stand for the /// selected picture's values. struct AlbumWords { diff --git a/crates/ui-egui/src/dialogs/preferences_tests.rs b/crates/ui-egui/src/dialogs/preferences_tests.rs index 90b77872d..f256724f8 100644 --- a/crates/ui-egui/src/dialogs/preferences_tests.rs +++ b/crates/ui-egui/src/dialogs/preferences_tests.rs @@ -5,7 +5,9 @@ use egui_kittest::kittest::Queryable; use egui_kittest::{Harness, Node}; use serde_json::{Value, json}; -use crate::control::{ControlRequest, Outcome, handle}; +use craft::automation::control::{ControlRequest, Reply}; + +use crate::control::handle; use crate::state::Brightness; use crate::test_harness::harness; use crate::{Services, SlideApp}; @@ -30,7 +32,7 @@ fn dark(app: &SlideApp) -> bool { fn request(h: &mut Harness<'_, SlideApp>, method: &str, params: Value) { let (request, _reply) = ControlRequest::new(method, params); let ctx = h.ctx.clone(); - let Outcome::Done(answer) = handle(h.state_mut(), &ctx, &request) else { panic!("{method} must reply") }; + let Reply::Done(answer) = handle(h.state_mut(), &ctx, &request) else { panic!("{method} must reply") }; assert_eq!(answer["ok"], true, "{method}: {answer}"); } diff --git a/crates/ui-egui/src/dialogs/tests.rs b/crates/ui-egui/src/dialogs/tests.rs index cf62dd443..e3f43b46f 100644 --- a/crates/ui-egui/src/dialogs/tests.rs +++ b/crates/ui-egui/src/dialogs/tests.rs @@ -166,11 +166,11 @@ fn a_text_span_reports_the_link_it_covers() { let unlinked = Shape::default(); let linked = Shape { click: Some(url(address, tip)), ..Default::default() }; let other = Shape { click: Some(url(address, "other")), ..Default::default() }; - // PLAN: assumed common_click<'a>(impl IntoIterator, &[SlideId]) -> CurrentLink (dialogs-w9) - assert_eq!(common_click([&unlinked, &unlinked], &slides), CurrentLink::None); - assert_eq!(common_click([&linked], &slides), CurrentLink::One(UiHyperlink::new(LinkTarget::Url(address.into())).tooltip(tip))); - assert_eq!(common_click([&linked, &other], &slides), CurrentLink::Mixed); - assert_eq!(common_click(std::iter::empty::<&Shape>(), &slides), CurrentLink::None); + let clicks = |shapes: &[&Shape]| shapes.iter().map(|shape| shape.click.clone()).collect::>(); + assert_eq!(common_click(clicks(&[&unlinked, &unlinked]), &slides), CurrentLink::None); + assert_eq!(common_click(clicks(&[&linked]), &slides), CurrentLink::One(UiHyperlink::new(LinkTarget::Url(address.into())).tooltip(tip))); + assert_eq!(common_click(clicks(&[&linked, &other]), &slides), CurrentLink::Mixed); + assert_eq!(common_click(clicks(&[]), &slides), CurrentLink::None); } #[test]