DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
I: video and sound — media frames, posters, EPUB players (+ Media panel)
Brandon Thomas839887eb041d
diff --git a/ROADMAP.md b/ROADMAP.mdindex 178beee96..da3e72024 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -92,6 +92,7 @@ DesignCraft aims at full Adobe InDesign parity — and to be better: faster, ope- Liquid Layout (`liquid.pageRule/object`, `guide.liquid`, `layout.createAlternate`, Liquid Layout panel): scale / re-center / guide-based / object-based page rules applied on page resize and Document Setup; dashed liquid guides; alternate layouts as resized page copies in a named section. Alternate layouts aren't linked to their source.- Split Window / New Window (`window.split`, `window.newWindow`, Window ▸ Arrange): two side-by-side views of the document with their own zoom, scroll and render cache. New Window opens that second view rather than a separate OS window.- Transparency flattener (`file.exportPdf {flatten: high|medium|low|ppi}`, Edit ▸ Transparency Flattener Presets): spreads with transparency are rasterised per page in the exported PDF. It doesn't yet keep text and vectors outside transparent areas.+- Video and sound (place .mp4/.mov/.webm/.mp3/.wav…, `media.options/get`, Media panel): media frames show a poster or placeholder on screen, in print and in PDF, and export as HTML5 `<video>`/`<audio>` in EPUB. No in-app playback or PDF rich media.- Drag and drop text editing: drag selected text to move it (Alt copies) with its formatting (`text.release`).- Image Import Options: place any page of a multi-page PDF (`file.place {pdfPage}`; the app asks which page), shown on screen and embedded as that page in PDF export.- Define Lists: named numbered lists that continue across stories in page order (`list.define`, paragraph `listName` / `startAt`), round-tripped through IDML; `null` in `type.para` / `type.char` now removes an override.diff --git a/apps/designcraft/src/main.rs b/apps/designcraft/src/main.rsindex 52ac54828..c8f534187 100644--- a/apps/designcraft/src/main.rs+++ b/apps/designcraft/src/main.rs@@ -122,10 +122,19 @@ fn services() -> Services {"xlsx","idml","designcraft",+ "mp4",+ "m4v",+ "mov",+ "webm",+ "mp3",+ "m4a",+ "wav",+ "ogg",],).add_filter("Graphics", &["png", "jpg", "jpeg", "gif", "webp", "tif", "tiff", "bmp", "psd", "svg", "pdf", "ai"]).add_filter("Text (Word, RTF, plain, Excel)", &["docx", "rtf", "txt", "md", "xlsx"])+ .add_filter("Video and sound", &["mp4", "m4v", "mov", "webm", "mp3", "m4a", "wav", "ogg"])} else {d.add_filter("DesignCraft or IDML", &["designcraft", "idml"]).add_filter("DesignCraft", &["designcraft"])diff --git a/crates/doc/src/item.rs b/crates/doc/src/item.rsindex edb88aad0..127aed898 100644--- a/crates/doc/src/item.rs+++ b/crates/doc/src/item.rs@@ -463,6 +463,63 @@ pub struct ObjectLiquid {pub pin_right: bool,}+/// Media panel options for a placed video or sound.+#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase", default)]+pub struct MediaOptions {+ pub play_on_page_load: bool,+ #[serde(rename = "loop")]+ pub looping: bool,+ /// Show the player controls.+ pub controls: bool,+ /// Poster image (shown on the page and in print); `None` = a placeholder frame.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub poster: Option<AssetId>,+}++impl Item {+ /// The graphic to draw for this frame: a media frame with a poster draws the poster+ /// stretched over the media rectangle.+ pub fn drawn_graphic(&self, assets: &std::collections::BTreeMap<AssetId, Arc<crate::Asset>>) -> Option<Graphic> {+ let Content::Graphic(g) = &self.content else { return None };+ if let Some(poster) = self.media.as_ref().and_then(|m| m.poster)+ && let Some((pw, ph)) = assets.get(&poster).and_then(|a| a.pixels)+ {+ let (pw, ph) = (pw.max(1) as f64, ph.max(1) as f64);+ return Some(Graphic { asset: poster, size: (pw, ph), xf: g.xf * Affine::scale_non_uniform(g.size.0 / pw, g.size.1 / ph), ..g.clone() });+ }+ Some(g.clone())+ }+}++/// "video" or "audio" for a media MIME type.+pub fn media_kind(mime: &str) -> Option<&'static str> {+ if mime.starts_with("video/") {+ Some("video")+ } else if mime.starts_with("audio/") {+ Some("audio")+ } else {+ None+ }+}++/// MIME type of a media file by its extension.+pub fn media_mime(name: &str) -> Option<&'static str> {+ let ext = name.rsplit('.').next()?.to_ascii_lowercase();+ Some(match ext.as_str() {+ "mp4" | "m4v" => "video/mp4",+ "mov" => "video/quicktime",+ "webm" => "video/webm",+ "ogv" => "video/ogg",+ "mp3" => "audio/mpeg",+ "m4a" => "audio/mp4",+ "wav" => "audio/wav",+ "ogg" | "oga" => "audio/ogg",+ "aac" => "audio/aac",+ _ => return None,+ })+}+/// A button's On Release action.#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]#[serde(rename_all = "camelCase", tag = "kind")]@@ -744,6 +801,9 @@ pub struct Item {/// Liquid Layout (object-based pages): pins and resize permissions.#[serde(default, skip_serializing_if = "Option::is_none")]pub liquid: Option<ObjectLiquid>,+ /// Window › Interactive › Media: options of a placed video or sound.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub media: Option<MediaOptions>,/// Buttons and Forms: what clicking this object does in an interactive PDF.#[serde(default, skip_serializing_if = "Option::is_none")]pub button: Option<ButtonAction>,@@ -796,6 +856,7 @@ impl Item {alt_text: String::new(),xml_tag: String::new(),button: None,+ media: None,liquid: None,states: Vec::new(),active_state: 0,diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rsindex dd0e81be0..a86d02514 100644--- a/crates/engine/src/cmd/file.rs+++ b/crates/engine/src/cmd/file.rs@@ -219,6 +219,10 @@ fn file_place(s: &mut Session, p: &Value) -> Result<Value> {if lname.ends_with(".idml") || lname.ends_with(".designcraft") {return place_layout_page(s, p, &name, &bytes);}+ // Video and sound: a media frame (Window › Interactive › Media).+ if let Some(mime) = designcraft_doc::media_mime(&name) {+ return super::media::place_media(s, p, name, mime, bytes, link);+ }// Text files (plain, Word, RTF) flow into frames.if designcraft_textimport::is_text_file(&name) {return super::place_text::place_text(s, p, &name, &bytes);diff --git a/crates/engine/src/cmd/media.rs b/crates/engine/src/cmd/media.rsnew file mode 100644index 000000000..6eb756471--- /dev/null+++ b/crates/engine/src/cmd/media.rs@@ -0,0 +1,187 @@+//! Window › Interactive › Media: placed video and sound (shown as a poster or a placeholder,+//! exported as `<video>` / `<audio>` in EPUB).++use std::sync::Arc;++use designcraft_doc::{Asset, AssetId, Content, Graphic, Item, ItemId, MediaOptions, Shape};+use designcraft_geom::{Affine, Rect, shapes};+use serde_json::{Value, json};++use super::{CommandSpec, bad, cmd, has_selection, ok, targets};+use crate::{Result, Session};++pub(crate) fn place_media(s: &mut Session, p: &Value, name: String, mime: &str, bytes: Vec<u8>, link: Option<String>) -> Result<Value> {+ let video = mime.starts_with("video/");+ let (w, h) = (+ p.get("width").and_then(Value::as_f64).unwrap_or(if video { 320.0 } else { 200.0 }),+ p.get("height").and_then(Value::as_f64).unwrap_or(if video { 180.0 } else { 48.0 }),+ );+ let target = super::id_param(p, "frame").or_else(|| {+ let st = s.active()?;+ st.selection.items.iter().copied().find(|i| st.doc.item(*i).is_some_and(|it| matches!(it.content, Content::Unassigned | Content::Graphic(_))))+ });+ let spread = super::spread_param(p, "spread");+ let lid = s.doc()?.active_layer;+ let (px, py) = (p.get("x").and_then(Value::as_f64), p.get("y").and_then(Value::as_f64));+ let mime = mime.to_string();+ s.edit(|d, sel| {+ let aid = AssetId(d.alloc());+ d.assets.insert(aid, Arc::new(Asset { page: 0, id: aid, name, mime, link, data: Arc::new(bytes), pixels: None }));+ let id = match target {+ Some(fid) => {+ let it = d.item_mut(fid).ok_or(designcraft_doc::DocError::NoItem(fid))?;+ let r = it.inner_bounds();+ it.content = Content::Graphic(Graphic {+ asset: aid,+ size: (r.width(), r.height()),+ xf: Affine::translate((r.x0, r.y0)),+ auto_fit: Default::default(),+ fit_align: 4,+ crop: [0.0; 4],+ });+ it.media = Some(MediaOptions { controls: true, ..Default::default() });+ fid+ }+ None => {+ let pr = d.spread(spread).and_then(|sp| sp.pages.first()).map(|pg| pg.margin_rect()).unwrap_or(Rect::new(36.0, 36.0, 300.0, 300.0));+ let (x, y) = (px.unwrap_or(pr.x0), py.unwrap_or(pr.y0));+ let id = ItemId(d.alloc());+ let mut it = Item::new(id, lid, Shape::Rectangle, shapes::rectangle(Rect::new(x, y, x + w, y + h)));+ it.content = Content::Graphic(Graphic {+ asset: aid,+ size: (w, h),+ xf: Affine::translate((x, y)),+ auto_fit: Default::default(),+ fit_align: 4,+ crop: [0.0; 4],+ });+ it.media = Some(MediaOptions { controls: true, ..Default::default() });+ d.insert_item(spread, it, None)?;+ id+ }+ };+ sel.items = vec![id];+ sel.text = None;+ Ok(json!({"id": id.0, "asset": aid.0, "media": true}))+ })+}++pub fn specs() -> Vec<CommandSpec> {+ vec![+ cmd!(+ "media.options",+ "Media Options",+ [],+ None,+ "{ids?, playOnPageLoad?, loop?, controls?, poster?: {path | base64+name} | null (placeholder)} — for placed video and sound",+ has_selection,+ |s, p| {+ let ids = targets(s, p)?;+ // A poster image is read before the edit.+ let poster = match p.get("poster") {+ Some(Value::Object(_)) => {+ let (bytes, name, link) = super::file::read_source(&p["poster"])?;+ let px = designcraft_render::image_size(&bytes).ok_or_else(|| bad("media.options", "the poster isn't a readable image"))?;+ Some(Some((bytes, name, link, px)))+ }+ Some(Value::Null) => Some(None),+ _ => None,+ };+ s.edit(|d, _| {+ let poster_id = match poster {+ Some(Some((bytes, name, link, px))) => {+ let aid = AssetId(d.alloc());+ let mime = designcraft_render::image_mime(&bytes).to_string();+ d.assets.insert(aid, Arc::new(Asset { page: 0, id: aid, name, mime, link, data: Arc::new(bytes), pixels: Some(px) }));+ Some(Some(aid))+ }+ Some(None) => Some(None),+ None => None,+ };+ let mut n = 0;+ for id in &ids {+ let Some(it) = d.item_mut(*id) else { continue };+ let Some(m) = &mut it.media else { continue };+ if let Some(v) = p.get("playOnPageLoad").and_then(Value::as_bool) {+ m.play_on_page_load = v;+ }+ if let Some(v) = p.get("loop").and_then(Value::as_bool) {+ m.looping = v;+ }+ if let Some(v) = p.get("controls").and_then(Value::as_bool) {+ m.controls = v;+ }+ if let Some(ps) = poster_id {+ m.poster = ps;+ }+ n += 1;+ }+ if n == 0 {+ return Err(bad("media.options", "select a video or sound"));+ }+ ok()+ })+ }+ ),+ cmd!(query "media.get", "Media", [], None, "{id?} → {kind, name, playOnPageLoad, loop, controls, poster}", has_selection, |s, p| {+ let id = super::id_param(p, "id").or_else(|| s.active().and_then(|d| d.selection.items.first().copied())).ok_or_else(|| bad("media.get", "no selection"))?;+ let d = &s.doc()?.doc;+ let it = d.item(id).ok_or_else(|| bad("media.get", "no such object"))?;+ let (Some(m), Content::Graphic(g)) = (&it.media, &it.content) else { return Err(bad("media.get", "not a video or sound")) };+ let a = d.assets.get(&g.asset);+ Ok(json!({"kind": a.and_then(|a| designcraft_doc::media_kind(&a.mime)), "name": a.map(|a| a.name.clone()), "playOnPageLoad": m.play_on_page_load,+ "loop": m.looping, "controls": m.controls, "poster": m.poster.map(|p| p.0)}))+ }),+ ]+}++#[cfg(test)]+mod tests {+ use serde_json::json;++ use crate::Session;++ #[test]+ fn media_frames_place_render_and_export() {+ let mut s = Session::new();+ s.execute("file.new", &json!({})).unwrap();+ let fake = super::super::file::base64_encode(b"\x00\x00\x00\x18ftypmp42");+ let r = s.execute("file.place", &json!({"base64": fake, "name": "clip.mp4", "x": 100, "y": 100})).unwrap();+ let id = r["id"].clone();+ let g = s.execute("media.get", &json!({"id": id})).unwrap();+ assert_eq!(g["kind"], "video");+ assert_eq!(g["controls"], true);+ // The placeholder is dark with a light play mark.+ let d = s.doc().unwrap().doc.clone();+ let mut rr = designcraft_render::Renderer::new();+ rr.threads = 0;+ let img = rr.render_page(&d, &s.cache, 0, 1.0, false, &Default::default()).unwrap();+ assert!(img.pixel(110, 110)[0] < 80, "dark frame");+ assert!(img.pixel(260, 190)[0] > 200, "play mark");+ // A poster replaces the placeholder.+ let px: Vec<u8> = (0..8 * 8).flat_map(|_| [255, 0, 0, 255]).collect();+ let png = designcraft_render::Rendered { width: 8, height: 8, pixels: px }.to_png();+ s.execute(+ "media.options",+ &json!({"ids": [id], "loop": true, "poster": {"base64": super::super::file::base64_encode(&png), "name": "p.png"}}),+ )+ .unwrap();+ let d = s.doc().unwrap().doc.clone();+ let img = rr.render_page(&d, &s.cache, 0, 1.0, false, &Default::default()).unwrap();+ let p = img.pixel(110, 110);+ assert!(p[0] > 200 && p[1] < 60, "poster: {p:?}");+ // PDF export draws it; EPUB carries the video.+ assert!(s.execute("file.exportPdf", &json!({})).is_ok());+ let e = s.execute("file.exportEpub", &json!({})).unwrap();+ let bytes = super::super::file::base64_decode(e["base64"].as_str().unwrap());+ let mut z = zip::ZipArchive::new(std::io::Cursor::new(bytes)).unwrap();+ let mut read = |name: &str| {+ let mut s = String::new();+ std::io::Read::read_to_string(&mut z.by_name(name).unwrap(), &mut s).unwrap();+ s+ };+ assert!(read("OEBPS/content.opf").contains("video/mp4"), "the video is in the package");+ let x = read("OEBPS/content.xhtml");+ assert!(x.contains("<video src=") && x.contains("loop=") && x.contains("poster="), "{x}");+ }+}diff --git a/crates/engine/src/cmd/mod.rs b/crates/engine/src/cmd/mod.rsindex 2af86a9b6..002cff4ff 100644--- a/crates/engine/src/cmd/mod.rs+++ b/crates/engine/src/cmd/mod.rs@@ -27,6 +27,7 @@ mod linked;mod links;mod liquid;mod lists;+mod media;mod notes;mod object;mod overrides;@@ -159,6 +160,7 @@ pub fn command_specs() -> &'static [CommandSpec] {v.extend(library::specs());v.extend(lists::specs());v.extend(linked::specs());+ v.extend(media::specs());v.extend(liquid::specs());v.extend(xml::specs());v.extend(strokes::specs());diff --git a/crates/epub/src/lib.rs b/crates/epub/src/lib.rsindex dda615da0..3c8a2c561 100644--- a/crates/epub/src/lib.rs+++ b/crates/epub/src/lib.rs@@ -320,6 +320,15 @@ fn ext(mime: &str) -> &'static str {"image/gif" => "gif","image/webp" => "webp","image/svg+xml" => "svg",+ "video/mp4" => "mp4",+ "video/quicktime" => "mov",+ "video/webm" => "webm",+ "video/ogg" => "ogv",+ "audio/mpeg" => "mp3",+ "audio/mp4" => "m4a",+ "audio/wav" => "wav",+ "audio/ogg" => "ogg",+ "audio/aac" => "aac",_ => "png",}}@@ -356,6 +365,29 @@ fn body_html<'a>(if a.data.is_empty() {continue;}+ // Video and sound: an HTML5 player (with the poster, when there is one).+ if let Some(kind) = designcraft_doc::media_kind(&a.mime) {+ let name = format!("media/{}.{}", g.asset.0, ext(&a.mime));+ images.insert(name.clone(), (a.mime.as_str(), a.data.as_slice()));+ let m = doc.item(*iid).and_then(|i| i.media.clone()).unwrap_or_default();+ let mut attrs = String::new();+ for (on, attr) in+ [(m.controls, " controls=\"controls\""), (m.play_on_page_load, " autoplay=\"autoplay\""), (m.looping, " loop=\"loop\"")]+ {+ if on {+ attrs.push_str(attr);+ }+ }+ if let Some(pa) = m.poster.and_then(|p| doc.assets.get(&p)) {+ let pn = format!("images/{}.{}", pa.id.0, ext(&pa.mime));+ images.insert(pn.clone(), (pa.mime.as_str(), pa.data.as_slice()));+ if kind == "video" {+ attrs.push_str(&format!(" poster=\"{}\"", img_src(&pn, &pa.mime, &pa.data)));+ }+ }+ let _ = writeln!(body, "<figure><{kind} src=\"{}\"{attrs}>{}</{kind}></figure>", img_src(&name, &a.mime, &a.data), esc(&a.name));+ continue;+ }let name = format!("images/{}.{}", g.asset.0, ext(&a.mime));images.insert(name.clone(), (a.mime.as_str(), a.data.as_slice()));// Alt text from Object Export Options, else the file name.diff --git a/crates/pdf/src/export.rs b/crates/pdf/src/export.rsindex 6ed3af647..c4c90c11a 100644--- a/crates/pdf/src/export.rs+++ b/crates/pdf/src/export.rs@@ -785,6 +785,7 @@ impl Exporter<'_> {// Content.match &it.content {Content::Graphic(g) => {+ let g = &if it.media.is_some() { it.drawn_graphic(&self.doc.assets).unwrap_or_else(|| g.clone()) } else { g.clone() };if let Some(p) = &path {s.push_clip_path(p, &FillRule::NonZero);self.graphic(s, g);@@ -1027,6 +1028,29 @@ impl Exporter<'_> {}pub(crate) fn graphic(&mut self, s: &mut Surface, g: &designcraft_doc::Graphic) {+ // Video / sound without a poster: a dark frame with a play mark.+ if let Some(asset) = self.doc.assets.get(&g.asset)+ && designcraft_doc::media_kind(&asset.mime).is_some()+ {+ let (w, h) = g.size;+ let (cx, cy, r) = (w / 2.0, h / 2.0, w.min(h) * 0.18);+ let mut tri = BezPath::new();+ tri.move_to((cx - r * 0.6, cy - r));+ tri.line_to((cx + r, cy));+ tri.line_to((cx - r * 0.6, cy + r));+ tri.close_path();+ s.push_transform(&tf(g.xf));+ s.set_stroke(None);+ for (bp, c) in [(Rect::new(0.0, 0.0, w, h).to_path(0.1), rgb::Color::new(48, 48, 52)), (tri, rgb::Color::new(235, 235, 235))] {+ if let Some(p) = to_path(&bp) {+ s.set_fill(Some(Fill { paint: c.into(), ..Default::default() }));+ s.draw_path(&p);+ }+ }+ s.set_fill(None);+ s.pop();+ return;+ }// Placed PDFs go in as vectors (the page as a form XObject).if let Some(asset) = self.doc.assets.get(&g.asset)&& asset.data.starts_with(b"%PDF")diff --git a/crates/render/src/lib.rs b/crates/render/src/lib.rsindex 058dbd8fe..4777779ea 100644--- a/crates/render/src/lib.rs+++ b/crates/render/src/lib.rs@@ -505,6 +505,7 @@ impl Renderer {// Content.match &it.content {Content::Graphic(g) => {+ let g = &if it.media.is_some() { it.drawn_graphic(&f.doc.assets).unwrap_or_else(|| g.clone()) } else { g.clone() };ctx.set_transform(f.view * xf);ctx.push_clip_layer(bp);self.draw_graphic(ctx, f, g, xf);@@ -638,6 +639,21 @@ impl Renderer {pub(crate) fn draw_graphic(&mut self, ctx: &mut RenderContext, f: &Frame, g: &designcraft_doc::Graphic, xf: Affine) {let Some(asset) = f.doc.assets.get(&g.asset) else { return };+ if designcraft_doc::media_kind(&asset.mime).is_some() {+ // Video / sound: a dark frame with a play mark (the poster, when set, is drawn by the item).+ ctx.set_transform(f.view * xf * g.xf);+ ctx.set_paint(peniko::Color::from_rgba8(48, 48, 52, 255));+ ctx.fill_rect(&Rect::new(0.0, 0.0, g.size.0, g.size.1));+ let (cx, cy, r) = (g.size.0 / 2.0, g.size.1 / 2.0, g.size.0.min(g.size.1) * 0.18);+ let mut tri = BezPath::new();+ tri.move_to((cx - r * 0.6, cy - r));+ tri.line_to((cx + r, cy));+ tri.line_to((cx - r * 0.6, cy + r));+ tri.close_path();+ ctx.set_paint(peniko::Color::from_rgba8(235, 235, 235, 255));+ ctx.fill_path(&tri);+ return;+ }if f.opts.quality == DisplayQuality::Fast {ctx.set_transform(f.view * xf * g.xf);ctx.set_paint(peniko::Color::from_rgba8(178, 178, 178, 255));diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rsindex 0d19b3078..96689d600 100644--- a/crates/ui-egui/src/dock.rs+++ b/crates/ui-egui/src/dock.rs@@ -41,6 +41,7 @@ pub const ICON_PANELS: &[(&str, &str, &str)] = &[("states", "Object States", "panel-articles"),("buttons", "Buttons and Forms", "panel-articles"),("liquid", "Liquid Layout", "panel-pages"),+ ("media", "Media", "panel-articles"),];pub fn show(app: &mut DesignApp, ui: &mut egui::Ui) {@@ -187,6 +188,7 @@ pub fn panel_body(app: &mut DesignApp, ui: &mut egui::Ui, id: &str) {"states" => panels::interactive::states(app, ui),"buttons" => panels::interactive::buttons(app, ui),"liquid" => panels::interactive::liquid(app, ui),+ "media" => panels::interactive::media(app, ui),"table" => panels::table::show(app, ui),_ => panels::properties::info_panel(app, ui),}diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rsindex 7c7e3b01e..698a53a4e 100644--- a/crates/ui-egui/src/menus.rs+++ b/crates/ui-egui/src/menus.rs@@ -544,6 +544,7 @@ pub const MENUS: &[(&str, &[&str])] = &["ui:window.panel|Articles|{\"panel\": \"articles\"}","ui:window.panel|Object States|{\"panel\": \"states\"}","ui:window.panel|Buttons and Forms|{\"panel\": \"buttons\"}",+ "ui:window.panel|Media|{\"panel\": \"media\"}","ui:window.panel|Liquid Layout|{\"panel\": \"liquid\"}","ui:window.panel|Tags|{\"panel\": \"tags\"}","ui:window.panel|Book|{\"panel\": \"book\"}",diff --git a/crates/ui-egui/src/panels/interactive.rs b/crates/ui-egui/src/panels/interactive.rsindex a3250fc76..17d714a23 100644--- a/crates/ui-egui/src/panels/interactive.rs+++ b/crates/ui-egui/src/panels/interactive.rs@@ -343,3 +343,32 @@ pub fn liquid(app: &mut DesignApp, ui: &mut egui::Ui) {}ui.data_mut(|x| x.insert_temp(key, (name, w, h)));}++/// Media panel: the selected video or sound's playback options and poster.+pub fn media(app: &mut DesignApp, ui: &mut egui::Ui) {+ let t = Tokens::get(ui.ctx());+ let Ok(m) = app.session.execute("media.get", &json!({})) else {+ ui.label(egui::RichText::new("Select a placed video or sound (File › Place a .mp4, .mov, .mp3, .wav …).").size(11.0).color(t.text_dim));+ return;+ };+ ui.label(egui::RichText::new(format!("{} — {}", m["kind"].as_str().unwrap_or(""), m["name"].as_str().unwrap_or(""))).strong());+ for (key, label) in [("playOnPageLoad", "Play on Page Load"), ("loop", "Loop"), ("controls", "Show Controls")] {+ let mut on = m[key].as_bool().unwrap_or(false);+ if ui.checkbox(&mut on, label).changed() {+ let _ = app.run("media.options", json!({key: on}));+ }+ }+ ui.horizontal(|ui| {+ ui.label("Poster");+ if ui.button("Choose Image…").clicked()+ && let Some(path) = app.services.pick_open.as_mut().and_then(|f| f("place"))+ && let Err(e) = app.run("media.options", json!({"poster": {"path": path}}))+ {+ app.status(format!("Media: {e}"));+ }+ if !m["poster"].is_null() && ui.small_button("None").clicked() {+ let _ = app.run("media.options", json!({"poster": null}));+ }+ });+ ui.label(egui::RichText::new("Plays in EPUB export; print and PDF show the poster.").size(10.5).color(t.text_dim));+}diff --git a/docs/parity.md b/docs/parity.mdindex 57e23b467..5d236a9c8 100644--- a/docs/parity.md+++ b/docs/parity.md@@ -11,7 +11,7 @@ Each row of the InDesign feature catalogue is scored **D** (done), **P** (partia|---|---|---|---|---|---|| P0 | 102 | 99 | 3 | 0 | 99% || P1 | 97 | 92 | 5 | 0 | 97% |-| P2 | 76 | 40 | 26 | 10 | 70% |+| P2 | 76 | 40 | 27 | 9 | 70% || Area | Parity ||---|---|@@ -22,7 +22,7 @@ Each row of the InDesign feature catalogue is scored **D** (done), **P** (partia| Transform | 100% || Fill, stroke, colour | 96% || Effects & transparency | 75% |-| Placing & links | 90% |+| Placing & links | 91% || Type & text frames | 94% || Typography | 98% || Styles | 97% |@@ -180,7 +180,7 @@ Open P0 items: Preferences, Vector/page formats (PDF/AI/SVG/EPS place), Export t| Placing & links | Image import options | P1 | D || Placing & links | Linked text/stories | P2 | D || Placing & links | Display performance | P0 | D |-| Placing & links | Video/audio | P2 | M |+| Placing & links | Video/audio | P2 | P || Type & text frames | Text frames | P0 | D || Type & text frames | Threading | P0 | D || Type & text frames | Overset detection & indicator | P0 | D |