Merge branch 'port/deckcraft/cfix/app-1' into port/deckcraft/area/app

This commit is contained in:
Dylan M. Taylor committed 2026-11-27 15:16:17 +00:00
commit 4203a4b649
12 files changed
+35 -23

No files matched your search

+2 -2
View File
@@ -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);
+1 -1
View File
@@ -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"}));
+2 -3
View File
@@ -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<craft::behavior::MotionMode> (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();
+2 -1
View File
@@ -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(&params).str_field("id")?.ok_or("missing `id`")?;
let params_view = Params(&params);
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::<Vec<_>>(),
Some(_) => return Err("fields must be an object".into()),
+2 -2
View File
@@ -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<const N: usize>(values: [(&str, &str); N]) -> Vec<(String, craft::ui::runtime::env::Label)> {
fn options<const N: usize>(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,
+3 -2
View File
@@ -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(),
)];
+1 -1
View File
@@ -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<String>> = 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
+1 -1
View File
@@ -8,7 +8,7 @@ use serde_json::{Value, json};
use crate::SlideApp;
fn options<const N: usize>(values: [(&str, &str); N]) -> Vec<(String, Label)> {
fn options<const N: usize>(values: [(&'static str, &'static str); N]) -> Vec<(String, Label)> {
values.into_iter().map(|(key, label)| (key.into(), label.into())).collect()
}
+11 -2
View File
@@ -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<f32> = 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();
}
+1 -1
View File
@@ -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 {
@@ -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}");
}
+5 -5
View File
@@ -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<Item = &'a Shape>, &[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::<Vec<_>>();
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]