mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-01 10:47:56 +01:00
1 parent
71486f44a4
commit
3b3094e15f
93 files changed
+795
-1107
No files matched your search
@@ -177,8 +177,6 @@ impl eframe::App for PopupApp {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
self.receive(ui.ctx());
|
||||
ui.ctx().request_repaint_after(std::time::Duration::from_millis(500));
|
||||
AppShell::new(WindowKey::main())
|
||||
.page(true, SHOW_SCOPE, |ui, cx, app: &mut Self| app.page(ui, cx))
|
||||
.show(ui, self);
|
||||
AppShell::new(WindowKey::main()).page(true, SHOW_SCOPE, |ui, cx, app: &mut Self| app.page(ui, cx)).show(ui, self);
|
||||
}
|
||||
}
|
||||
@@ -141,8 +141,8 @@ fn startup(nightly: bool, args: impl IntoIterator<Item = String>) -> Result<Star
|
||||
let value = args.next().ok_or_else(|| format!("a value is required for '{a}'"))?;
|
||||
match a.as_str() {
|
||||
"--control" => {
|
||||
let port = control_port(&value)
|
||||
.map_err(|_| OptionsError::NotAPort { value, shown: "--control <PORT>".into() }.to_string())?;
|
||||
let port =
|
||||
control_port(&value).map_err(|_| OptionsError::NotAPort { value, shown: "--control <PORT>".into() }.to_string())?;
|
||||
flags.port = Some(port);
|
||||
flags.sources.port = Some(Source::Flag);
|
||||
}
|
||||
@@ -399,9 +399,8 @@ fn main() -> eframe::Result {
|
||||
let (mut platform, panels) = desktop_platform(install, settings, wake, at_exit);
|
||||
platform.intake = Some(intake);
|
||||
// The output device clocks media; disabling audio leaves playback silent.
|
||||
platform.audio_out = std::env::var_os("DECKCRAFT_NO_AUDIO")
|
||||
.is_none()
|
||||
.then(|| Box::new(audio::CpalOut::default()) as Box<dyn deckcraft_media::AudioOut>);
|
||||
platform.audio_out =
|
||||
std::env::var_os("DECKCRAFT_NO_AUDIO").is_none().then(|| Box::new(audio::CpalOut::default()) as Box<dyn deckcraft_media::AudioOut>);
|
||||
let mut listening = None;
|
||||
if let Some(port) = control.port {
|
||||
let token = control.server_token().unwrap_or_else(|error| {
|
||||
|
||||
@@ -20,11 +20,11 @@ mod links;
|
||||
mod picture;
|
||||
mod text_fields;
|
||||
|
||||
use album::{photo_album, photo_album_edit};
|
||||
pub use album::{
|
||||
ALBUM_MAX_BYTES, ALBUM_MAX_ITEMS, ALBUM_MAX_TEXT, ALBUM_MAX_TOTAL, album_check_item_count, album_check_picture_bytes, album_check_text,
|
||||
album_check_total_bytes,
|
||||
};
|
||||
use album::{photo_album, photo_album_edit};
|
||||
pub use chart::chart_type;
|
||||
use chart::{chart, chart_data, chart_options, chart_type_cmd};
|
||||
use links::{action_button, hyperlink, shape_action};
|
||||
|
||||
@@ -101,7 +101,10 @@ pub fn endpoints(x: &Xfrm) -> (Point, Point) {
|
||||
/// Connections to shapes that no longer exist are dropped.
|
||||
pub fn reroute(doc: &mut Presentation, sel: &Selection) {
|
||||
// Read first: taking the list mutably would unshare the edited slide even when no connector is glued.
|
||||
if !crate::shapes_of(doc, sel).iter().any(|s| matches!(s.kind, ShapeKind::Connector { start: Some(_), .. } | ShapeKind::Connector { end: Some(_), .. })) {
|
||||
if !crate::shapes_of(doc, sel)
|
||||
.iter()
|
||||
.any(|s| matches!(s.kind, ShapeKind::Connector { start: Some(_), .. } | ShapeKind::Connector { end: Some(_), .. }))
|
||||
{
|
||||
return;
|
||||
}
|
||||
let Some(list) = crate::shapes_mut(doc, sel) else { return };
|
||||
|
||||
@@ -288,9 +288,7 @@ impl Session {
|
||||
// Clicking inside the text being edited moves the caret / starts a text selection.
|
||||
let before = self.text_selection();
|
||||
let canonical_transform = matches!(transform_hit, Some(Some(Hit::Resize { .. } | Hit::Rotate { .. })));
|
||||
if !canonical_transform
|
||||
&& let Some((shape, pos)) = self.place_caret(p, tol, mods.shift)?
|
||||
{
|
||||
if !canonical_transform && let Some((shape, pos)) = self.place_caret(p, tol, mods.shift)? {
|
||||
let press = self.doc()?.selection.text.clone();
|
||||
self.tool.drag = Some(Drag::TextSelect { shape, before, press });
|
||||
return Ok(json!({"caret": [pos.0, pos.1]}));
|
||||
|
||||
@@ -499,7 +499,6 @@ fn instance_legacy_names(family: &str, style: &str) -> Option<(String, String)>
|
||||
Some((format!("{family} {weight}"), if style_italic(style) { "Italic" } else { "Regular" }.into()))
|
||||
}
|
||||
|
||||
|
||||
/// One face found in a font file: index, family, style and (variable fonts) the named instance's
|
||||
/// axis settings.
|
||||
type Found = (u32, String, String, Vec<([u8; 4], f32)>);
|
||||
@@ -874,7 +873,8 @@ impl FontDb {
|
||||
|
||||
/// Invalidates derived family lookups and coverage misses after catalogue changes.
|
||||
pub fn invalidate_catalog(&self) {
|
||||
*self.loaded_families.lock().unwrap_or_else(std::sync::PoisonError::into_inner) = (self.catalog.generation(), std::collections::HashSet::new());
|
||||
*self.loaded_families.lock().unwrap_or_else(std::sync::PoisonError::into_inner) =
|
||||
(self.catalog.generation(), std::collections::HashSet::new());
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
self.refresh_misses(true);
|
||||
}
|
||||
@@ -890,9 +890,8 @@ impl FontDb {
|
||||
}
|
||||
|
||||
fn add_catalog_face(&self, info: &craft::font_catalog::FaceInfo, data: &craft::font_catalog::FontData) {
|
||||
let present = |faces: &[Arc<FontFace>]| {
|
||||
faces.iter().any(|f| f.family.eq_ignore_ascii_case(&info.family) && f.style.eq_ignore_ascii_case(&info.style))
|
||||
};
|
||||
let present =
|
||||
|faces: &[Arc<FontFace>]| faces.iter().any(|f| f.family.eq_ignore_ascii_case(&info.family) && f.style.eq_ignore_ascii_case(&info.style));
|
||||
if present(&self.read_faces()) {
|
||||
return;
|
||||
}
|
||||
@@ -1545,13 +1544,7 @@ mod font_dir_tests {
|
||||
let home = root.join("home/ann");
|
||||
let file = root.join("fonts.conf");
|
||||
std::fs::write(&file, conf).unwrap();
|
||||
let env = FontEnv {
|
||||
os: Os::Unix,
|
||||
root: root.clone(),
|
||||
home: Some(home.clone()),
|
||||
fontconfig_file: Some(file.clone()),
|
||||
..FontEnv::default()
|
||||
};
|
||||
let env = FontEnv { os: Os::Unix, root: root.clone(), home: Some(home.clone()), fontconfig_file: Some(file.clone()), ..FontEnv::default() };
|
||||
for directory in [
|
||||
root.join("usr/share/fonts"),
|
||||
home.join(".local/share/fonts"),
|
||||
@@ -1588,11 +1581,7 @@ mod font_dir_tests {
|
||||
let _ = std::fs::remove_dir_all(&root);
|
||||
std::fs::create_dir_all(&root).unwrap();
|
||||
let file = root.join("fonts.conf");
|
||||
std::fs::write(
|
||||
&file,
|
||||
"<fontconfig><dir>/run/host/user-fonts</dir><dir>/run/host/user-fonts</dir></fontconfig>",
|
||||
)
|
||||
.unwrap();
|
||||
std::fs::write(&file, "<fontconfig><dir>/run/host/user-fonts</dir><dir>/run/host/user-fonts</dir></fontconfig>").unwrap();
|
||||
let env = FontEnv { os: Os::Unix, root: root.clone(), flatpak: true, fontconfig_file: Some(file), ..FontEnv::default() };
|
||||
for directory in ["run/host/fonts", "run/host/local-fonts", "run/host/user-fonts"] {
|
||||
assert_fixture_discovered_after_rescan(env.clone(), &root.join(directory));
|
||||
|
||||
@@ -14,8 +14,7 @@ impl SlideApp {
|
||||
.or_else(|| INTERVAL_CHOICES_MINUTES.into_iter().max().and_then(interval_for_minutes));
|
||||
let autosave = self.autosave.get_or_insert_with(|| Autosave::new(interval));
|
||||
autosave.set_interval(interval);
|
||||
let docs: Vec<_> =
|
||||
self.session.documents().iter().map(|d| AutosaveDoc { id: d.uid, revision: d.revision, dirty: d.is_dirty() }).collect();
|
||||
let docs: Vec<_> = self.session.documents().iter().map(|d| AutosaveDoc { id: d.uid, revision: d.revision, dirty: d.is_dirty() }).collect();
|
||||
let due = autosave.due(Instant::now(), docs.iter().copied());
|
||||
let mut failure = None;
|
||||
for uid in due.discard {
|
||||
|
||||
@@ -276,10 +276,12 @@ fn choose(
|
||||
current: &'static str,
|
||||
) -> &'static str {
|
||||
let source = keyed(rows, |row| row.0).with_text(|row| std::borrow::Cow::Borrowed(row.1));
|
||||
let output = List::new(label).select(SelectMode::Single).sizing(Sizing::Content).natural_height(true).selection(Bind::given(Selection::single(current))).show_items(
|
||||
ui,
|
||||
&source,
|
||||
&mut |key, _| {
|
||||
let output = List::new(label)
|
||||
.select(SelectMode::Single)
|
||||
.sizing(Sizing::Content)
|
||||
.natural_height(true)
|
||||
.selection(Bind::given(Selection::single(current)))
|
||||
.show_items(ui, &source, &mut |key, _| {
|
||||
let (_, label, detail, icon) = rows.iter().find(|row| row.0 == *key).copied().unwrap_or(("", "", "", None));
|
||||
let mut row = ListRow::new(label);
|
||||
if !detail.is_empty() {
|
||||
@@ -289,8 +291,7 @@ fn choose(
|
||||
row = row.icon(craft::behavior::IconId::new(icon.name()).into());
|
||||
}
|
||||
row
|
||||
},
|
||||
);
|
||||
});
|
||||
let mut selected = Some(current);
|
||||
for event in output.events {
|
||||
if let CollectionEvent::Selection { change, .. } = event {
|
||||
|
||||
@@ -104,7 +104,9 @@ pub(crate) fn show(app: &mut SlideApp, ui: &mut Ui) {
|
||||
media::gif_buttons(app, ui, &space, &gifs);
|
||||
}
|
||||
if let Some(pass) = tool_pass(&body.env) {
|
||||
let result = if !app.anim_preview_active() && let Some(mut dropper) = crate::eyedropper::tool(app) {
|
||||
let result = if !app.anim_preview_active()
|
||||
&& let Some(mut dropper) = crate::eyedropper::tool(app)
|
||||
{
|
||||
let result = ToolHost::new().run(ui, &pass, &mut dropper);
|
||||
crate::eyedropper::after_pass(app, ui.ctx(), dropper, space.view.rect);
|
||||
result
|
||||
|
||||
@@ -70,10 +70,9 @@ pub(crate) fn show_guides(app: &mut SlideApp, ui: &mut egui::Ui, space: &CanvasS
|
||||
.bounds(Rect::new(0.0, 0.0, size.width, size.height))
|
||||
.readout(GuideReadout::FromCentre)
|
||||
.show_at(ui, space.view.rect);
|
||||
let mut selected = output.select.map_or_else(
|
||||
|| app.guide_selection.guides.clone(),
|
||||
|key| key.and_then(|key| usize::try_from(key.get()).ok()).into_iter().collect(),
|
||||
);
|
||||
let mut selected = output
|
||||
.select
|
||||
.map_or_else(|| app.guide_selection.guides.clone(), |key| key.and_then(|key| usize::try_from(key.get()).ok()).into_iter().collect());
|
||||
for event in &output.edit.events {
|
||||
if let EditEvent::Commit { after, .. } | EditEvent::Set { after, .. } = event {
|
||||
let round = app.session.prefs.snap_to_grid && !craft::ui::runtime::pointer::frame(ui.ctx()).pick_mods.alt;
|
||||
|
||||
@@ -116,21 +116,9 @@ pub(crate) fn show(app: &mut SlideApp, ui: &mut egui::Ui, space: &CanvasSpace) {
|
||||
let size = ((page_size.width * scale).round().max(1.0) as u32, (page_size.height * scale).round().max(1.0) as u32);
|
||||
let visible = visible_region(space.view.visible(), scale);
|
||||
let picture = &mut app.picture;
|
||||
let source = picture.source.get_or_insert_with(|| Reach {
|
||||
uid,
|
||||
page,
|
||||
dimensions,
|
||||
slide: None,
|
||||
master: None,
|
||||
estimate: Rect::ZERO,
|
||||
drawn: Rect::ZERO,
|
||||
});
|
||||
if source.uid != uid
|
||||
|| source.page != page
|
||||
|| source.dimensions != dimensions
|
||||
|| !same(&source.slide, &slide)
|
||||
|| !same(&source.master, &master)
|
||||
{
|
||||
let source =
|
||||
picture.source.get_or_insert_with(|| Reach { uid, page, dimensions, slide: None, master: None, estimate: Rect::ZERO, drawn: Rect::ZERO });
|
||||
if source.uid != uid || source.page != page || source.dimensions != dimensions || !same(&source.slide, &slide) || !same(&source.master, &master) {
|
||||
let estimate = match layout {
|
||||
Some((master, layout)) => deckcraft_render::layout_extent(render_doc, master, layout),
|
||||
None => deckcraft_render::slide_extent(render_doc, index),
|
||||
@@ -143,13 +131,7 @@ pub(crate) fn show(app: &mut SlideApp, ui: &mut egui::Ui, space: &CanvasSpace) {
|
||||
let mut region = region_for(source.estimate.union(source.drawn));
|
||||
let revision_of = |region| {
|
||||
Revision::of(&(
|
||||
(
|
||||
uid,
|
||||
page,
|
||||
dimensions,
|
||||
source.slide.as_ref().map(|s| Arc::as_ptr(s) as usize),
|
||||
source.master.as_ref().map(|m| Arc::as_ptr(m) as usize),
|
||||
),
|
||||
(uid, page, dimensions, source.slide.as_ref().map(|s| Arc::as_ptr(s) as usize), source.master.as_ref().map(|m| Arc::as_ptr(m) as usize)),
|
||||
(size, scale.to_bits(), region, editing_text, crate::media::gif_key(&gifs), anim_key(anim), app.ui.grayscale),
|
||||
))
|
||||
};
|
||||
|
||||
@@ -25,11 +25,8 @@ pub(crate) fn paint(draw: &Draw<'_>, cx: &ToolContext<'_>, app: &SlideApp) {
|
||||
.guides
|
||||
.iter()
|
||||
.map(|g| {
|
||||
let (a, b) = if g.vertical {
|
||||
(Point::new(g.pos, g.from), Point::new(g.pos, g.to))
|
||||
} else {
|
||||
(Point::new(g.from, g.pos), Point::new(g.to, g.pos))
|
||||
};
|
||||
let (a, b) =
|
||||
if g.vertical { (Point::new(g.pos, g.from), Point::new(g.pos, g.to)) } else { (Point::new(g.from, g.pos), Point::new(g.to, g.pos)) };
|
||||
SmartLine::new(a, b).dashed()
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -94,10 +94,7 @@ fn drag_indents_add_move_and_remove_tabs_on_the_ruler() {
|
||||
drag(&mut h, Pos2::new(rx(moved), strip_y), Pos2::new(rx(moved), strip_y + 80.0));
|
||||
assert_eq!(ruler(&mut h)["tabs"], initial["tabs"], "dragging off removes the stop");
|
||||
|
||||
h.state_mut()
|
||||
.session
|
||||
.execute("format.tabs", &json!({"set": [{"pos": 72}, {"pos": 144, "align": "ctr"}, {"pos": 216, "align": "dec"}]}))
|
||||
.unwrap();
|
||||
h.state_mut().session.execute("format.tabs", &json!({"set": [{"pos": 72}, {"pos": 144, "align": "ctr"}, {"pos": 216, "align": "dec"}]})).unwrap();
|
||||
h.run_steps(2);
|
||||
let before_all = ruler(&mut h)["tabs"].clone();
|
||||
drag_with_modifiers(
|
||||
@@ -169,14 +166,9 @@ fn tabs_dialog_sets_clears_and_applies_on_ok() {
|
||||
.unwrap();
|
||||
h.run_steps(1);
|
||||
assert_eq!(ruler(&mut h), before, "draft stops stay in the dialog until OK");
|
||||
crate::dialogs::control(
|
||||
h.state_mut(),
|
||||
&ctx,
|
||||
"ui.dialog.set",
|
||||
&json!({"dialog": "top", "field": "stops", "value": [new_stop.clone()]}),
|
||||
)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
crate::dialogs::control(h.state_mut(), &ctx, "ui.dialog.set", &json!({"dialog": "top", "field": "stops", "value": [new_stop.clone()]}))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
h.run_steps(1);
|
||||
h.get_by_label("OK").click();
|
||||
h.run_steps(2);
|
||||
|
||||
@@ -95,12 +95,7 @@ fn commit_values(app: &mut SlideApp, before: &RulerValues, after: &RulerValues)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
const TAB_ALIGNS: [(&str, TabAlign); 4] = [
|
||||
("l", TabAlign::Left),
|
||||
("ctr", TabAlign::Center),
|
||||
("r", TabAlign::Right),
|
||||
("dec", TabAlign::Decimal),
|
||||
];
|
||||
const TAB_ALIGNS: [(&str, TabAlign); 4] = [("l", TabAlign::Left), ("ctr", TabAlign::Center), ("r", TabAlign::Right), ("dec", TabAlign::Decimal)];
|
||||
|
||||
fn tab_align(code: &str) -> TabAlign {
|
||||
TAB_ALIGNS.iter().find(|(name, _)| *name == code).map_or(TabAlign::Left, |(_, align)| *align)
|
||||
|
||||
@@ -86,12 +86,8 @@ fn a_placeholder_that_inherits_its_box_has_a_resize_cursor() {
|
||||
}
|
||||
|
||||
fn harness() -> Harness<'static, SlideApp> {
|
||||
let mut h = crate::test_harness::harness_with(
|
||||
Session::with_new(),
|
||||
Services::default(),
|
||||
Harness::builder().with_size(vec2(1200.0, 800.0)),
|
||||
|_| {},
|
||||
);
|
||||
let mut h =
|
||||
crate::test_harness::harness_with(Session::with_new(), Services::default(), Harness::builder().with_size(vec2(1200.0, 800.0)), |_| {});
|
||||
h.run_steps(3);
|
||||
h
|
||||
}
|
||||
|
||||
@@ -64,8 +64,11 @@ impl TextOffsets {
|
||||
}
|
||||
|
||||
fn selection(&self, selection: &TextSel) -> TextSelection {
|
||||
TextSelection::new(self.offset(selection.anchor), self.offset(selection.caret))
|
||||
.with_affinity(if selection.at_line_end() { CaretAffinity::Upstream } else { CaretAffinity::Downstream })
|
||||
TextSelection::new(self.offset(selection.anchor), self.offset(selection.caret)).with_affinity(if selection.at_line_end() {
|
||||
CaretAffinity::Upstream
|
||||
} else {
|
||||
CaretAffinity::Downstream
|
||||
})
|
||||
}
|
||||
|
||||
fn apply(&self, selection: TextSelection, target: &mut TextSel) {
|
||||
@@ -227,9 +230,10 @@ impl TextEditorHost for EngineTextHost<'_> {
|
||||
}
|
||||
|
||||
fn line_range(&mut self, line: usize) -> Range<usize> {
|
||||
self.frame.as_ref().and_then(|(layout, _)| layout.lines.get(line)).map_or(0..0, |line| {
|
||||
self.offsets.offset((line.para, line.start))..self.offsets.offset((line.para, line.end))
|
||||
})
|
||||
self.frame
|
||||
.as_ref()
|
||||
.and_then(|(layout, _)| layout.lines.get(line))
|
||||
.map_or(0..0, |line| self.offsets.offset((line.para, line.start))..self.offsets.offset((line.para, line.end)))
|
||||
}
|
||||
|
||||
fn line_step(&mut self, offset: usize, affinity: CaretAffinity, lines: i32) -> (usize, CaretAffinity) {
|
||||
@@ -325,9 +329,7 @@ pub(crate) fn show_editor(app: &mut crate::SlideApp, ui: &mut Ui, space: &Canvas
|
||||
return None;
|
||||
};
|
||||
let id = ui.make_persistent_id(("slide-text-editor", uid, target.shape, target.cell));
|
||||
if focus::focused_rec(ui.ctx())
|
||||
.is_some_and(|record| record.stop.id != id && record.stop.text && !record.stop.keys.is_document_editor())
|
||||
{
|
||||
if focus::focused_rec(ui.ctx()).is_some_and(|record| record.stop.id != id && record.stop.text && !record.stop.keys.is_document_editor()) {
|
||||
return None;
|
||||
}
|
||||
if let Err(error) = app.session.begin_text_edit_session() {
|
||||
|
||||
@@ -202,12 +202,7 @@ impl CanvasTool for EngineTool<'_> {
|
||||
self.app.twist_frame = Some(self.ctx.cumulative_frame_nr());
|
||||
self.run("shape.rotate", json!({"by": f64::from(delta.to_degrees()), "gesture": "move"}));
|
||||
}
|
||||
if self.app.session.tool.marquee.is_some()
|
||||
|| wheel.mods.cmd
|
||||
|| wheel.mods.ctrl
|
||||
|| wheel.zooms
|
||||
|| wheel.zoom != 1.0
|
||||
|| wheel.touch_zoom != 1.0
|
||||
if self.app.session.tool.marquee.is_some() || wheel.mods.cmd || wheel.mods.ctrl || wheel.zooms || wheel.zoom != 1.0 || wheel.touch_zoom != 1.0
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -217,8 +212,7 @@ impl CanvasTool for EngineTool<'_> {
|
||||
return;
|
||||
}
|
||||
let notch = f64::from(super::navigation().wheel_line);
|
||||
let turn =
|
||||
wheel_turn(&wheel, Some(true), notch, TurnAxis::Stronger).or_else(|| wheel_turn(&wheel, Some(false), notch, TurnAxis::Stronger));
|
||||
let turn = wheel_turn(&wheel, Some(true), notch, TurnAxis::Stronger).or_else(|| wheel_turn(&wheel, Some(false), notch, TurnAxis::Stronger));
|
||||
if let Some(forward) = turn {
|
||||
self.run(if forward { "slide.next" } else { "slide.previous" }, json!({}));
|
||||
}
|
||||
@@ -298,7 +292,15 @@ impl CanvasTool for EngineTool<'_> {
|
||||
ToolKey::Cancel if claims.keys.contains(&Chord::new(KeyMods::NONE, Key::Escape)) => ("Escape", cx.mods),
|
||||
ToolKey::Delete { forward, .. } if claims.deletes => (if *forward { "Delete" } else { "Backspace" }, cx.mods),
|
||||
ToolKey::Nudge { direction, mods, .. } if !mods.cmd && !mods.ctrl => {
|
||||
let name = if direction.x < 0.0 { "Left" } else if direction.x > 0.0 { "Right" } else if direction.y < 0.0 { "Up" } else { "Down" };
|
||||
let name = if direction.x < 0.0 {
|
||||
"Left"
|
||||
} else if direction.x > 0.0 {
|
||||
"Right"
|
||||
} else if direction.y < 0.0 {
|
||||
"Up"
|
||||
} else {
|
||||
"Down"
|
||||
};
|
||||
(name, *mods)
|
||||
}
|
||||
ToolKey::Kept(chord) if claims.keys.contains(chord) => {
|
||||
|
||||
@@ -659,13 +659,7 @@ fn set_pane_state(app: &mut SlideApp, ctx: &egui::Context, params: &Value) -> Re
|
||||
})
|
||||
.transpose()?;
|
||||
let rename = rename
|
||||
.map(|index| {
|
||||
index
|
||||
.map(|index| {
|
||||
sections.get(index).map(|_| index).ok_or_else(|| format!("no section {index}"))
|
||||
})
|
||||
.transpose()
|
||||
})
|
||||
.map(|index| index.map(|index| sections.get(index).map(|_| index).ok_or_else(|| format!("no section {index}"))).transpose())
|
||||
.transpose()?;
|
||||
if let Some(folds) = folds {
|
||||
app.sorter.collapsed = folds.into_iter().collect();
|
||||
@@ -766,11 +760,9 @@ fn backstage_edit(value: &Value) -> Result<BackstageEdit, String> {
|
||||
|
||||
fn set_state_hooks(app: &mut SlideApp, params: &Value) -> Result<(), String> {
|
||||
let mut pane_sizes = app.ui.clone();
|
||||
for (key, size) in [
|
||||
("paneWidth", &mut pane_sizes.pane_width),
|
||||
("thumbsWidth", &mut pane_sizes.thumbs_width),
|
||||
("notesHeight", &mut pane_sizes.notes_height),
|
||||
] {
|
||||
for (key, size) in
|
||||
[("paneWidth", &mut pane_sizes.pane_width), ("thumbsWidth", &mut pane_sizes.thumbs_width), ("notesHeight", &mut pane_sizes.notes_height)]
|
||||
{
|
||||
if let Some(value) = params.get(key) {
|
||||
*size = value
|
||||
.as_f64()
|
||||
@@ -994,7 +986,9 @@ mod tests {
|
||||
harness.state_mut().control = Some(ControlChannel::new(receiver));
|
||||
let addr = listening.addr;
|
||||
let notice = "A notice sent over the socket";
|
||||
let client = std::thread::spawn(move || ControlClient::connect(addr, &token).map_err(|e| format!("{e:?}"))?.call("ui.notify", json!({"text": notice})));
|
||||
let client = std::thread::spawn(move || {
|
||||
ControlClient::connect(addr, &token).map_err(|e| format!("{e:?}"))?.call("ui.notify", json!({"text": notice}))
|
||||
});
|
||||
let mut frames = 0;
|
||||
while !client.is_finished() && frames < 600 {
|
||||
harness.run_steps(1);
|
||||
|
||||
@@ -56,26 +56,26 @@ pub mod credits;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(super) mod updates_ui;
|
||||
|
||||
#[cfg(test)]
|
||||
mod columns_dialog_tests;
|
||||
#[cfg(test)]
|
||||
mod font_dialog_tests;
|
||||
#[cfg(test)]
|
||||
mod paragraph_dialog_tests;
|
||||
#[cfg(test)]
|
||||
mod photo_album_tests;
|
||||
#[cfg(test)]
|
||||
mod preferences_tests;
|
||||
#[cfg(test)]
|
||||
mod size_position_tests;
|
||||
#[cfg(test)]
|
||||
mod columns_dialog_tests;
|
||||
mod spelling_tests;
|
||||
#[cfg(test)]
|
||||
mod photo_album_tests;
|
||||
mod tests;
|
||||
#[cfg(test)]
|
||||
mod theme_colors_tests;
|
||||
#[cfg(test)]
|
||||
mod theme_fonts_tests;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
#[cfg(test)]
|
||||
mod spelling_tests;
|
||||
#[cfg(test)]
|
||||
mod paragraph_dialog_tests;
|
||||
#[cfg(test)]
|
||||
mod preferences_tests;
|
||||
|
||||
/// App-owned dialog state, independent of a UI context.
|
||||
#[derive(Default)]
|
||||
@@ -177,8 +177,8 @@ fn typed_id<D: StackDialog>(host: &DialogHost) -> Option<DialogId> {
|
||||
host.get::<D>().map(StackDialog::id)
|
||||
}
|
||||
|
||||
// PreferencesDialog and AccessibilityDialog publish their routing keys through StackDialog::key.
|
||||
// AutoCorrect belongs to Preferences; opening it must preserve the parent's transaction.
|
||||
// PreferencesDialog and AccessibilityDialog publish their routing keys through StackDialog::key.
|
||||
// AutoCorrect belongs to Preferences; opening it must preserve the parent's transaction.
|
||||
fn matching_dialog(host: &DialogHost, key: &str) -> Option<DialogId> {
|
||||
match key {
|
||||
"paragraph" => typed_id::<craft::text::ui::character::ParagraphDialog>(host),
|
||||
|
||||
@@ -19,13 +19,7 @@ const MAX_SIZE: f64 = 400.0;
|
||||
const MIN_START: i64 = 1;
|
||||
const MAX_START: i64 = 32767;
|
||||
|
||||
fn styles(
|
||||
key: &'static str,
|
||||
label: &'static str,
|
||||
cells: &'static [(&'static str, &'static str)],
|
||||
default: &'static str,
|
||||
wide: bool,
|
||||
) -> Param {
|
||||
fn styles(key: &'static str, label: &'static str, cells: &'static [(&'static str, &'static str)], default: &'static str, wide: bool) -> Param {
|
||||
let groups = vec![IconPickerGroup::new(
|
||||
"",
|
||||
cells
|
||||
|
||||
@@ -84,10 +84,7 @@ pub(crate) fn open(app: &crate::SlideApp, ctx: &egui::Context, _params: &Value)
|
||||
};
|
||||
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
|
||||
.iter()
|
||||
.map(|series| series.values.get(at).copied().flatten().map(|value| value.to_string()).unwrap_or_default());
|
||||
let values = chart.series.iter().map(|series| series.values.get(at).copied().flatten().map(|value| value.to_string()).unwrap_or_default());
|
||||
cells.push(std::iter::once(category.clone()).chain(values).collect());
|
||||
}
|
||||
let fields = DialogFields::from_pairs([("id", FieldValue::Int(i64::from(id.0))), ("grid", FieldValue::Json(json!(cells)))]);
|
||||
|
||||
@@ -125,22 +125,18 @@ impl SlideApp {
|
||||
return;
|
||||
}
|
||||
self.show = None;
|
||||
self.dialogs.closing = Some(Closing {
|
||||
guard: CloseGuard::new(scope, uids),
|
||||
scope,
|
||||
asked: false,
|
||||
pending_uid: None,
|
||||
completion: None,
|
||||
reason: None,
|
||||
});
|
||||
self.dialogs.closing =
|
||||
Some(Closing { guard: CloseGuard::new(scope, uids), scope, asked: false, pending_uid: None, completion: None, reason: None });
|
||||
}
|
||||
|
||||
/// Whether clean documents or a completed, uncancelled Quit guard allow the window to close.
|
||||
pub(crate) fn quit_allowed(&self) -> bool {
|
||||
!self.session.documents().iter().any(|doc| doc.is_dirty())
|
||||
|| self.dialogs.closing.as_ref().is_some_and(|closing| {
|
||||
closing.scope == CloseScope::Quit && closing.guard.is_finished() && !closing.guard.is_cancelled()
|
||||
})
|
||||
|| self
|
||||
.dialogs
|
||||
.closing
|
||||
.as_ref()
|
||||
.is_some_and(|closing| closing.scope == CloseScope::Quit && closing.guard.is_finished() && !closing.guard.is_cancelled())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ fn two_boxes() -> Harness<'static, SlideApp> {
|
||||
}
|
||||
|
||||
fn harness_of(s: Session) -> Harness<'static, SlideApp> {
|
||||
|
||||
let mut h: Harness<'static, SlideApp> = crate::test_harness::harness(s, Services::default());
|
||||
h.run_steps(4);
|
||||
h
|
||||
|
||||
@@ -39,13 +39,8 @@ pub(crate) fn pump(app: &mut SlideApp, _ctx: &Context, host: &mut DialogHost) {
|
||||
let _ = app.run("show.start", json!({"custom": choice.name}));
|
||||
}
|
||||
"create" => {
|
||||
let slides: Vec<usize> = choice
|
||||
.field
|
||||
.as_deref()
|
||||
.unwrap_or_default()
|
||||
.split(',')
|
||||
.filter_map(|s| s.trim().parse::<usize>().ok()?.checked_sub(1))
|
||||
.collect();
|
||||
let slides: Vec<usize> =
|
||||
choice.field.as_deref().unwrap_or_default().split(',').filter_map(|s| s.trim().parse::<usize>().ok()?.checked_sub(1)).collect();
|
||||
let _ = app.run("show.customShow", json!({"name": choice.name, "slides": slides}));
|
||||
}
|
||||
_ => {}
|
||||
|
||||
@@ -109,13 +109,15 @@ pub(crate) fn open(app: &mut SlideApp, _ctx: &Context, host: &mut DialogHost, _p
|
||||
.active()
|
||||
.map(|st| st.doc.slides.iter().enumerate().map(|(i, slide)| LinkPlace::new(format!("{}. {}", i + 1, slide.title()), 0)).collect())
|
||||
.unwrap_or_default();
|
||||
Ok(Some(host.open(
|
||||
HyperlinkDialog::new(current_link_of(app.session.active()), None)
|
||||
.key("hyperlink".to_owned())
|
||||
.place_groups(vec![LinkPlaceGroup::new("Slide Titles", places)])
|
||||
.parts(HyperlinkParts::Basic)
|
||||
.held_ok(),
|
||||
)))
|
||||
Ok(Some(
|
||||
host.open(
|
||||
HyperlinkDialog::new(current_link_of(app.session.active()), None)
|
||||
.key("hyperlink".to_owned())
|
||||
.place_groups(vec![LinkPlaceGroup::new("Slide Titles", places)])
|
||||
.parts(HyperlinkParts::Basic)
|
||||
.held_ok(),
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
/// Applies each held answer once and leaves refused commands open with their reason.
|
||||
|
||||
@@ -49,9 +49,13 @@ fn paragraph_button_aligns_text_in_one_undo() {
|
||||
h.run_steps(2);
|
||||
assert!(super::open_keys(&h.ctx).iter().any(|key| key == "paragraph"));
|
||||
let indent = 0.5 * 72.0;
|
||||
dialog(&mut h, "ui.dialog.set", json!({"dialog": "top", "fields": [
|
||||
{"field": "align", "value": "Right"}, {"field": "before_text", "value": indent}
|
||||
]}));
|
||||
dialog(
|
||||
&mut h,
|
||||
"ui.dialog.set",
|
||||
json!({"dialog": "top", "fields": [
|
||||
{"field": "align", "value": "Right"}, {"field": "before_text", "value": indent}
|
||||
]}),
|
||||
);
|
||||
dialog(&mut h, "ui.dialog.confirm", json!({"dialog": "top"}));
|
||||
assert!(super::open_keys(&h.ctx).is_empty(), "status {:?}", h.state().status);
|
||||
assert_eq!(align_of(&h).as_deref(), Some(deckcraft_model::text::Align::Right.xml()));
|
||||
@@ -81,11 +85,8 @@ fn tabs_from_paragraph_applies_a_stop_and_returns() {
|
||||
assert!(super::open_keys(&h.ctx).iter().any(|key| key == "tabs"), "status {:?}", h.state().status);
|
||||
assert_eq!(align_of(&h), before, "Tabs leaves the paragraph draft unapplied");
|
||||
let position = 2.0 * 72.0;
|
||||
let stop = craft::text::ui::ruler::TabStop::new(
|
||||
position as f32,
|
||||
craft::text::ui::ruler::TabAlign::Center,
|
||||
craft::text::ui::ruler::TabLeader::None,
|
||||
);
|
||||
let stop =
|
||||
craft::text::ui::ruler::TabStop::new(position as f32, craft::text::ui::ruler::TabAlign::Center, craft::text::ui::ruler::TabLeader::None);
|
||||
dialog(&mut h, "ui.dialog.set", json!({"dialog": "top", "field": "stops", "value": [stop]}));
|
||||
dialog(&mut h, "ui.dialog.confirm", json!({"dialog": "top"}));
|
||||
assert!(super::open_keys(&h.ctx).iter().any(|key| key == "paragraph"), "status {:?}", h.state().status);
|
||||
|
||||
@@ -51,10 +51,7 @@ fn album_json_id(v: &Value) -> Option<u64> {
|
||||
|
||||
fn items(fields: &DialogFields) -> Result<Vec<Value>, String> {
|
||||
let value = fields.get("items").ok_or_else(|| "The picture list is invalid".to_string())?;
|
||||
serde_json::to_value(value)
|
||||
.ok()
|
||||
.and_then(|value| value.as_array().cloned())
|
||||
.ok_or_else(|| "The picture list is invalid".to_string())
|
||||
serde_json::to_value(value).ok().and_then(|value| value.as_array().cloned()).ok_or_else(|| "The picture list is invalid".to_string())
|
||||
}
|
||||
|
||||
fn selected(fields: &DialogFields, list: &[Value]) -> Option<usize> {
|
||||
@@ -98,12 +95,7 @@ pub(crate) fn open(app: &SlideApp, ctx: &egui::Context, params: &Value) -> Hoste
|
||||
fields.set("items", FieldValue::Json(params.get("items").cloned().unwrap_or_else(|| json!([]))));
|
||||
fields.set("sel", 0_i64);
|
||||
fields.set("boxText", "Text Box");
|
||||
let theme = params
|
||||
.get("theme")
|
||||
.and_then(Value::as_str)
|
||||
.filter(|name| !name.is_empty())
|
||||
.map(str::to_string)
|
||||
.unwrap_or_else(|| current_theme(app));
|
||||
let theme = params.get("theme").and_then(Value::as_str).filter(|name| !name.is_empty()).map(str::to_string).unwrap_or_else(|| current_theme(app));
|
||||
fields.set("themeWas", theme.clone());
|
||||
fields.set("theme", theme);
|
||||
for (key, default) in [("layout", "1"), ("frame", "rect")] {
|
||||
@@ -117,127 +109,129 @@ pub(crate) fn open(app: &SlideApp, ctx: &egui::Context, params: &Value) -> Hoste
|
||||
let editing = params.get("items").is_some();
|
||||
HostedParamDialog::new(ctx, "photoAlbum", fields, move |fields| {
|
||||
let list = Param::custom("items", "Pictures in album", |ui, fields, context| {
|
||||
Stack::new().show(ui, |ui, _| {
|
||||
let Ok(mut list) = items(fields) else {
|
||||
Text::new("The picture list is invalid").show(ui);
|
||||
return;
|
||||
};
|
||||
let mut sel = selected(fields, &list);
|
||||
let sel_was = sel;
|
||||
let mut edited = false;
|
||||
let mut selection = sel.map(Selection::single).unwrap_or_default();
|
||||
Text::new("Pictures in album").show(ui);
|
||||
let output = List::new("Pictures in album")
|
||||
.select(SelectMode::Single)
|
||||
.selection(Bind::bound(&mut selection))
|
||||
.min_rows(5)
|
||||
.max_rows(5)
|
||||
.empty("No pictures yet")
|
||||
.show_items(ui, &AlbumRows(&list), &mut |key, cx| ListRow::new(album_item_label(&list[*key])).state(cx.row.clone()));
|
||||
for event in output.events {
|
||||
if let CollectionEvent::Selection { change, .. } = event {
|
||||
match change {
|
||||
SelectionChange::Set(keys) => sel = keys.last().copied(),
|
||||
SelectionChange::Toggle(key) => sel = (sel != Some(key)).then_some(key),
|
||||
SelectionChange::Clear => sel = None,
|
||||
_ => {}
|
||||
Stack::new()
|
||||
.show(ui, |ui, _| {
|
||||
let Ok(mut list) = items(fields) else {
|
||||
Text::new("The picture list is invalid").show(ui);
|
||||
return;
|
||||
};
|
||||
let mut sel = selected(fields, &list);
|
||||
let sel_was = sel;
|
||||
let mut edited = false;
|
||||
let mut selection = sel.map(Selection::single).unwrap_or_default();
|
||||
Text::new("Pictures in album").show(ui);
|
||||
let output = List::new("Pictures in album")
|
||||
.select(SelectMode::Single)
|
||||
.selection(Bind::bound(&mut selection))
|
||||
.min_rows(5)
|
||||
.max_rows(5)
|
||||
.empty("No pictures yet")
|
||||
.show_items(ui, &AlbumRows(&list), &mut |key, cx| ListRow::new(album_item_label(&list[*key])).state(cx.row.clone()));
|
||||
for event in output.events {
|
||||
if let CollectionEvent::Selection { change, .. } = event {
|
||||
match change {
|
||||
SelectionChange::Set(keys) => sel = keys.last().copied(),
|
||||
SelectionChange::Toggle(key) => sel = (sel != Some(key)).then_some(key),
|
||||
SelectionChange::Clear => sel = None,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut text = fields.text("boxText").unwrap_or("Text Box").to_string();
|
||||
Row::new().show(ui, |ui, _| {
|
||||
let can_pick = Host::of(ui).files().can_pick();
|
||||
let add = Button::new("Add Pictures…").enabled(can_pick).tooltip("Pass pictures to insert.photoAlbum").show(ui);
|
||||
if clicked(&add) {
|
||||
context.request_action("addPictures");
|
||||
let mut text = fields.text("boxText").unwrap_or("Text Box").to_string();
|
||||
Row::new().show(ui, |ui, _| {
|
||||
let can_pick = Host::of(ui).files().can_pick();
|
||||
let add = Button::new("Add Pictures…").enabled(can_pick).tooltip("Pass pictures to insert.photoAlbum").show(ui);
|
||||
if clicked(&add) {
|
||||
context.request_action("addPictures");
|
||||
}
|
||||
let draft = album_check_item_count(list.len().saturating_add(1)).and_then(|()| album_check_text(&text).map(str::to_string));
|
||||
let mut add = Button::new("New Text Box").enabled(draft.is_ok());
|
||||
if let Err(reason) = &draft {
|
||||
add = add.tooltip(reason.clone());
|
||||
}
|
||||
if clicked(&add.show(ui))
|
||||
&& let Ok(text) = draft
|
||||
{
|
||||
edited = true;
|
||||
list.push(json!({"text": text}));
|
||||
sel = Some(list.len() - 1);
|
||||
}
|
||||
if clicked(&Button::new("Remove").enabled(sel.is_some()).show(ui))
|
||||
&& let Some(at) = sel
|
||||
{
|
||||
edited = true;
|
||||
list.remove(at);
|
||||
sel = (!list.is_empty()).then(|| at.min(list.len() - 1));
|
||||
}
|
||||
});
|
||||
Row::new().show(ui, |ui, _| {
|
||||
Text::new(Env::of(ui).words::<AlbumWords>().text_box_caption.clone()).show(ui);
|
||||
let edit = TextField::new("Text box", Bind::bound(&mut text)).show(ui);
|
||||
if edit.value().is_some() {
|
||||
fields.set("boxText", text.clone());
|
||||
}
|
||||
});
|
||||
if sel != sel_was {
|
||||
fields.set("sel", sel.and_then(|i| i64::try_from(i).ok()).unwrap_or(-1));
|
||||
}
|
||||
let draft = album_check_item_count(list.len().saturating_add(1)).and_then(|()| album_check_text(&text).map(str::to_string));
|
||||
let mut add = Button::new("New Text Box").enabled(draft.is_ok());
|
||||
if let Err(reason) = &draft {
|
||||
add = add.tooltip(reason.clone());
|
||||
if edited {
|
||||
fields.set("items", FieldValue::Json(json!(list)));
|
||||
}
|
||||
if clicked(&add.show(ui))
|
||||
&& let Ok(text) = draft
|
||||
{
|
||||
edited = true;
|
||||
list.push(json!({"text": text}));
|
||||
sel = Some(list.len() - 1);
|
||||
}
|
||||
if clicked(&Button::new("Remove").enabled(sel.is_some()).show(ui))
|
||||
&& let Some(at) = sel
|
||||
{
|
||||
edited = true;
|
||||
list.remove(at);
|
||||
sel = (!list.is_empty()).then(|| at.min(list.len() - 1));
|
||||
}
|
||||
});
|
||||
Row::new().show(ui, |ui, _| {
|
||||
Text::new(Env::of(ui).words::<AlbumWords>().text_box_caption.clone()).show(ui);
|
||||
let edit = TextField::new("Text box", Bind::bound(&mut text)).show(ui);
|
||||
if edit.value().is_some() {
|
||||
fields.set("boxText", text.clone());
|
||||
}
|
||||
});
|
||||
if sel != sel_was {
|
||||
fields.set("sel", sel.and_then(|i| i64::try_from(i).ok()).unwrap_or(-1));
|
||||
}
|
||||
if edited {
|
||||
fields.set("items", FieldValue::Json(json!(list)));
|
||||
}
|
||||
})
|
||||
.output
|
||||
})
|
||||
.output
|
||||
})
|
||||
.companions(["sel", "boxText"])
|
||||
.full_width();
|
||||
let options = Param::custom("pictureOptions", "Picture options", |ui, fields, _| {
|
||||
Stack::new().show(ui, |ui, _| {
|
||||
let Ok(mut list) = items(fields) else { return };
|
||||
let sel = selected(fields, &list);
|
||||
let picture = sel.filter(|at| is_picture(&list[*at]));
|
||||
let mut edited = false;
|
||||
let words = Env::of(ui).words::<AlbumWords>();
|
||||
let status: Label = match sel.map(|at| &list[at]) {
|
||||
Some(item) if is_picture(item) => {
|
||||
let rot = item.get("rot").and_then(Value::as_f64).unwrap_or(0.0);
|
||||
let brightness = item.get("brightness").and_then(Value::as_f64).unwrap_or(0.0);
|
||||
let contrast = item.get("contrast").and_then(Value::as_f64).unwrap_or(0.0);
|
||||
Label::from(words.picture_status.fill(&[
|
||||
("rot", &format!("{rot:.0}")),
|
||||
("brightness", &format!("{brightness:.1}")),
|
||||
("contrast", &format!("{contrast:.1}")),
|
||||
]))
|
||||
}
|
||||
Some(_) => words.text_box_status.clone(),
|
||||
None => words.nothing_selected.clone(),
|
||||
};
|
||||
Text::new(status).show(ui);
|
||||
Row::new().wrap(true).show(ui, |ui, _| {
|
||||
for (label, key, delta) in [
|
||||
("Rotate Left", "rot", -90.0),
|
||||
("Rotate Right", "rot", 90.0),
|
||||
("More Brightness", "brightness", 0.1),
|
||||
("Less Brightness", "brightness", -0.1),
|
||||
("More Contrast", "contrast", 0.1),
|
||||
("Less Contrast", "contrast", -0.1),
|
||||
] {
|
||||
if clicked(&Button::new(label).enabled(picture.is_some()).show(ui))
|
||||
&& let Some(obj) = picture.and_then(|at| list[at].as_object_mut())
|
||||
{
|
||||
edited = true;
|
||||
if key == "rot" {
|
||||
let cur = obj.get(key).and_then(Value::as_f64).unwrap_or(0.0);
|
||||
obj.insert(key.into(), json!((cur + delta).rem_euclid(360.0)));
|
||||
} else {
|
||||
nudge_picture(obj, key, delta);
|
||||
Stack::new()
|
||||
.show(ui, |ui, _| {
|
||||
let Ok(mut list) = items(fields) else { return };
|
||||
let sel = selected(fields, &list);
|
||||
let picture = sel.filter(|at| is_picture(&list[*at]));
|
||||
let mut edited = false;
|
||||
let words = Env::of(ui).words::<AlbumWords>();
|
||||
let status: Label = match sel.map(|at| &list[at]) {
|
||||
Some(item) if is_picture(item) => {
|
||||
let rot = item.get("rot").and_then(Value::as_f64).unwrap_or(0.0);
|
||||
let brightness = item.get("brightness").and_then(Value::as_f64).unwrap_or(0.0);
|
||||
let contrast = item.get("contrast").and_then(Value::as_f64).unwrap_or(0.0);
|
||||
Label::from(words.picture_status.fill(&[
|
||||
("rot", &format!("{rot:.0}")),
|
||||
("brightness", &format!("{brightness:.1}")),
|
||||
("contrast", &format!("{contrast:.1}")),
|
||||
]))
|
||||
}
|
||||
Some(_) => words.text_box_status.clone(),
|
||||
None => words.nothing_selected.clone(),
|
||||
};
|
||||
Text::new(status).show(ui);
|
||||
Row::new().wrap(true).show(ui, |ui, _| {
|
||||
for (label, key, delta) in [
|
||||
("Rotate Left", "rot", -90.0),
|
||||
("Rotate Right", "rot", 90.0),
|
||||
("More Brightness", "brightness", 0.1),
|
||||
("Less Brightness", "brightness", -0.1),
|
||||
("More Contrast", "contrast", 0.1),
|
||||
("Less Contrast", "contrast", -0.1),
|
||||
] {
|
||||
if clicked(&Button::new(label).enabled(picture.is_some()).show(ui))
|
||||
&& let Some(obj) = picture.and_then(|at| list[at].as_object_mut())
|
||||
{
|
||||
edited = true;
|
||||
if key == "rot" {
|
||||
let cur = obj.get(key).and_then(Value::as_f64).unwrap_or(0.0);
|
||||
obj.insert(key.into(), json!((cur + delta).rem_euclid(360.0)));
|
||||
} else {
|
||||
nudge_picture(obj, key, delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if edited {
|
||||
fields.set("items", FieldValue::Json(json!(list)));
|
||||
}
|
||||
});
|
||||
if edited {
|
||||
fields.set("items", FieldValue::Json(json!(list)));
|
||||
}
|
||||
})
|
||||
.output
|
||||
})
|
||||
.output
|
||||
})
|
||||
.full_width();
|
||||
let rows = vec![
|
||||
@@ -295,11 +289,7 @@ fn append_picture(dialog: &mut HostedParamDialog, name: &str, bytes: &[u8], tota
|
||||
let mut list = items(dialog.fields())?;
|
||||
album_check_item_count(list.len().saturating_add(1))?;
|
||||
let next = album_check_total_bytes(*total, bytes.len())?;
|
||||
let name = std::path::Path::new(name)
|
||||
.file_name()
|
||||
.and_then(std::ffi::OsStr::to_str)
|
||||
.filter(|name| !name.is_empty())
|
||||
.unwrap_or("picture");
|
||||
let name = std::path::Path::new(name).file_name().and_then(std::ffi::OsStr::to_str).filter(|name| !name.is_empty()).unwrap_or("picture");
|
||||
list.push(json!({"name": name, "data": deckcraft_engine::cmd::base64_encode(bytes)}));
|
||||
dialog.set_field("sel", FieldValue::Int(i64::try_from(list.len() - 1).map_err(|error| error.to_string())?));
|
||||
dialog.set_field("items", FieldValue::Json(json!(list)));
|
||||
|
||||
@@ -80,12 +80,8 @@ fn create_inserts_the_album_in_one_step() {
|
||||
let pics: Vec<_> = st.doc.slides[before].shapes.iter().filter(|sh| matches!(sh.kind, ShapeKind::Picture { .. })).collect();
|
||||
assert_eq!(pics.len(), 1);
|
||||
assert_eq!(pics[0].line.as_ref().and_then(|l| l.width), Some(1.5));
|
||||
let texts: Vec<_> = st.doc.slides[before + 1]
|
||||
.shapes
|
||||
.iter()
|
||||
.filter(|sh| sh.text_box)
|
||||
.filter_map(|sh| sh.text.as_ref().map(|t| t.text()))
|
||||
.collect();
|
||||
let texts: Vec<_> =
|
||||
st.doc.slides[before + 1].shapes.iter().filter(|sh| sh.text_box).filter_map(|sh| sh.text.as_ref().map(|t| t.text())).collect();
|
||||
assert_eq!(texts, [text]);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,8 +117,18 @@ pub(crate) fn write(app: &mut SlideApp, draft: &PrefDraft) {
|
||||
};
|
||||
}
|
||||
assign!(
|
||||
units, smart_guides, snap_to_grid, smart_quotes, autocorrect, ac_two_initials, ac_sentence_caps, ac_days, ac_caps_lock,
|
||||
ac_fractions, ac_ordinals, ac_lists,
|
||||
units,
|
||||
smart_guides,
|
||||
snap_to_grid,
|
||||
smart_quotes,
|
||||
autocorrect,
|
||||
ac_two_initials,
|
||||
ac_sentence_caps,
|
||||
ac_days,
|
||||
ac_caps_lock,
|
||||
ac_fractions,
|
||||
ac_ordinals,
|
||||
ac_lists,
|
||||
);
|
||||
if prefs.author != draft.author {
|
||||
prefs.author.clone_from(&draft.author);
|
||||
@@ -444,5 +454,4 @@ pub(crate) fn pump(app: &mut SlideApp, _ctx: &Context, host: &mut DialogHost) {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -121,9 +121,11 @@ pub(crate) fn open(_app: &crate::SlideApp, ctx: &egui::Context, params: &Value)
|
||||
.columns(vec![ColumnSpec::toggle(CHECK, Label::Empty, ToggleColumn::sweepable())])
|
||||
.header(false)
|
||||
.show_items(ui, &source, &mut |key, icx| {
|
||||
ListRow::new(rows[icx.at].1.clone())
|
||||
.cells(icx.cells())
|
||||
.toggle(ToggleCell::check(CHECK, ToggleState::of(picked.contains(key)), "{row}"))
|
||||
ListRow::new(rows[icx.at].1.clone()).cells(icx.cells()).toggle(ToggleCell::check(
|
||||
CHECK,
|
||||
ToggleState::of(picked.contains(key)),
|
||||
"{row}",
|
||||
))
|
||||
});
|
||||
for event in out.events {
|
||||
let CollectionEvent::Toggle(edit) = event else { continue };
|
||||
|
||||
@@ -29,9 +29,7 @@ pub(crate) fn open(app: &SlideApp, ctx: &Context, params: &Value) -> HostedParam
|
||||
let w = number("w", selection.map_or(72.0, |x| x.w));
|
||||
let h = number("h", selection.map_or(72.0, |x| x.h));
|
||||
let rot = number("rot", selection.map_or(0.0, |x| x.rot));
|
||||
let mut fields = DialogFields::from_pairs([
|
||||
("x", x), ("y", y), ("w", w), ("h", h), ("rot", rot), ("scaleH", 100.0), ("scaleW", 100.0),
|
||||
]);
|
||||
let mut fields = DialogFields::from_pairs([("x", x), ("y", y), ("w", w), ("h", h), ("rot", rot), ("scaleH", 100.0), ("scaleW", 100.0)]);
|
||||
fields.set("lock", params["lockAspect"].as_bool().unwrap_or(false));
|
||||
let base = [h, w];
|
||||
for (key, value) in BASE_FIELDS.into_iter().zip(base) {
|
||||
@@ -91,10 +89,8 @@ fn set_size_field(fields: &mut DialogFields, key: &str, value: Value) -> Result<
|
||||
fields.set(key, value.as_bool().ok_or_else(|| "Lock aspect ratio must be true or false".to_owned())?);
|
||||
return Ok(());
|
||||
}
|
||||
let changed = DIMENSIONS
|
||||
.iter()
|
||||
.position(|(dimension, scale, _, _)| key == *dimension || key == *scale)
|
||||
.ok_or_else(|| "Unknown size field".to_owned())?;
|
||||
let changed =
|
||||
DIMENSIONS.iter().position(|(dimension, scale, _, _)| key == *dimension || key == *scale).ok_or_else(|| "Unknown size field".to_owned())?;
|
||||
let value = value.as_f64().filter(|value| value.is_finite()).ok_or_else(|| "Size and scale must be finite numbers".to_owned())?;
|
||||
let base = BASE_FIELDS.map(|key| fields.number(key).unwrap_or(0.0));
|
||||
let mut sizes = DIMENSIONS.map(|(key, _, _, _)| fields.number(key).unwrap_or(0.0));
|
||||
|
||||
@@ -63,7 +63,6 @@ pub(crate) fn open(app: &crate::SlideApp, ctx: &egui::Context, _params: &serde_j
|
||||
options.push(("custom".into(), Word::plain("Custom").into()));
|
||||
let rows = vec![
|
||||
Param::new("preset", Word::plain("Slides sized for:"), ParamKind::choice(options, Some("custom".into()))).on_change(apply_preset),
|
||||
|
||||
Param::number("w", Word::plain(width), size.width, 0.01, 2)
|
||||
.length(LengthUnits::new(UnitKind::Points, shown, 72.0))
|
||||
.bounds(Some(*SLIDE_SIZE_RANGE.start()), Some(*SLIDE_SIZE_RANGE.end()))
|
||||
|
||||
@@ -57,10 +57,8 @@ fn items(app: &mut SlideApp, ignored: &[String]) -> (Vec<SpellingItem>, Vec<Valu
|
||||
.enumerate()
|
||||
.map(|(at, location)| {
|
||||
// Keep the engine order: object remains the location index even after Ignore skips it.
|
||||
let suggestions = location["suggestions"]
|
||||
.as_array()
|
||||
.map(|a| a.iter().filter_map(Value::as_str).map(str::to_owned).collect())
|
||||
.unwrap_or_default();
|
||||
let suggestions =
|
||||
location["suggestions"].as_array().map(|a| a.iter().filter_map(Value::as_str).map(str::to_owned).collect()).unwrap_or_default();
|
||||
let item = SpellingItem::new(
|
||||
at as u64,
|
||||
index(location, "start")..index(location, "end"),
|
||||
@@ -169,17 +167,17 @@ fn reveal(app: &mut SlideApp, item: Option<&SpellingItem>) {
|
||||
|
||||
fn dictionary_line(info: &Value, words: &Words) -> Label {
|
||||
if info["available"].as_bool().unwrap_or(false) {
|
||||
let dictionary = info["found"]
|
||||
.as_str()
|
||||
.map(|f| f.rsplit(['/', '\\']).next().unwrap_or(f))
|
||||
.unwrap_or_else(|| info["lang"].as_str().unwrap_or_default());
|
||||
let dictionary =
|
||||
info["found"].as_str().map(|f| f.rsplit(['/', '\\']).next().unwrap_or(f)).unwrap_or_else(|| info["lang"].as_str().unwrap_or_default());
|
||||
WordTemplate::new(words.get(Word::plain("Dictionary: {dictionary}"))).fill(&[("dictionary", dictionary)]).into()
|
||||
} else {
|
||||
let fallback = words.get(Word::plain("a dictionaries folder"));
|
||||
let folder = info["folders"].as_array().and_then(|a| a.get(1).or(a.first())).and_then(Value::as_str).unwrap_or(&fallback);
|
||||
WordTemplate::new(words.get(Word::plain(
|
||||
"No {lang} dictionary is installed, so only common misspellings are found. Put a Hunspell .aff/.dic pair in {folder}.",
|
||||
)))
|
||||
WordTemplate::new(
|
||||
words.get(Word::plain(
|
||||
"No {lang} dictionary is installed, so only common misspellings are found. Put a Hunspell .aff/.dic pair in {folder}.",
|
||||
)),
|
||||
)
|
||||
.fill(&[("lang", info["lang"].as_str().unwrap_or("en-US")), ("folder", folder)])
|
||||
.into()
|
||||
}
|
||||
|
||||
@@ -18,9 +18,8 @@ fn spelling_dialog_changes_and_ignores_words() {
|
||||
let mut session = Session::with_new();
|
||||
session.execute("slide.layout", &json!({"layout": "blank"})).unwrap();
|
||||
let original = "our plan\n— Our plna for teh quarter";
|
||||
let id = session.execute("shape.insert", &json!({"preset": "rect", "rect": [100, 100, 500, 120], "text": original})).unwrap()["id"]
|
||||
.as_u64()
|
||||
.unwrap();
|
||||
let id =
|
||||
session.execute("shape.insert", &json!({"preset": "rect", "rect": [100, 100, 500, 120], "text": original})).unwrap()["id"].as_u64().unwrap();
|
||||
let mut h = harness_with(session, Services::default(), Harness::builder().with_size(egui::vec2(1100.0, 700.0)), |_| {});
|
||||
h.state_mut().open_dialog("spelling", json!({}));
|
||||
h.run_steps(3);
|
||||
@@ -28,9 +27,7 @@ fn spelling_dialog_changes_and_ignores_words() {
|
||||
let count = |h: &Harness<'_, SlideApp>| super::inspect(&h.ctx)[0]["fields"]["count"].as_u64().unwrap();
|
||||
let before = count(&h);
|
||||
let ctx = h.ctx.clone();
|
||||
super::control(h.state_mut(), &ctx, "ui.dialog.set", &json!({"dialog": "top", "field": "changeTo", "value": "plan"}))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
super::control(h.state_mut(), &ctx, "ui.dialog.set", &json!({"dialog": "top", "field": "changeTo", "value": "plan"})).unwrap().unwrap();
|
||||
// A Change must apply once in a two-pass frame.
|
||||
h.ctx.on_end_pass(
|
||||
"spelling input pass",
|
||||
@@ -76,11 +73,8 @@ fn squiggles_mark_misspelt_words_in_the_background() {
|
||||
session.execute("slide.layout", &json!({"layout": "blank"})).ok();
|
||||
let original = "Our plna for teh quarter reveiw";
|
||||
let correction = "plan";
|
||||
let id = session
|
||||
.execute("shape.insert", &json!({"preset": "rect", "rect": [80, 120, 700, 160], "text": original}))
|
||||
.unwrap()["id"]
|
||||
.as_u64()
|
||||
.unwrap();
|
||||
let id =
|
||||
session.execute("shape.insert", &json!({"preset": "rect", "rect": [80, 120, 700, 160], "text": original})).unwrap()["id"].as_u64().unwrap();
|
||||
session.execute("format.size", &json!({"size": 40})).unwrap();
|
||||
// Mark the runs' language directly (what a PPTX run's `lang` gives).
|
||||
let sid = deckcraft_model::ShapeId(id as u32);
|
||||
@@ -223,11 +217,10 @@ fn notes_menu_language_dialog_and_repeated_words() {
|
||||
deckcraft_engine::spell::install("xx-NM", deckcraft_engine::spell::Dictionary::parse(aff.as_bytes(), dic.as_bytes()));
|
||||
let mut session = Session::with_new();
|
||||
session.execute("slide.layout", &json!({"layout": "blank"})).ok();
|
||||
let id = session
|
||||
.execute("shape.insert", &json!({"preset": "rect", "rect": [80, 120, 700, 160], "text": "the plan is is good wrok"}))
|
||||
.unwrap()["id"]
|
||||
.as_u64()
|
||||
.unwrap();
|
||||
let id =
|
||||
session.execute("shape.insert", &json!({"preset": "rect", "rect": [80, 120, 700, 160], "text": "the plan is is good wrok"})).unwrap()["id"]
|
||||
.as_u64()
|
||||
.unwrap();
|
||||
session.execute("format.size", &json!({"size": 40})).unwrap();
|
||||
session.execute("format.language", &json!({"lang": "xx-NM"})).unwrap();
|
||||
let note_source = "Remmeber the the plan";
|
||||
|
||||
@@ -28,13 +28,7 @@ fn dialog_method(h: &mut Harness<'_, SlideApp>, method: &str, params: Value) ->
|
||||
}
|
||||
|
||||
fn dialog_fields(h: &Harness<'_, SlideApp>, key: &str) -> Value {
|
||||
crate::control::inspect(h.state(), &h.ctx)["dialogs"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.find(|d| d["key"] == key)
|
||||
.unwrap()["fields"]
|
||||
.clone()
|
||||
crate::control::inspect(h.state(), &h.ctx)["dialogs"].as_array().unwrap().iter().find(|d| d["key"] == key).unwrap()["fields"].clone()
|
||||
}
|
||||
|
||||
fn export_harness(session: deckcraft_engine::Session, files: Arc<ScriptedFiles>) -> Harness<'static, SlideApp> {
|
||||
@@ -69,12 +63,7 @@ fn header_footer_apply_keeps_an_existing_date_format() {
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
let mut harness = crate::test_harness::harness_with(
|
||||
session,
|
||||
Services::default(),
|
||||
Harness::builder().with_size(vec2(1200.0, 900.0)),
|
||||
|_| {},
|
||||
);
|
||||
let mut harness = crate::test_harness::harness_with(session, Services::default(), Harness::builder().with_size(vec2(1200.0, 900.0)), |_| {});
|
||||
harness.run_steps(2);
|
||||
assert_eq!(date_fields(harness.state()), vec!["datetime4".to_string()]);
|
||||
harness.state_mut().run("app.dialog", json!({"id": "headerFooter"})).unwrap();
|
||||
@@ -157,10 +146,7 @@ fn a_text_span_reports_the_link_it_covers() {
|
||||
let slides = [SlideId(1)];
|
||||
|
||||
assert_eq!(link_covering(&body, (0, 6), (0, 6), &slides), CurrentLink::None, "a caret inserts; it does not edit the run beside it");
|
||||
assert_eq!(
|
||||
link_covering(&body, (0, 6), (0, 11), &slides),
|
||||
CurrentLink::One(UiHyperlink::new(LinkTarget::Url(address.into())).tooltip(tip)),
|
||||
);
|
||||
assert_eq!(link_covering(&body, (0, 6), (0, 11), &slides), CurrentLink::One(UiHyperlink::new(LinkTarget::Url(address.into())).tooltip(tip)),);
|
||||
assert_eq!(link_covering(&body, (0, 0), (0, 11), &slides), CurrentLink::Mixed);
|
||||
|
||||
let unlinked = Shape::default();
|
||||
|
||||
@@ -28,12 +28,7 @@ fn open_dialog(h: &mut Harness<'_, SlideApp>) {
|
||||
#[test]
|
||||
fn save_applies_the_name_and_one_colour() {
|
||||
// PLAN: plan error: writer note 9 removes the local harness helper retained by the Files table.
|
||||
let mut h = harness_with(
|
||||
Session::with_new(),
|
||||
Services::default(),
|
||||
Harness::builder().with_size(egui::vec2(1800.0, 1100.0)),
|
||||
|_| {},
|
||||
);
|
||||
let mut h = harness_with(Session::with_new(), Services::default(), Harness::builder().with_size(egui::vec2(1800.0, 1100.0)), |_| {});
|
||||
h.state_mut().ui.tab = "Design".into();
|
||||
h.run_steps(3);
|
||||
let before = scheme(&h);
|
||||
|
||||
@@ -58,7 +58,6 @@ pub(crate) fn open(_app: &SlideApp, ctx: &egui::Context, params: &Value) -> Host
|
||||
.ok_label("Save".into())
|
||||
.footer_note("Heading and body fonts for this presentation.")
|
||||
.below(|ui, fields| {
|
||||
|
||||
Text::new(format!("Heading sample {}", fields.text("major").unwrap_or_default())).role(TypeRole::Heading).show(ui);
|
||||
Text::new(format!("Body sample {}", fields.text("minor").unwrap_or_default())).role(TypeRole::Body).show(ui);
|
||||
})
|
||||
|
||||
@@ -83,7 +83,6 @@ pub(crate) fn run(app: &mut SlideApp, ctx: &egui::Context, host: &mut DialogHost
|
||||
let action = app.updates_rt.updater.run(host, clean);
|
||||
apply_action(app, ctx, action);
|
||||
|
||||
|
||||
if let Some(DialogResult::Ok(choice)) = host.take::<UpdateCheckDialog>() {
|
||||
match choice {
|
||||
CheckChoice::Close => app.updates_rt.updater.dismiss_status(),
|
||||
|
||||
@@ -43,7 +43,11 @@ pub(crate) fn open(app: &SlideApp, ctx: &Context, _: &Value) -> HostedParamDialo
|
||||
Param::number("percent", "Percent:", 100.0, 1.0, 0).bounds(Some(10.0), Some(400.0)).unit(UnitKind::Percent).on_change(percent_changed),
|
||||
];
|
||||
HostedParamDialog::new(ctx, "zoom", fields, move |fields| {
|
||||
ParamDialog::new("zoom", "Zoom", rows.clone()).values(Bind::bound(fields)).layout(ParamLayout::Document).caption_column(true).ok_label("OK".into())
|
||||
ParamDialog::new("zoom", "Zoom", rows.clone())
|
||||
.values(Bind::bound(fields))
|
||||
.layout(ParamLayout::Document)
|
||||
.caption_column(true)
|
||||
.ok_label("OK".into())
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -92,46 +92,44 @@ pub fn show(app: &mut SlideApp, ui: &mut egui::Ui) {
|
||||
w.slide = slide;
|
||||
}
|
||||
let grayscale = app.ui.grayscale;
|
||||
let shown = ViewportWindow::new(title.clone())
|
||||
.remember(SaveKey::new("deckcraft_ui_egui.doc_window"))
|
||||
.show(ui, |ui, _| {
|
||||
if let Some(w) = app.doc_window.as_mut() {
|
||||
w.viewport = Some(ui.ctx().viewport_id());
|
||||
}
|
||||
let mut delta = None;
|
||||
Stack::new()
|
||||
.fill()
|
||||
.surface(SurfaceKind::Canvas)
|
||||
.header(|ui, _| {
|
||||
Bar::new("Document navigation", BarKind::Tool)
|
||||
.trailing(|ui, _| {
|
||||
if Button::new("Previous").enabled(slide > 0).show(ui).clicked() {
|
||||
delta = Some(-1);
|
||||
}
|
||||
if Button::new("Next").enabled(slide + 1 < n).show(ui).clicked() {
|
||||
delta = Some(1);
|
||||
}
|
||||
})
|
||||
.show(ui, |ui, _| {
|
||||
Text::new(title.clone()).role(TypeRole::BodyStrong).show(ui);
|
||||
Text::new(format!("Slide {} of {n}", slide + 1)).shade(Shade::Muted).show(ui);
|
||||
});
|
||||
})
|
||||
.show(ui, |ui, _| {
|
||||
Stack::new().fill().pad(Pad::Regular).show(ui, |ui, _| {
|
||||
let (w, h) = pixel_size(&doc, ui.available_width() * ui.ctx().pixels_per_point());
|
||||
let key = (uid, revision, slide, w, h, grayscale);
|
||||
Picture::new("Slide preview", uid, &|| slide_image(&doc, key))
|
||||
.revision(Revision::of(&key))
|
||||
.aspect(ThumbAspect::from_ratio((doc.slide_size.width / doc.slide_size.height) as f32))
|
||||
.extent(PictureSize::Fit)
|
||||
.show(ui);
|
||||
let shown = ViewportWindow::new(title.clone()).remember(SaveKey::new("deckcraft_ui_egui.doc_window")).show(ui, |ui, _| {
|
||||
if let Some(w) = app.doc_window.as_mut() {
|
||||
w.viewport = Some(ui.ctx().viewport_id());
|
||||
}
|
||||
let mut delta = None;
|
||||
Stack::new()
|
||||
.fill()
|
||||
.surface(SurfaceKind::Canvas)
|
||||
.header(|ui, _| {
|
||||
Bar::new("Document navigation", BarKind::Tool)
|
||||
.trailing(|ui, _| {
|
||||
if Button::new("Previous").enabled(slide > 0).show(ui).clicked() {
|
||||
delta = Some(-1);
|
||||
}
|
||||
if Button::new("Next").enabled(slide + 1 < n).show(ui).clicked() {
|
||||
delta = Some(1);
|
||||
}
|
||||
})
|
||||
.show(ui, |ui, _| {
|
||||
Text::new(title.clone()).role(TypeRole::BodyStrong).show(ui);
|
||||
Text::new(format!("Slide {} of {n}", slide + 1)).shade(Shade::Muted).show(ui);
|
||||
});
|
||||
})
|
||||
.show(ui, |ui, _| {
|
||||
Stack::new().fill().pad(Pad::Regular).show(ui, |ui, _| {
|
||||
let (w, h) = pixel_size(&doc, ui.available_width() * ui.ctx().pixels_per_point());
|
||||
let key = (uid, revision, slide, w, h, grayscale);
|
||||
Picture::new("Slide preview", uid, &|| slide_image(&doc, key))
|
||||
.revision(Revision::of(&key))
|
||||
.aspect(ThumbAspect::from_ratio((doc.slide_size.width / doc.slide_size.height) as f32))
|
||||
.extent(PictureSize::Fit)
|
||||
.show(ui);
|
||||
});
|
||||
if let Some(delta) = delta {
|
||||
let _ = app.run("view.newWindow", json!({"delta": delta}));
|
||||
}
|
||||
});
|
||||
});
|
||||
if let Some(delta) = delta {
|
||||
let _ = app.run("view.newWindow", json!({"delta": delta}));
|
||||
}
|
||||
});
|
||||
if shown.close_requested.is_some() {
|
||||
app.doc_window = None;
|
||||
}
|
||||
|
||||
@@ -66,8 +66,7 @@ pub fn tool(app: &mut SlideApp) -> Option<DropperTool<'static>> {
|
||||
pub fn after_pass(app: &mut SlideApp, ctx: &Context, mut tool: DropperTool<'static>, canvas_rect: Rect) {
|
||||
let Some(mut armed) = app.eyedropper.take() else { return };
|
||||
// A press outside the canvas disarms, as production did.
|
||||
let outside =
|
||||
!armed.fresh && ctx.input(|i| i.pointer.primary_pressed() && i.pointer.hover_pos().is_some_and(|pos| !canvas_rect.contains(pos)));
|
||||
let outside = !armed.fresh && ctx.input(|i| i.pointer.primary_pressed() && i.pointer.hover_pos().is_some_and(|pos| !canvas_rect.contains(pos)));
|
||||
armed.fresh = false;
|
||||
if outside {
|
||||
ctx.request_repaint();
|
||||
|
||||
@@ -31,10 +31,7 @@ pub(crate) fn window(ui: &mut Ui, filter: &str) -> bool {
|
||||
Row::new().show(ui, |ui, _| {
|
||||
DisplayIcon::new(icon.id().into()).size(ControlSize::Md).show(ui);
|
||||
DisplayIcon::new(icon.id().into()).size(ControlSize::Sm).show(ui);
|
||||
DisplayIcon::new(icon.id().into())
|
||||
.size(ControlSize::Sm)
|
||||
.enabled(false)
|
||||
.show(ui);
|
||||
DisplayIcon::new(icon.id().into()).size(ControlSize::Sm).enabled(false).show(ui);
|
||||
});
|
||||
Text::new(icon.name()).role(TypeRole::Caption).shade(Shade::Muted).show(ui);
|
||||
});
|
||||
|
||||
@@ -362,10 +362,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn names_round_trip_and_are_unique() {
|
||||
assert!(
|
||||
geometry::text_face().is_some(),
|
||||
"icon coverage requires the framework's parseable Inter Regular face"
|
||||
);
|
||||
assert!(geometry::text_face().is_some(), "icon coverage requires the framework's parseable Inter Regular face");
|
||||
register();
|
||||
register();
|
||||
let mut seen = HashSet::new();
|
||||
|
||||
@@ -273,11 +273,8 @@ impl Pen {
|
||||
}
|
||||
let rgb = format!("#{:02X}{:02X}{:02X}", color.r(), color.g(), color.b());
|
||||
if let Some(w) = stroke {
|
||||
let _ = write!(
|
||||
out,
|
||||
"<{tag} {geometry} fill=\"none\" stroke=\"{rgb}\" stroke-opacity=\"{opacity}\" stroke-width=\"{}\"/>",
|
||||
BASE_STROKE * w
|
||||
);
|
||||
let _ =
|
||||
write!(out, "<{tag} {geometry} fill=\"none\" stroke=\"{rgb}\" stroke-opacity=\"{opacity}\" stroke-width=\"{}\"/>", BASE_STROKE * w);
|
||||
} else {
|
||||
let _ = write!(out, "<{tag} {geometry} fill=\"{rgb}\" fill-opacity=\"{opacity}\" stroke=\"none\"/>");
|
||||
}
|
||||
@@ -532,12 +529,7 @@ impl Pen {
|
||||
for id in glyphs {
|
||||
let mut outline = GlyphOutline { path: String::new(), origin: (x, baseline), scale, current: (0.0, 0.0) };
|
||||
if face.outline_glyph(id, &mut outline).is_some() && !outline.path.is_empty() {
|
||||
self.element(
|
||||
"path",
|
||||
&format!("d=\"{}\" transform=\"rotate({angle_deg} {} {})\"", outline.path, at.0, at.1),
|
||||
c,
|
||||
None,
|
||||
);
|
||||
self.element("path", &format!("d=\"{}\" transform=\"rotate({angle_deg} {} {})\"", outline.path, at.0, at.1), c, None);
|
||||
}
|
||||
x += f32::from(face.glyph_hor_advance(id).unwrap_or(0)) * scale;
|
||||
}
|
||||
|
||||
+12
-12
@@ -54,9 +54,9 @@ use deckcraft_model::{LayoutId, MasterId, SlideId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
pub use app::{AppError, key_name};
|
||||
#[cfg(test)]
|
||||
use app::web_image_files;
|
||||
pub use app::{AppError, key_name};
|
||||
use canvas::preview;
|
||||
pub use canvas::squiggles;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
@@ -245,16 +245,23 @@ mod browsetheme_tests;
|
||||
#[cfg(test)]
|
||||
mod compare_tests;
|
||||
#[cfg(test)]
|
||||
#[path = "datetime_tests.rs"]
|
||||
mod datetime_tests;
|
||||
#[cfg(test)]
|
||||
mod eyedropper_tests;
|
||||
#[cfg(test)]
|
||||
mod field_frame_tests;
|
||||
#[cfg(test)]
|
||||
mod gpu_lock;
|
||||
#[cfg(test)]
|
||||
mod host_save_tests;
|
||||
#[cfg(test)]
|
||||
mod huge_deck_tests;
|
||||
#[cfg(test)]
|
||||
mod ime_tests;
|
||||
#[cfg(test)]
|
||||
mod inbox_tests;
|
||||
#[cfg(test)]
|
||||
mod last_color_tests;
|
||||
#[cfg(test)]
|
||||
mod presenter_tests;
|
||||
@@ -269,6 +276,10 @@ mod slide_size_tests;
|
||||
#[cfg(test)]
|
||||
mod split_button_tests;
|
||||
#[cfg(test)]
|
||||
pub(crate) mod test_harness;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
#[cfg(test)]
|
||||
mod texture_limit_tests;
|
||||
#[cfg(test)]
|
||||
mod thumb_source_tests;
|
||||
@@ -276,14 +287,3 @@ mod thumb_source_tests;
|
||||
mod ui_soak_tests;
|
||||
#[cfg(test)]
|
||||
mod units_tests;
|
||||
#[cfg(test)]
|
||||
#[path = "datetime_tests.rs"]
|
||||
mod datetime_tests;
|
||||
#[cfg(test)]
|
||||
mod inbox_tests;
|
||||
#[cfg(test)]
|
||||
mod host_save_tests;
|
||||
#[cfg(test)]
|
||||
pub(crate) mod test_harness;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -46,12 +46,8 @@ fn play_on_the_editor_media_bar_plays_the_selected_clip() {
|
||||
s.execute("slide.new", &json!({"layout": "blank"})).unwrap();
|
||||
let r = s.execute("insert.audio", &json!({"name": "tone.wav", "data": deckcraft_engine::cmd::base64_encode(&wav(2.0))})).unwrap();
|
||||
let id = ShapeId(r["id"].as_u64().unwrap() as u32);
|
||||
let mut h = test_harness::harness_with(
|
||||
s,
|
||||
Services::default(),
|
||||
Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0),
|
||||
|_| {},
|
||||
);
|
||||
let mut h =
|
||||
test_harness::harness_with(s, Services::default(), Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0), |_| {});
|
||||
h.run_steps(3);
|
||||
let d = h.state().session.active().unwrap();
|
||||
assert_eq!(d.selection.shapes, vec![id], "the inserted clip is selected");
|
||||
@@ -106,12 +102,8 @@ fn the_media_bar_never_paints_or_clicks_into_the_notes_pane() {
|
||||
// Dragged across the bottom edge of the slide, onto the pasteboard.
|
||||
let h_slide = s.doc().unwrap().doc.slide_size.height;
|
||||
s.execute("shape.setBounds", &json!({"ids": [id.0], "x": 300.0, "y": h_slide - 10.0, "w": 120.0, "h": 60.0})).unwrap();
|
||||
let mut h = test_harness::harness_with(
|
||||
s,
|
||||
Services::default(),
|
||||
Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0),
|
||||
|_| {},
|
||||
);
|
||||
let mut h =
|
||||
test_harness::harness_with(s, Services::default(), Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0), |_| {});
|
||||
h.state_mut().ui.notes = true;
|
||||
h.state_mut().ui.notes_height = 140.0;
|
||||
h.run_steps(3);
|
||||
|
||||
@@ -207,8 +207,6 @@ pub mod notes;
|
||||
pub mod selpane;
|
||||
pub mod thumbs;
|
||||
|
||||
#[cfg(test)]
|
||||
mod smartart_tests;
|
||||
#[cfg(test)]
|
||||
mod background_tests;
|
||||
#[cfg(test)]
|
||||
@@ -216,6 +214,8 @@ mod effect_presets_tests;
|
||||
#[cfg(test)]
|
||||
mod pattern_fill_tests;
|
||||
#[cfg(test)]
|
||||
mod smartart_tests;
|
||||
#[cfg(test)]
|
||||
mod thesaurus_tests;
|
||||
// PLAN: plan error: panels-w8 must supply panels/format_shape_tests.rs with the moved tests.
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -130,9 +130,7 @@ pub(super) fn background(app: &mut SlideApp, ui: &mut Ui) {
|
||||
}
|
||||
|
||||
fn transparency(ui: &mut Ui, alpha: f64) -> Option<Value> {
|
||||
let result = SliderField::new(Word::plain("Transparency"), Bind::given((1.0 - alpha) * 100.0), 0.0..=100.0)
|
||||
.unit_kind(UnitKind::Percent)
|
||||
.show(ui);
|
||||
let result = SliderField::new(Word::plain("Transparency"), Bind::given((1.0 - alpha) * 100.0), 0.0..=100.0).unit_kind(UnitKind::Percent).show(ui);
|
||||
result.events.committed().map(|value| json!({"transparency": value / 100.0}))
|
||||
}
|
||||
|
||||
@@ -185,9 +183,8 @@ fn picture_background_options(ui: &mut Ui, picture: &PictureFill) -> Vec<Value>
|
||||
] {
|
||||
let entries: Vec<_> = choices.iter().map(|(value, label)| Entry::new(*value, Word::plain(label))).collect();
|
||||
let current = choices.iter().find(|(value, _)| *value == current).unwrap_or(&choices[0]).0;
|
||||
let mut field = Field::new(Word::plain(label)).show(ui, |ui, _| {
|
||||
Select::new(Word::plain(label), Bind::given(current), &entries).show(ui).events.committed().copied()
|
||||
});
|
||||
let mut field = Field::new(Word::plain(label))
|
||||
.show(ui, |ui, _| Select::new(Word::plain(label), Bind::given(current), &entries).show(ui).events.committed().copied());
|
||||
if let Some(value) = field.settle(|_, value| value.take()).flatten() {
|
||||
commands.push(json!({"pictureProps": {key: value}}));
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@ use crate::{Services, SlideApp};
|
||||
const PNG: &str = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==";
|
||||
|
||||
fn harness(session: Session) -> Harness<'static, SlideApp> {
|
||||
let mut h =
|
||||
crate::test_harness::harness_with(session, Services::default(), Harness::builder().with_size(egui::vec2(1800.0, 1100.0)), |_| {});
|
||||
let mut h = crate::test_harness::harness_with(session, Services::default(), Harness::builder().with_size(egui::vec2(1800.0, 1100.0)), |_| {});
|
||||
h.state_mut().ui.tab = "Design".into();
|
||||
h.state_mut().ui.pane = Some("background".into());
|
||||
h.run_steps(3);
|
||||
|
||||
@@ -73,11 +73,8 @@ pub(crate) fn color_row_named(
|
||||
) {
|
||||
let Some(uid) = app.session.active().map(|st| st.uid) else { return };
|
||||
let key = format!("fmt-color:{uid}:{key}");
|
||||
let name = if plain {
|
||||
Label::from(Word::plain("Color"))
|
||||
} else {
|
||||
Label::from(Env::of(ui).words::<ColorRowWords>().named.fill(&[("label", label)]))
|
||||
};
|
||||
let name =
|
||||
if plain { Label::from(Word::plain("Color")) } else { Label::from(Env::of(ui).words::<ColorRowWords>().named.fill(&[("label", label)])) };
|
||||
let mut field = Field::new(label.to_owned()).layout(FieldLayout::Beside).id_salt(&key).show(ui, |ui, _| {
|
||||
Button::new(name.clone()).painted(Word::plain("Color")).keeps_name(true).trailing_icon(DisclosureGlyph::dropdown()).show(ui)
|
||||
});
|
||||
|
||||
@@ -18,11 +18,8 @@ pub(super) fn comments(app: &mut SlideApp, ui: &mut Ui) {
|
||||
}
|
||||
Divider::horizontal().show(ui);
|
||||
let threads = app.session.active().map(|st| threads(&st.doc)).unwrap_or_default();
|
||||
let now = web_time::SystemTime::now()
|
||||
.duration_since(web_time::UNIX_EPOCH)
|
||||
.ok()
|
||||
.and_then(|elapsed| i64::try_from(elapsed.as_secs()).ok())
|
||||
.unwrap_or(0);
|
||||
let now =
|
||||
web_time::SystemTime::now().duration_since(web_time::UNIX_EPOCH).ok().and_then(|elapsed| i64::try_from(elapsed.as_secs()).ok()).unwrap_or(0);
|
||||
let out = CommentsPanel::new(Word::plain("Comments"), &threads, &mut app.comments_pane)
|
||||
.header(CommentsHeader::Hosted)
|
||||
.form(CommentsForm::Replies)
|
||||
|
||||
@@ -195,4 +195,3 @@ fn paint_soft(p: &Painter, tile: Rect, radius: f64) {
|
||||
p.rect_stroke(r.shrink(i as f32), CornerRadius::same(2), Stroke::new(1.0, c), StrokeKind::Inside);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ fn click(h: &mut Harness<'_, SlideApp>, label: &str) {
|
||||
h.run_steps(3);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn the_current_preset_tile_is_marked_selected() {
|
||||
let mut h = harness();
|
||||
|
||||
@@ -207,9 +207,8 @@ pub(crate) fn gradient_editor(app: &mut crate::SlideApp, ui: &mut Ui, label: &st
|
||||
GradientShape::Path { .. } => "Radial",
|
||||
};
|
||||
let types: Vec<_> = ["Linear", "Radial", "Rectangular", "Path"].into_iter().map(|k| Entry::new(k, Word::plain(k))).collect();
|
||||
let mut type_field = Field::new(Word::plain("Type")).show(ui, |ui, _| {
|
||||
Select::new(Word::plain("Type"), Bind::given(kind), &types).show(ui).events.committed().copied()
|
||||
});
|
||||
let mut type_field = Field::new(Word::plain("Type"))
|
||||
.show(ui, |ui, _| Select::new(Word::plain("Type"), Bind::given(kind), &types).show(ui).events.committed().copied());
|
||||
if let Some(k) = type_field.settle(|_, value| value.take()).flatten().filter(|k| *k != kind) {
|
||||
let focus = match &g.shape {
|
||||
GradientShape::Path { focus, .. } => *focus,
|
||||
@@ -232,11 +231,7 @@ pub(crate) fn gradient_editor(app: &mut crate::SlideApp, ui: &mut Ui, label: &st
|
||||
.collect();
|
||||
let selected = DIRECTIONS_LINEAR.iter().position(|(_, a)| (angle - a).abs() < 0.5);
|
||||
let mut direction = Field::new(Word::plain("Direction")).show(ui, |ui, _| {
|
||||
Segmented::new(Word::plain("Direction"), Bind::given(selected.unwrap_or(usize::MAX)), &entries)
|
||||
.show(ui)
|
||||
.events
|
||||
.committed()
|
||||
.copied()
|
||||
Segmented::new(Word::plain("Direction"), Bind::given(selected.unwrap_or(usize::MAX)), &entries).show(ui).events.committed().copied()
|
||||
});
|
||||
if let Some(i) = direction.settle(|_, value| value.take()).flatten() {
|
||||
out = Some(Gradient { shape: GradientShape::Linear { angle: DIRECTIONS_LINEAR[i].1, scaled: *scaled }, ..g.clone() });
|
||||
@@ -264,11 +259,7 @@ pub(crate) fn gradient_editor(app: &mut crate::SlideApp, ui: &mut Ui, label: &st
|
||||
.collect();
|
||||
let selected = DIRECTIONS_PATH.iter().position(|(_, f)| focus.iter().zip(f).all(|(a, b)| (a - b).abs() < 1e-3));
|
||||
let mut direction = Field::new(Word::plain("Direction")).show(ui, |ui, _| {
|
||||
Segmented::new(Word::plain("Direction"), Bind::given(selected.unwrap_or(usize::MAX)), &entries)
|
||||
.show(ui)
|
||||
.events
|
||||
.committed()
|
||||
.copied()
|
||||
Segmented::new(Word::plain("Direction"), Bind::given(selected.unwrap_or(usize::MAX)), &entries).show(ui).events.committed().copied()
|
||||
});
|
||||
if let Some(i) = direction.settle(|_, value| value.take()).flatten() {
|
||||
out = Some(Gradient { shape: GradientShape::Path { path: path.clone(), focus: DIRECTIONS_PATH[i].1 }, ..g.clone() });
|
||||
@@ -519,8 +510,7 @@ fn stop_menu(app: &mut crate::SlideApp, ui: &mut Ui, label: &str, g: &Gradient,
|
||||
}
|
||||
// The UI scope names the fill property; document, subject and value prevent delayed samples crossing targets.
|
||||
let prefix = format!("fill.gradient.{:?}.{label}:", ui.scope_id());
|
||||
let subject =
|
||||
app.session.active().map(|doc| (doc.uid, doc.current_slide().map(|s| s.id), doc.selection.target, doc.selection.shapes.clone()));
|
||||
let subject = app.session.active().map(|doc| (doc.uid, doc.current_slide().map(|s| s.id), doc.selection.target, doc.selection.shapes.clone()));
|
||||
let identity = format!("{prefix}{subject:?}:{g:?}:");
|
||||
let keys: Vec<_> = (0..g.stops.len()).map(|i| format!("{identity}{i}")).collect();
|
||||
// Answers are consumed in their receiving pass. A second pass has no drained answer to replay.
|
||||
|
||||
@@ -100,30 +100,24 @@ fn selection_takes_background_fill(app: &SlideApp) -> bool {
|
||||
|
||||
fn slider(ui: &mut Ui, label: &'static str, value: f64, range: std::ops::RangeInclusive<f64>, unit: UnitKind) -> Option<f64> {
|
||||
let mut field = Field::new(Word::plain(label)).layout(FieldLayout::Beside).id_salt(label).show(ui, |ui, _| {
|
||||
SliderField::new(Word::plain(label), Bind::given(value), range.clone())
|
||||
.layout(SliderFieldLayout::Inline)
|
||||
.unit_kind(unit)
|
||||
.show(ui)
|
||||
SliderField::new(Word::plain(label), Bind::given(value), range.clone()).layout(SliderFieldLayout::Inline).unit_kind(unit).show(ui)
|
||||
});
|
||||
field.settle(|_, output| output.events.committed().copied()).flatten().filter(|shown| *shown != value)
|
||||
}
|
||||
|
||||
fn number(ui: &mut Ui, label: &'static str, value: f64, step: f64, unit: UnitKind) -> Option<f64> {
|
||||
let mut field = Field::new(Word::plain(label)).layout(FieldLayout::Beside).id_salt(label).show(ui, |ui, _| {
|
||||
NumberField::new(Word::plain(label), Bind::given(Some(value)))
|
||||
.step(step)
|
||||
.unit_kind(unit)
|
||||
.step_arrows(StepArrows::Trailing)
|
||||
.show(ui)
|
||||
NumberField::new(Word::plain(label), Bind::given(Some(value))).step(step).unit_kind(unit).step_arrows(StepArrows::Trailing).show(ui)
|
||||
});
|
||||
field.settle(|_, output| output.events.committed().copied().flatten()).flatten().filter(|shown| *shown != value)
|
||||
}
|
||||
|
||||
fn select(ui: &mut Ui, label: &'static str, current: &str, items: &[(&'static str, &str)]) -> Option<String> {
|
||||
let entries: Vec<_> = items.iter().map(|(name, value)| Entry::new((*value).to_owned(), Word::plain(name))).collect();
|
||||
let mut field = Field::new(Word::plain(label)).layout(FieldLayout::Beside).id_salt(label).show(ui, |ui, _| {
|
||||
Select::new(Word::plain(label), Bind::given(current.to_owned()), &entries).show(ui)
|
||||
});
|
||||
let mut field = Field::new(Word::plain(label))
|
||||
.layout(FieldLayout::Beside)
|
||||
.id_salt(label)
|
||||
.show(ui, |ui, _| Select::new(Word::plain(label), Bind::given(current.to_owned()), &entries).show(ui));
|
||||
field.settle(|_, output| output.events.committed().cloned()).flatten().filter(|picked| picked != current)
|
||||
}
|
||||
|
||||
@@ -211,11 +205,9 @@ fn fill_options(app: &mut SlideApp, ui: &mut Ui, sh: &Shape) {
|
||||
match picked.as_str() {
|
||||
"none" => run(app, "shape.fill", json!({"none": true})),
|
||||
"solid" => run(app, "shape.fill", json!({"color": "accent1"})),
|
||||
"gradient" => run(
|
||||
app,
|
||||
"shape.fill",
|
||||
json!({"gradient": {"stops": [[0, "accent1"], [1, {"scheme": "accent1", "lumMod": 50000}]], "angle": 90}}),
|
||||
),
|
||||
"gradient" => {
|
||||
run(app, "shape.fill", json!({"gradient": {"stops": [[0, "accent1"], [1, {"scheme": "accent1", "lumMod": 50000}]], "angle": 90}}))
|
||||
}
|
||||
"pattern" => run(app, "shape.fill", json!({"pattern": {"preset": "pct25", "fg": "accent1", "bg": "bg1"}})),
|
||||
"picture" => pick_fill_picture(app),
|
||||
"background" => run(app, "shape.fill", json!({"background": true})),
|
||||
@@ -263,7 +255,13 @@ fn fill_options(app: &mut SlideApp, ui: &mut Ui, sh: &Shape) {
|
||||
|
||||
fn line_options(app: &mut SlideApp, ui: &mut Ui, sh: &Shape) {
|
||||
let none = matches!(sh.line.as_ref().and_then(|line| line.fill.as_ref()), Some(Fill::None));
|
||||
let kind = if none { "none" } else if sh.line.is_some() { "solid" } else { "auto" };
|
||||
let kind = if none {
|
||||
"none"
|
||||
} else if sh.line.is_some() {
|
||||
"solid"
|
||||
} else {
|
||||
"auto"
|
||||
};
|
||||
if let Some(picked) = radios(ui, "Line type", kind, &[("No line", "none"), ("Solid line", "solid"), ("Automatic", "auto")]) {
|
||||
let params = match picked.as_str() {
|
||||
"none" => json!({"none": true}),
|
||||
@@ -331,10 +329,9 @@ fn line_details(app: &mut SlideApp, ui: &mut Ui, sh: &Shape) {
|
||||
line_choice(app, ui, "Join type", "join", join, &[("Round", "round"), ("Bevel", "bevel"), ("Miter", "miter")]);
|
||||
let arrows = [("None", "none"), ("Arrow", "triangle"), ("Open Arrow", "arrow"), ("Stealth", "stealth"), ("Diamond", "diamond"), ("Oval", "oval")];
|
||||
let sizes = [("Small", "sm"), ("Medium", "med"), ("Large", "lg")];
|
||||
for (label, key, size_label, size_key, end) in [
|
||||
("Begin arrow", "head", "Begin size", "headSize", &line.head),
|
||||
("End arrow", "tail", "End size", "tailSize", &line.tail),
|
||||
] {
|
||||
for (label, key, size_label, size_key, end) in
|
||||
[("Begin arrow", "head", "Begin size", "headSize", &line.head), ("End arrow", "tail", "End size", "tailSize", &line.tail)]
|
||||
{
|
||||
line_choice(app, ui, label, key, end.as_ref().map_or("none", |end| end.kind.as_str()), &arrows);
|
||||
if let Some(end) = end {
|
||||
line_choice(app, ui, size_label, size_key, &end.w, &sizes);
|
||||
@@ -349,9 +346,8 @@ fn pick_fill_picture(app: &mut SlideApp) {
|
||||
|
||||
fn picture_fill_options(app: &mut SlideApp, ui: &mut Ui, picture: &deckcraft_model::style::PictureFill) {
|
||||
use deckcraft_model::style::PictureMode;
|
||||
let mut source = Field::new(Word::plain("Picture source"))
|
||||
.layout(FieldLayout::Beside)
|
||||
.show(ui, |ui, _| Button::new(Word::plain("Insert…")).show(ui));
|
||||
let mut source =
|
||||
Field::new(Word::plain("Picture source")).layout(FieldLayout::Beside).show(ui, |ui, _| Button::new(Word::plain("Insert…")).show(ui));
|
||||
if source.settle(|_, output| output.clicked()).unwrap_or(false) {
|
||||
pick_fill_picture(app);
|
||||
}
|
||||
|
||||
@@ -125,18 +125,17 @@ fn preset_label(name: &str) -> String {
|
||||
|
||||
fn three_d_combo(app: &mut SlideApp, ui: &mut Ui, label: &'static str, key: &str, current: &str, options: &[&str]) {
|
||||
let entries: Vec<_> = options.iter().map(|&option| Entry::new(option.to_owned(), preset_label(option))).collect();
|
||||
let mut output = Field::new(Word::plain(label)).show(ui, |ui, _| {
|
||||
Select::new(Word::plain(label), Bind::given(current.to_owned()), &entries).show(ui)
|
||||
});
|
||||
let mut output =
|
||||
Field::new(Word::plain(label)).show(ui, |ui, _| Select::new(Word::plain(label), Bind::given(current.to_owned()), &entries).show(ui));
|
||||
if let Some(value) = output.settle(|_, out| out.events.committed().cloned()).flatten() {
|
||||
run(app, "shape.effects", json!({"threeD": {key: value}}));
|
||||
}
|
||||
}
|
||||
|
||||
fn three_d_number(app: &mut SlideApp, ui: &mut Ui, label: &'static str, value: f64, unit: UnitKind, key: &str) {
|
||||
let mut output = Field::new(Word::plain(label)).id_salt(key).show(ui, |ui, _| {
|
||||
NumberField::new(Word::plain(label), Bind::given(Some(value))).unit_kind(unit).show(ui)
|
||||
});
|
||||
let mut output = Field::new(Word::plain(label))
|
||||
.id_salt(key)
|
||||
.show(ui, |ui, _| NumberField::new(Word::plain(label), Bind::given(Some(value))).unit_kind(unit).show(ui));
|
||||
if let Some(value) = output.settle(|_, out| out.events.committed().copied().flatten()).flatten() {
|
||||
run(app, "shape.effects", json!({"threeD": {key: value}}));
|
||||
}
|
||||
|
||||
@@ -65,9 +65,9 @@ pub(super) fn tab(app: &mut SlideApp, ui: &mut Ui, sh: &deckcraft_model::Shape,
|
||||
});
|
||||
Section::fixed(Word::plain("Position")).id_salt((uid, sh.id.0, "position")).show(ui, |ui, _| {
|
||||
let entries = [Entry::new(false, Word::plain("Top Left Corner")), Entry::new(true, Word::plain("Center"))];
|
||||
let mut origin = Field::new(Word::plain("From")).enabled(single).show(ui, |ui, _| {
|
||||
Select::new(Word::plain("From"), Bind::given(single && app.format_pane.centre_origin), &entries).show(ui)
|
||||
});
|
||||
let mut origin = Field::new(Word::plain("From"))
|
||||
.enabled(single)
|
||||
.show(ui, |ui, _| Select::new(Word::plain("From"), Bind::given(single && app.format_pane.centre_origin), &entries).show(ui));
|
||||
if let Some(value) = origin.settle(|_, out| out.events.committed().copied()).flatten() {
|
||||
app.format_pane.centre_origin = value;
|
||||
}
|
||||
|
||||
@@ -14,12 +14,7 @@ use crate::{Services, SlideApp};
|
||||
type TestResult<T = ()> = Result<T, Box<dyn std::error::Error>>;
|
||||
|
||||
fn pane(session: Session) -> Harness<'static, SlideApp> {
|
||||
let mut h = crate::test_harness::harness_with(
|
||||
session,
|
||||
Services::default(),
|
||||
Harness::builder().with_size(egui::vec2(1800.0, 1500.0)),
|
||||
|_| {},
|
||||
);
|
||||
let mut h = crate::test_harness::harness_with(session, Services::default(), Harness::builder().with_size(egui::vec2(1800.0, 1500.0)), |_| {});
|
||||
h.state_mut().ui.pane = Some("format".into());
|
||||
h.state_mut().ui.format_tab = "fill".into();
|
||||
h.run_steps(3);
|
||||
@@ -140,14 +135,7 @@ fn fill_color_and_transparency_show_only_where_they_change_the_fill() -> TestRes
|
||||
// so its slider and absent pattern controls are checked against the other fill kinds.
|
||||
("solid", Some(json!({"color": "accent2", "transparency": 0.4})), true, true, false, false),
|
||||
("none", Some(json!({"none": true})), false, false, false, false),
|
||||
(
|
||||
"gradient",
|
||||
Some(json!({"gradient": {"stops": [[0, "accent1"], [1, "accent2"]], "angle": 90}})),
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
),
|
||||
("gradient", Some(json!({"gradient": {"stops": [[0, "accent1"], [1, "accent2"]], "angle": 90}})), false, false, true, false),
|
||||
("picture", Some(json!({"picture": picture_data(), "transparency": 0.4})), false, true, false, false),
|
||||
("pattern", Some(json!({"pattern": {"preset": "pct25", "fg": "accent1", "bg": "bg1"}})), false, false, false, true),
|
||||
] {
|
||||
@@ -256,10 +244,8 @@ fn slide_background_fill_is_a_fill_option() -> TestResult {
|
||||
}
|
||||
let h = fill_pane(Some(json!({"background": true})))?;
|
||||
assert_eq!(h.get_by_role_and_label(Role::RadioButton, "Slide background fill").accesskit_node().toggled(), Some(Toggled::True));
|
||||
let chosen_automatic = h
|
||||
.query_all_by_role_and_label(Role::RadioButton, "Automatic")
|
||||
.filter(|node| node.accesskit_node().toggled() == Some(Toggled::True))
|
||||
.count();
|
||||
let chosen_automatic =
|
||||
h.query_all_by_role_and_label(Role::RadioButton, "Automatic").filter(|node| node.accesskit_node().toggled() == Some(Toggled::True)).count();
|
||||
let line_only = fill_pane(Some(json!({"none": true})))?;
|
||||
let line_automatic = line_only
|
||||
.query_all_by_role_and_label(Role::RadioButton, "Automatic")
|
||||
@@ -269,4 +255,3 @@ fn slide_background_fill_is_a_fill_option() -> TestResult {
|
||||
assert_eq!(color_rows(&h), color_rows(&line_only));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -103,8 +103,7 @@ pub(crate) fn pane_body(app: &mut SlideApp, ui: &mut Ui, cx: &mut BodyCx<'_>) {
|
||||
// PLAN: plan error: BodyCx exposes no enclosing container Inner::settle hook for pane mutations and request drains
|
||||
// All candidates keep their original indices; the editor hides the live caret's flag in paint.
|
||||
// PLAN: assumed Squiggles::notes(&str, &str, Option<usize>) -> Vec<(usize, usize)> (canvas-w12)
|
||||
let flags: Vec<_> =
|
||||
app.squiggles.notes(&plain, &lang, None).into_iter().map(|(a, b)| NotesFlag::new(a..b, Tone::Bad)).collect();
|
||||
let flags: Vec<_> = app.squiggles.notes(&plain, &lang, None).into_iter().map(|(a, b)| NotesFlag::new(a..b, Tone::Bad)).collect();
|
||||
let out = NotesEditor::new(words.notes.clone(), &mut notes)
|
||||
.form(NotesEditorForm::Pane)
|
||||
.flags(&flags)
|
||||
|
||||
@@ -13,8 +13,7 @@ use serde_json::json;
|
||||
use crate::{Services, SlideApp};
|
||||
|
||||
fn harness(session: Session, pane: &str) -> Harness<'static, SlideApp> {
|
||||
let mut h =
|
||||
crate::test_harness::harness_with(session, Services::default(), Harness::builder().with_size(egui::vec2(1800.0, 1100.0)), |_| {});
|
||||
let mut h = crate::test_harness::harness_with(session, Services::default(), Harness::builder().with_size(egui::vec2(1800.0, 1100.0)), |_| {});
|
||||
h.state_mut().ui.pane = Some(pane.into());
|
||||
h.run_steps(3);
|
||||
h
|
||||
|
||||
@@ -143,10 +143,9 @@ fn toolbar(ui: &mut Ui, has_selection: bool, commands: &mut Vec<Command>) {
|
||||
let mut trailing = Vec::new();
|
||||
Bar::new("Selection actions", BarKind::Tool)
|
||||
.trailing(|ui, _| {
|
||||
for (icon, label, command) in [
|
||||
(Icon::ChevronDown, "Send Backward", "arrange.sendBackward"),
|
||||
(Icon::ChevronUp, "Bring Forward", "arrange.bringForward"),
|
||||
] {
|
||||
for (icon, label, command) in
|
||||
[(Icon::ChevronDown, "Send Backward", "arrange.sendBackward"), (Icon::ChevronUp, "Bring Forward", "arrange.bringForward")]
|
||||
{
|
||||
if IconButton::new(icon.id()).label(label).enabled(has_selection).show(ui).clicked() {
|
||||
trailing.push((command, json!({})));
|
||||
}
|
||||
@@ -192,7 +191,6 @@ pub fn show(app: &mut SlideApp, ui: &mut Ui) {
|
||||
.reorder(ReorderRule::new().siblings_only())
|
||||
.drag_selection(DragSelection::SelectUnselected)
|
||||
.drag_scope(DragScope::Grabbed)
|
||||
|
||||
.show_items(ui, &source, &mut |_, icx| {
|
||||
let row = &rows[icx.at];
|
||||
let mut line = ListRow::new(row.name.clone())
|
||||
@@ -269,11 +267,8 @@ fn click(state: &mut State, rows: &[Row], change: &SelectionChange<u32>, shift:
|
||||
match change {
|
||||
SelectionChange::Set(ids) if shift => {
|
||||
if let Some(end) = ids.last().and_then(|id| rows.iter().find(|row| row.id == *id)) {
|
||||
let ids: Vec<u32> = ids
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|id| rows.iter().any(|row| row.id == *id && row.parent.is_none() == end.parent.is_none()))
|
||||
.collect();
|
||||
let ids: Vec<u32> =
|
||||
ids.iter().copied().filter(|id| rows.iter().any(|row| row.id == *id && row.parent.is_none() == end.parent.is_none())).collect();
|
||||
commands.push(("selection.select", json!({"ids": ids, "add": cmd})));
|
||||
}
|
||||
}
|
||||
@@ -305,7 +300,6 @@ fn context_menu(ui: &mut Ui, response: &egui::Response, uid: u64, row: &Row, com
|
||||
];
|
||||
if let Some(command) = Menu::context("Selection object", response).pick(ui, &entries).picked {
|
||||
match command {
|
||||
|
||||
"rename" => craft::ui::contract::request_rename(ui.ctx(), list_id(uid), &row.id),
|
||||
"shape.visible" => commands.push((command, json!({"id": row.id, "visible": row.hidden}))),
|
||||
"shape.lock" => commands.push((command, json!({"id": row.id}))),
|
||||
|
||||
@@ -103,12 +103,7 @@ fn home_convert_to_smartart_gallery_converts_the_text() {
|
||||
let mut s = Session::with_new();
|
||||
s.execute("slide.new", &json!({"layout": "blank"})).unwrap();
|
||||
s.execute("insert.textBox", &json!({"text": "Goals\nRevenue\nGrowth"})).unwrap();
|
||||
let mut h = harness_with(
|
||||
s,
|
||||
Services::default(),
|
||||
Harness::builder().with_size(egui::vec2(1600.0, 900.0)).with_step_dt(1.0 / 60.0),
|
||||
|_| {},
|
||||
);
|
||||
let mut h = harness_with(s, Services::default(), Harness::builder().with_size(egui::vec2(1600.0, 900.0)).with_step_dt(1.0 / 60.0), |_| {});
|
||||
h.run_steps(3);
|
||||
h.get_by_label("Convert to Diagram").click();
|
||||
h.run_steps(3);
|
||||
@@ -127,12 +122,7 @@ fn layout_gallery_shows_cached_pictures_and_previews_on_hover() {
|
||||
let mut s = Session::with_new();
|
||||
s.execute("slide.new", &json!({"layout": "blank"})).unwrap();
|
||||
s.execute("insert.smartArt", &json!({"kind": "process", "items": ["Plan", "Build", "Ship"]})).unwrap();
|
||||
let mut h = harness_with(
|
||||
s,
|
||||
Services::default(),
|
||||
Harness::builder().with_size(egui::vec2(1600.0, 900.0)).with_step_dt(1.0 / 60.0),
|
||||
|_| {},
|
||||
);
|
||||
let mut h = harness_with(s, Services::default(), Harness::builder().with_size(egui::vec2(1600.0, 900.0)).with_step_dt(1.0 / 60.0), |_| {});
|
||||
h.state_mut().ui.tab = "SmartArt Design".into();
|
||||
h.run_steps(3);
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Button, "Layouts").click();
|
||||
|
||||
@@ -112,12 +112,8 @@ pub(crate) fn body(app: &mut SlideApp, ui: &mut Ui, cx: &mut BodyCx<'_>) {
|
||||
match event {
|
||||
CollectionEvent::Selection { change, .. } => {
|
||||
selection.apply(change);
|
||||
let mut ids: Vec<_> = doc
|
||||
.slides
|
||||
.iter()
|
||||
.map(|slide| u64::from(slide.id.0))
|
||||
.filter(|id| selection.contains(id) && Some(*id) != selection.lead)
|
||||
.collect();
|
||||
let mut ids: Vec<_> =
|
||||
doc.slides.iter().map(|slide| u64::from(slide.id.0)).filter(|id| selection.contains(id) && Some(*id) != selection.lead).collect();
|
||||
ids.extend(selection.lead.filter(|id| selection.contains(id)));
|
||||
let _ = app.run("slide.selectSlides", json!({"ids": ids, "add": false}));
|
||||
}
|
||||
@@ -187,12 +183,8 @@ pub(crate) fn slide_menu(ui: &mut Ui, app: &mut SlideApp, key: u64, opener: &Res
|
||||
};
|
||||
let slide = &state.doc.slides[at];
|
||||
let hidden = slide.hidden;
|
||||
let layouts: Vec<_> = state
|
||||
.doc
|
||||
.masters
|
||||
.first()
|
||||
.map(|master| master.layouts.iter().map(|layout| (layout.name.clone(), layout.id.0)).collect())
|
||||
.unwrap_or_default();
|
||||
let layouts: Vec<_> =
|
||||
state.doc.masters.first().map(|master| master.layouts.iter().map(|layout| (layout.name.clone(), layout.id.0)).collect()).unwrap_or_default();
|
||||
let words = Env::of(ui).view().words::<ThumbWords>();
|
||||
let requested = app.pane_menu.as_ref().is_some_and(|(kind, held)| kind == "slides" && *held == key);
|
||||
let mut menu = Menu::context(words.slide_menu.clone(), opener);
|
||||
@@ -201,9 +193,10 @@ pub(crate) fn slide_menu(ui: &mut Ui, app: &mut SlideApp, key: u64, opener: &Res
|
||||
}
|
||||
let out = menu.show(ui, |ui, _| {
|
||||
if !craft::ui::runtime::measure::active(ui.ctx())
|
||||
&& app.session.active().is_some_and(|state| {
|
||||
state.selection.slide != at && !state.selection.slides.iter().any(|id| u64::from(id.0) == key)
|
||||
})
|
||||
&& app
|
||||
.session
|
||||
.active()
|
||||
.is_some_and(|state| state.selection.slide != at && !state.selection.slides.iter().any(|id| u64::from(id.0) == key))
|
||||
{
|
||||
let _ = app.run("slide.go", json!({"id": key}));
|
||||
}
|
||||
|
||||
@@ -520,4 +520,3 @@ mod tests {
|
||||
assert!(SnapshotDelta::from_payload("not JSON").is_none());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,10 +104,8 @@ pub fn presenter_body(ui: &mut egui::Ui, _cx: &mut BodyCx<'_>, model: &Presenter
|
||||
let clock = cx.env.dates().format(DateTime::from_system(std::time::SystemTime::now(), TimeZone::Local), DateStyle::TIME);
|
||||
Text::new(clock).shade(Shade::Muted).show(ui);
|
||||
let template = cx.env.resolve(&Word::plain("Slide {n} of {N}").into());
|
||||
let position = WordTemplate::new(template.as_str()).fill(&[
|
||||
("n", &model.slide.saturating_add(1).to_string()),
|
||||
("N", &model.total.to_string()),
|
||||
]);
|
||||
let position = WordTemplate::new(template.as_str())
|
||||
.fill(&[("n", &model.slide.saturating_add(1).to_string()), ("N", &model.total.to_string())]);
|
||||
Text::new(position).shade(Shade::Muted).show(ui);
|
||||
});
|
||||
Row::new().gap(Gap::Item).show(ui, |ui, _| {
|
||||
@@ -232,10 +230,7 @@ fn pictures_and_notes(ui: &mut egui::Ui, model: &PresenterModel<'_>, aspect: f32
|
||||
});
|
||||
let mut notes = crate::notes::to_notes(model.notes);
|
||||
Stack::new().fill().scroll(Scroll::vertical()).show(ui, |ui, _| {
|
||||
craft::text::ui::notes::NotesEditor::new(Word::plain("Notes"), &mut notes)
|
||||
.read_only(true)
|
||||
.zoom(model.notes_px / 12.0)
|
||||
.show(ui);
|
||||
craft::text::ui::notes::NotesEditor::new(Word::plain("Notes"), &mut notes).read_only(true).zoom(model.notes_px / 12.0).show(ui);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -106,11 +106,7 @@ fn inserts_into_the_presentation_the_picker_was_opened_for() {
|
||||
assert!(crate::dialogs::open_keys(&h.ctx).is_empty());
|
||||
let s = &h.state().session;
|
||||
let doc = |uid: u64| s.documents().iter().find(|d| d.uid == uid).unwrap();
|
||||
assert_eq!(
|
||||
doc(first).doc.slides.iter().map(|slide| slide.title()).collect::<Vec<_>>(),
|
||||
expected,
|
||||
"inserted where the picker was opened"
|
||||
);
|
||||
assert_eq!(doc(first).doc.slides.iter().map(|slide| slide.title()).collect::<Vec<_>>(), expected, "inserted where the picker was opened");
|
||||
assert_eq!(titles(&h), second_before, "the other presentation is untouched");
|
||||
assert_eq!(s.active().unwrap().uid, second, "the view stays on the presentation the user moved to");
|
||||
}
|
||||
|
||||
@@ -24,12 +24,7 @@ fn harness(select: &[usize]) -> (Harness<'static, SlideApp>, Vec<ShapeId>) {
|
||||
.collect();
|
||||
let picked: Vec<u32> = select.iter().map(|&i| ids[i].0).collect();
|
||||
s.execute("selection.select", &json!({"ids": picked})).unwrap();
|
||||
let mut h = crate::test_harness::harness_with(
|
||||
s,
|
||||
Services::default(),
|
||||
Harness::builder().with_size(egui::vec2(1800.0, 900.0)),
|
||||
|_| {},
|
||||
);
|
||||
let mut h = crate::test_harness::harness_with(s, Services::default(), Harness::builder().with_size(egui::vec2(1800.0, 900.0)), |_| {});
|
||||
h.state_mut().ui.tab = "Shape Format".into();
|
||||
h.run_steps(3);
|
||||
(h, ids)
|
||||
|
||||
@@ -163,7 +163,15 @@ pub(crate) fn animations(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
});
|
||||
});
|
||||
let armed = app.session.anim_painter.is_some();
|
||||
super::home::painter_toggle(app, ui, Icon::AnimationPainter, "Animation\nPainter", "animation.painter", armed, "Animation Painter (double-click to keep it on)");
|
||||
super::home::painter_toggle(
|
||||
app,
|
||||
ui,
|
||||
Icon::AnimationPainter,
|
||||
"Animation\nPainter",
|
||||
"animation.painter",
|
||||
armed,
|
||||
"Animation Painter (double-click to keep it on)",
|
||||
);
|
||||
});
|
||||
});
|
||||
row.group(RibbonGroup::new("timing", "Timing", Icon::Duration.id().into()), |ui| {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use super::{Icon, SlideApp, Ui, json};
|
||||
use deckcraft_model::ShapeId;
|
||||
use craft::menu::ribbon::{RibbonGroup, RibbonRow};
|
||||
use craft::ui::buttons::{Arrangement, Button, SplitButton, SplitMenu, SplitMenuEnablement};
|
||||
use craft::ui::contract::{Bind, BodyCx, Entry, PopupKind, Props as _, Show as _, ShowContainer as _, Trigger};
|
||||
@@ -11,12 +10,10 @@ use craft::ui::primitives::IconSpec;
|
||||
use craft::ui::runtime::commands::{self, CommandRef};
|
||||
use craft::ui::runtime::env::{LengthUnits, UnitKind};
|
||||
use craft::ui::text::NumberField;
|
||||
use deckcraft_model::ShapeId;
|
||||
|
||||
const GROUP: [(&str, &str, Icon); 3] = [
|
||||
("Group", "arrange.group", Icon::Group),
|
||||
("Ungroup", "arrange.ungroup", Icon::Ungroup),
|
||||
("Regroup", "arrange.regroup", Icon::Group),
|
||||
];
|
||||
const GROUP: [(&str, &str, Icon); 3] =
|
||||
[("Group", "arrange.group", Icon::Group), ("Ungroup", "arrange.ungroup", Icon::Ungroup), ("Regroup", "arrange.regroup", Icon::Group)];
|
||||
const ROTATE: [(&str, &str, Icon); 4] = [
|
||||
("Rotate Right 90°", "arrange.rotateRight", Icon::RotateRight),
|
||||
("Rotate Left 90°", "arrange.rotateLeft", Icon::RotateLeft),
|
||||
@@ -76,10 +73,8 @@ pub fn align_menu(app: &mut SlideApp, ui: &mut Ui, cx: &mut BodyCx<'_>) {
|
||||
MenuItem::command(CommandRef::with_params("arrange.align", json!({"edge": e, "to": to}))).label(l).icon(ic.id()).show(ui);
|
||||
}
|
||||
Divider::horizontal().show(ui);
|
||||
for (label, dir, icon) in [
|
||||
("Distribute Horizontally", "horizontal", Icon::DistributeH),
|
||||
("Distribute Vertically", "vertical", Icon::DistributeV),
|
||||
] {
|
||||
for (label, dir, icon) in [("Distribute Horizontally", "horizontal", Icon::DistributeH), ("Distribute Vertically", "vertical", Icon::DistributeV)]
|
||||
{
|
||||
MenuItem::command(CommandRef::with_params("arrange.distribute", json!({"dir": dir, "to": to}))).label(label).icon(icon.id()).show(ui);
|
||||
}
|
||||
Divider::horizontal().show(ui);
|
||||
@@ -109,19 +104,13 @@ pub(crate) fn arrange_group(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
"arrange.bringForward",
|
||||
"Bring Forward",
|
||||
Icon::BringForward,
|
||||
[
|
||||
("Bring Forward", "arrange.bringForward", Icon::BringForward),
|
||||
("Bring to Front", "arrange.bringToFront", Icon::BringToFront),
|
||||
],
|
||||
[("Bring Forward", "arrange.bringForward", Icon::BringForward), ("Bring to Front", "arrange.bringToFront", Icon::BringToFront)],
|
||||
),
|
||||
(
|
||||
"arrange.sendBackward",
|
||||
"Send Backward",
|
||||
Icon::SendBackward,
|
||||
[
|
||||
("Send Backward", "arrange.sendBackward", Icon::SendBackward),
|
||||
("Send to Back", "arrange.sendToBack", Icon::SendToBack),
|
||||
],
|
||||
[("Send Backward", "arrange.sendBackward", Icon::SendBackward), ("Send to Back", "arrange.sendToBack", Icon::SendToBack)],
|
||||
),
|
||||
] {
|
||||
let choices = entries(ui, &options);
|
||||
@@ -151,10 +140,9 @@ pub(crate) fn arrange_group(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
Menu::new("Align options").opened_by(&align.response, Trigger::Click).show(ui, |ui, cx| align_menu(app, ui, cx));
|
||||
Stack::new().show(ui, |ui, _| {
|
||||
// The arrow follows its entries: Ungroup stays reachable while Group is disabled for one selected group.
|
||||
for (id, label, icon, options) in [
|
||||
("arrange.group", "Group", Icon::Group, GROUP.as_slice()),
|
||||
("arrange.rotateRight", "Rotate", Icon::Rotate, ROTATE.as_slice()),
|
||||
] {
|
||||
for (id, label, icon, options) in
|
||||
[("arrange.group", "Group", Icon::Group, GROUP.as_slice()), ("arrange.rotateRight", "Rotate", Icon::Rotate, ROTATE.as_slice())]
|
||||
{
|
||||
let choices = entries(ui, options);
|
||||
let out = SplitButton::command(id, SplitMenu::Entries(&choices))
|
||||
.label(label)
|
||||
|
||||
@@ -24,9 +24,10 @@ impl ThumbSource<u64> for DiagramThumbs<'_> {
|
||||
Revision::of(&(key, Arc::as_ptr(self.doc).addr(), self.slide))
|
||||
}
|
||||
fn render(&self, key: &u64, request: &ThumbRequest) -> ThumbRender {
|
||||
let Some((kind, outline)) = deckcraft_engine::cmd::smartart::LAYOUTS.iter().find_map(|(kind, _)| {
|
||||
[false, true].into_iter().find(|outline| self.key(kind, *outline) == *key).map(|outline| (*kind, outline))
|
||||
}) else {
|
||||
let Some((kind, outline)) = deckcraft_engine::cmd::smartart::LAYOUTS
|
||||
.iter()
|
||||
.find_map(|(kind, _)| [false, true].into_iter().find(|outline| self.key(kind, *outline) == *key).map(|outline| (*kind, outline)))
|
||||
else {
|
||||
return ThumbRender::Blank;
|
||||
};
|
||||
let Some(slide) = self.doc.slides.get(self.slide).or_else(|| self.doc.slides.first()) else {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use super::{SlideApp, Ui, Value, json};
|
||||
use crate::theme;
|
||||
use egui::{Color32, Rect, Stroke, pos2};
|
||||
use craft::ui::contract::{ActivateOn, Bind, BodyCx, CollectionEvent, Props as _, SelectMode, Show as _, ShowCollection as _};
|
||||
use craft::ui::display::{Picture, PictureSize};
|
||||
use craft::ui::list::ThumbAspect;
|
||||
@@ -8,6 +7,7 @@ use craft::ui::menu::{Menu, MenuItem};
|
||||
use craft::ui::primitives::{Glyph, HAlign, IconSpec, PaintShape, StrokeWidth, TextRun};
|
||||
use craft::ui::style::{DataColor, TypeRole, UiTokens};
|
||||
use craft::ui::tile_grid::{CaptionPlace, Tile, TileGrid, TileGroup};
|
||||
use egui::{Color32, Rect, Stroke, pos2};
|
||||
use std::sync::LazyLock;
|
||||
|
||||
/// A ColorRef as a command colour parameter.
|
||||
@@ -234,12 +234,7 @@ fn flattened_preset(r: Rect, name: &str) -> Vec<FlatPath> {
|
||||
pub fn paint_preset(p: &egui::Painter, r: Rect, name: &str, fill: Color32, stroke: Color32) {
|
||||
for path in flattened_preset(r, name) {
|
||||
if path.closed && fill != Color32::TRANSPARENT && path.fill != deckcraft_geom::preset::FillMode::None {
|
||||
p.add(egui::Shape::Path(egui::epaint::PathShape {
|
||||
points: path.points.clone(),
|
||||
closed: true,
|
||||
fill,
|
||||
stroke: Stroke::NONE.into(),
|
||||
}));
|
||||
p.add(egui::Shape::Path(egui::epaint::PathShape { points: path.points.clone(), closed: true, fill, stroke: Stroke::NONE.into() }));
|
||||
}
|
||||
if path.stroke {
|
||||
p.add(egui::Shape::Path(egui::epaint::PathShape {
|
||||
@@ -498,7 +493,9 @@ pub fn preset_outline(r: Rect, name: &str) -> Vec<Vec<egui::Pos2>> {
|
||||
flattened_preset(r, name)
|
||||
.into_iter()
|
||||
.map(|mut path| {
|
||||
if path.closed && let Some(first) = path.points.first().copied() {
|
||||
if path.closed
|
||||
&& let Some(first) = path.points.first().copied()
|
||||
{
|
||||
path.points.push(first);
|
||||
}
|
||||
path.points
|
||||
|
||||
@@ -18,7 +18,7 @@ use serde_json::{Value, json};
|
||||
|
||||
use super::arrange::arrange_menu;
|
||||
use super::galleries::{self, cref_param, effects_menu, layout_gallery, outline_menu, quick_styles, shapes_gallery, smartart_gallery};
|
||||
use super::{fonts, fmt_state};
|
||||
use super::{fmt_state, fonts};
|
||||
use crate::SlideApp;
|
||||
use crate::icons::Icon;
|
||||
use crate::panels::color_row::{color_menu, take_color_answer};
|
||||
@@ -80,13 +80,12 @@ fn slides(app: &mut SlideApp, ui: &mut Ui) {
|
||||
app.open_dialog("outline", json!({}));
|
||||
}
|
||||
let desktop = app.host.files().can_pick();
|
||||
let reuse = [
|
||||
Entry::new(false, Word::plain("Reuse Slides…")),
|
||||
Entry::new(true, Word::plain("Reuse Slides (Keep Source Formatting)…")),
|
||||
]
|
||||
.map(|entry| {
|
||||
if desktop { entry } else { entry.disabled_reason(Word::plain("Choosing a presentation to reuse needs the desktop app")) }
|
||||
});
|
||||
let reuse = [Entry::new(false, Word::plain("Reuse Slides…")), Entry::new(true, Word::plain("Reuse Slides (Keep Source Formatting)…"))]
|
||||
.map(
|
||||
|entry| {
|
||||
if desktop { entry } else { entry.disabled_reason(Word::plain("Choosing a presentation to reuse needs the desktop app")) }
|
||||
},
|
||||
);
|
||||
if let Some(keep) = Menu::inline(Word::plain("Reuse Slides")).pick(ui, &reuse).picked {
|
||||
let _ = app.run("app.reuseSlidesDialog", json!({"keepFormatting": keep}));
|
||||
}
|
||||
@@ -138,10 +137,8 @@ fn font(app: &mut SlideApp, ui: &mut Ui, state: &Value) {
|
||||
if picked.action == Some(0) {
|
||||
let _ = app.run("font.rescan", json!({}));
|
||||
}
|
||||
let presets: Vec<_> = deckcraft_engine::cmd::format::SIZES
|
||||
.iter()
|
||||
.map(|size| Entry::new(NumberPick::Number(*size), size.to_string()))
|
||||
.collect();
|
||||
let presets: Vec<_> =
|
||||
deckcraft_engine::cmd::format::SIZES.iter().map(|size| Entry::new(NumberPick::Number(*size), size.to_string())).collect();
|
||||
let size = NumberField::new(Word::plain("Font size"), Bind::given(state["size"].as_f64()))
|
||||
.presets(&presets)
|
||||
.enabled(commands::resolve(ui.ctx(), "format.size").enabled)
|
||||
@@ -221,9 +218,7 @@ impl TextColor {
|
||||
|
||||
fn text_color(app: &mut SlideApp, ui: &mut Ui, target: TextColor) {
|
||||
let (key, label, command, icon, color, none) = match target {
|
||||
TextColor::Highlight => (
|
||||
HIGHLIGHT_KEY, "Text Highlight Color", "format.highlight", Icon::Highlight, Color32::YELLOW, Some("No Color"),
|
||||
),
|
||||
TextColor::Highlight => (HIGHLIGHT_KEY, "Text Highlight Color", "format.highlight", Icon::Highlight, Color32::YELLOW, Some("No Color")),
|
||||
TextColor::Font => (FONT_COLOR_KEY, "Font Color", "format.color", Icon::FontColor, Color32::from_rgb(0xC0, 0, 0), None),
|
||||
};
|
||||
let hex = format!("#{:02X}{:02X}{:02X}", color.r(), color.g(), color.b());
|
||||
@@ -244,10 +239,9 @@ fn text_color(app: &mut SlideApp, ui: &mut Ui, target: TextColor) {
|
||||
fn paragraph(app: &mut SlideApp, ui: &mut Ui) {
|
||||
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
|
||||
Row::new().gap(Gap::None).show(ui, |ui, _| {
|
||||
for (command, label, icon, tab) in [
|
||||
("format.bullets", "Bullets", Icon::Bullets, "bulleted"),
|
||||
("format.numbering", "Numbering", Icon::Numbering, "numbered"),
|
||||
] {
|
||||
for (command, label, icon, tab) in
|
||||
[("format.bullets", "Bullets", Icon::Bullets, "bulleted"), ("format.numbering", "Numbering", Icon::Numbering, "numbered")]
|
||||
{
|
||||
SplitButton::<()>::command(
|
||||
command,
|
||||
SplitMenu::Body(Box::new(|ui, cx| {
|
||||
@@ -293,9 +287,7 @@ fn paragraph(app: &mut SlideApp, ui: &mut Ui) {
|
||||
.show(ui);
|
||||
Menu::new(Word::plain("Line Spacing")).opened_by(&spacing.response, Trigger::Click).show(ui, |ui, _| {
|
||||
for lines in [1.0, 1.5, 2.0, 2.5, 3.0] {
|
||||
MenuItem::command(CommandRef::with_params("format.lineSpacing", json!({"lines": lines})))
|
||||
.label(format!("{lines:.1}"))
|
||||
.show(ui);
|
||||
MenuItem::command(CommandRef::with_params("format.lineSpacing", json!({"lines": lines}))).label(format!("{lines:.1}")).show(ui);
|
||||
}
|
||||
MenuItem::command("format.paragraphDialog").label(Word::plain("Line Spacing Options…")).show(ui);
|
||||
if MenuItem::new(Word::plain("Tabs…")).show(ui).ran {
|
||||
@@ -333,12 +325,9 @@ fn paragraph(app: &mut SlideApp, ui: &mut Ui) {
|
||||
.enabled(commands::resolve(ui.ctx(), "format.direction").enabled)
|
||||
.show(ui);
|
||||
Menu::new(Word::plain("Text Direction")).opened_by(&direction.response, Trigger::Click).show(ui, |ui, _| {
|
||||
for (label, dir) in [
|
||||
("Horizontal", "horizontal"),
|
||||
("Rotate all text 90°", "rotate90"),
|
||||
("Rotate all text 270°", "rotate270"),
|
||||
("Stacked", "stacked"),
|
||||
] {
|
||||
for (label, dir) in
|
||||
[("Horizontal", "horizontal"), ("Rotate all text 90°", "rotate90"), ("Rotate all text 270°", "rotate270"), ("Stacked", "stacked")]
|
||||
{
|
||||
MenuItem::command(CommandRef::with_params("format.direction", json!({"dir": dir}))).label(Word::plain(label)).show(ui);
|
||||
}
|
||||
});
|
||||
@@ -456,11 +445,7 @@ pub(crate) fn home(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
row.group(RibbonGroup::new("home.font", Word::plain("Font"), Icon::Fonts.id().into()), |ui| font(app, ui, &state));
|
||||
row.group(RibbonGroup::new("home.paragraph", Word::plain("Paragraph"), Icon::AlignLeft.id().into()), |ui| paragraph(app, ui));
|
||||
row.group(RibbonGroup::new("home.picture", Word::plain("Picture"), Icon::Picture.id().into()), |ui| {
|
||||
Button::command("app.insertPictureDialog")
|
||||
.label(Word::plain("Picture"))
|
||||
.icon(Icon::Picture.id())
|
||||
.arrangement(Arrangement::Stacked)
|
||||
.show(ui);
|
||||
Button::command("app.insertPictureDialog").label(Word::plain("Picture")).icon(Icon::Picture.id()).arrangement(Arrangement::Stacked).show(ui);
|
||||
});
|
||||
if let Some(pick) = take_color_answer(app, SHAPE_FILL_KEY) {
|
||||
apply_fill(app, pick);
|
||||
|
||||
@@ -269,4 +269,3 @@ pub(super) fn chart_menu_types() -> Vec<Option<deckcraft_model::chart::ChartType
|
||||
v.extend(ChartType::OFFICE_2016.iter().copied().filter(|k| !ChartType::MAIN.contains(k)).map(Some));
|
||||
v
|
||||
}
|
||||
|
||||
@@ -34,11 +34,7 @@ pub(crate) fn picture_format(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
.show(ui);
|
||||
Menu::new("Remove Background").opened_by(&opener.response, Trigger::Click).show(ui, |ui, cx| {
|
||||
for (label, tolerance) in [("Remove Background", 20.0), ("Remove More (looser)", 35.0), ("Remove Less (tighter)", 10.0)] {
|
||||
if MenuItem::command(CommandRef::with_params("picture.removeBackground", json!({"tolerance": tolerance})))
|
||||
.label(label)
|
||||
.show(ui)
|
||||
.ran
|
||||
{
|
||||
if MenuItem::command(CommandRef::with_params("picture.removeBackground", json!({"tolerance": tolerance}))).label(label).show(ui).ran {
|
||||
cx.request_close();
|
||||
}
|
||||
}
|
||||
@@ -85,9 +81,11 @@ pub(crate) fn picture_format(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
MenuItem::heading("Recolor").show(ui);
|
||||
let sc = app.color_scheme();
|
||||
let presets = deckcraft_engine::cmd::recolor::presets();
|
||||
if let Some(preset) = style_grid(ui, TileGrid::new("Recolor").natural_height(true), &presets, None, ThumbAspect::new(40, 30), |cx, rect, id| {
|
||||
paint_recolor(cx, rect, id, &sc)
|
||||
}) {
|
||||
if let Some(preset) =
|
||||
style_grid(ui, TileGrid::new("Recolor").natural_height(true), &presets, None, ThumbAspect::new(40, 30), |cx, rect, id| {
|
||||
paint_recolor(cx, rect, id, &sc)
|
||||
})
|
||||
{
|
||||
let _ = app.run("picture.recolor", json!({"preset": preset}));
|
||||
cx.request_close();
|
||||
}
|
||||
@@ -144,8 +142,7 @@ pub(crate) fn picture_format(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
row.group(RibbonGroup::new("picture.styles", "Picture Styles", Icon::QuickStyles.id().into()), |ui| {
|
||||
use deckcraft_engine::cmd::picture_style::{STYLES, look};
|
||||
let styles: Vec<_> = STYLES.iter().map(|(id, label)| ((*id).to_owned(), (*label).to_owned())).collect();
|
||||
let paints: Vec<_> =
|
||||
styles.iter().map(|(id, _)| move |cx: &ContentPainterCx<'_>, rect| paint_picture_style(cx, rect, look(id))).collect();
|
||||
let paints: Vec<_> = styles.iter().map(|(id, _)| move |cx: &ContentPainterCx<'_>, rect| paint_picture_style(cx, rect, look(id))).collect();
|
||||
let items: Vec<_> = styles
|
||||
.iter()
|
||||
.zip(&paints)
|
||||
@@ -154,9 +151,8 @@ pub(crate) fn picture_format(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
let mut more_pick = None;
|
||||
let mut body = |ui: &mut Ui, cx: &mut BodyCx<'_>| {
|
||||
let grid = TileGrid::new("Picture Styles").card_columns(6).column_rule(ColumnRule::Exactly(6));
|
||||
if let Some(style) = style_grid(ui, grid, &styles, None, ThumbAspect::new(56, 44), |cx, rect, id| {
|
||||
paint_picture_style(cx, rect, look(id))
|
||||
}) {
|
||||
if let Some(style) = style_grid(ui, grid, &styles, None, ThumbAspect::new(56, 44), |cx, rect, id| paint_picture_style(cx, rect, look(id)))
|
||||
{
|
||||
more_pick = Some(style);
|
||||
cx.request_close();
|
||||
}
|
||||
@@ -209,13 +205,10 @@ pub(crate) fn picture_format(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
}
|
||||
Divider::horizontal().show(ui);
|
||||
for (label, value) in [("Crop 10% each side", 0.1), ("Crop 20% each side", 0.2), ("Reset Crop", 0.0)] {
|
||||
if MenuItem::command(CommandRef::with_params(
|
||||
"picture.crop",
|
||||
json!({"left": value, "top": value, "right": value, "bottom": value}),
|
||||
))
|
||||
.label(label)
|
||||
.show(ui)
|
||||
.ran
|
||||
if MenuItem::command(CommandRef::with_params("picture.crop", json!({"left": value, "top": value, "right": value, "bottom": value})))
|
||||
.label(label)
|
||||
.show(ui)
|
||||
.ran
|
||||
{
|
||||
cx.request_close();
|
||||
}
|
||||
@@ -236,16 +229,12 @@ pub(super) fn style_grid(
|
||||
) -> Option<String> {
|
||||
let source = keyed(styles, |(id, _)| id.clone());
|
||||
let selection = Selection::new(current.cloned().into_iter().collect(), current.cloned(), current.cloned());
|
||||
let out = grid
|
||||
.select(SelectMode::Single)
|
||||
.selection(Bind::given(selection))
|
||||
.caption(CaptionPlace::None)
|
||||
.show_items(ui, &source, &mut |id, _| {
|
||||
let label = styles.iter().find(|(key, _)| key == id).map(|(_, label)| label.clone()).unwrap_or_default();
|
||||
let id = id.clone();
|
||||
let paint = &paint;
|
||||
Tile::new(label).thumb(aspect, move |cx, rect| paint(cx, rect, &id))
|
||||
});
|
||||
let out = grid.select(SelectMode::Single).selection(Bind::given(selection)).caption(CaptionPlace::None).show_items(ui, &source, &mut |id, _| {
|
||||
let label = styles.iter().find(|(key, _)| key == id).map(|(_, label)| label.clone()).unwrap_or_default();
|
||||
let id = id.clone();
|
||||
let paint = &paint;
|
||||
Tile::new(label).thumb(aspect, move |cx, rect| paint(cx, rect, &id))
|
||||
});
|
||||
let mut picked = None;
|
||||
for event in out.response.events {
|
||||
match event {
|
||||
@@ -274,10 +263,7 @@ fn paint_picture_style(cx: &ContentPainterCx<'_>, r: Rect, lk: Option<deckcraft_
|
||||
let r = r.shrink(7.0);
|
||||
cx.with_draw(|d| {
|
||||
if lk.shadow.is_some() {
|
||||
d.data_fill(
|
||||
&PaintShape::Rect(r.translate(r.size() * SHADOW_OFFSET), CornerRadius::same(2)),
|
||||
DataColor::from(SHADOW),
|
||||
);
|
||||
d.data_fill(&PaintShape::Rect(r.translate(r.size() * SHADOW_OFFSET), CornerRadius::same(2)), DataColor::from(SHADOW));
|
||||
}
|
||||
let sky = SKY;
|
||||
let shape = match lk.preset {
|
||||
@@ -309,10 +295,7 @@ fn paint_picture_style(cx: &ContentPainterCx<'_>, r: Rect, lk: Option<deckcraft_
|
||||
}
|
||||
if lk.reflection {
|
||||
d.data_fill(
|
||||
&PaintShape::Rect(
|
||||
Rect::from_min_max(pos2(r.left(), r.bottom() + 1.0), pos2(r.right(), r.bottom() + 5.0)),
|
||||
CornerRadius::ZERO,
|
||||
),
|
||||
&PaintShape::Rect(Rect::from_min_max(pos2(r.left(), r.bottom() + 1.0), pos2(r.right(), r.bottom() + 5.0)), CornerRadius::ZERO),
|
||||
DataColor::from(sky.gamma_multiply(0.3)),
|
||||
);
|
||||
}
|
||||
@@ -350,10 +333,7 @@ fn paint_recolor(cx: &ContentPainterCx<'_>, r: Rect, id: &str, sc: &deckcraft_co
|
||||
let c = Color32::from_rgb(rgb[0].clamp(0.0, 255.0) as u8, rgb[1].clamp(0.0, 255.0) as u8, rgb[2].clamp(0.0, 255.0) as u8);
|
||||
let w = r.width() / n as f32;
|
||||
d.data_fill(
|
||||
&PaintShape::Rect(
|
||||
Rect::from_min_size(pos2(r.left() + k as f32 * w, r.top()), vec2(w + 0.5, r.height())),
|
||||
CornerRadius::ZERO,
|
||||
),
|
||||
&PaintShape::Rect(Rect::from_min_size(pos2(r.left() + k as f32 * w, r.top()), vec2(w + 0.5, r.height())), CornerRadius::ZERO),
|
||||
DataColor::from(c),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use super::arrange::{arrange_group, size_group};
|
||||
use super::galleries::{apply_line_answer, cref_param, effects_menu, outline_menu, quick_styles, shapes_gallery};
|
||||
use super::{Icon, SlideApp, Ui, json};
|
||||
use egui::{Color32, Rect, Stroke, pos2};
|
||||
use crate::panels::color_row::{color_menu, take_color_answer};
|
||||
use craft::behavior::{Selection, SelectionChange};
|
||||
use craft::keymap::CommandRef;
|
||||
@@ -19,6 +18,7 @@ use craft::ui::list::{ThumbAspect, ThumbSize};
|
||||
use craft::ui::menu::{Menu, MenuItem};
|
||||
use craft::ui::runtime::{commands, env::UnitKind};
|
||||
use craft::ui::tile_grid::{CaptionPlace, Tile, TileGrid};
|
||||
use egui::{Color32, Rect, Stroke, pos2};
|
||||
|
||||
fn selected_warp(app: &SlideApp) -> Option<String> {
|
||||
let doc = app.session.active()?;
|
||||
|
||||
@@ -44,11 +44,8 @@ pub(crate) fn publish(app: &mut SlideApp, states: &mut CommandStates) {
|
||||
] {
|
||||
checked(states, id.into(), app.ui.view == mode);
|
||||
}
|
||||
for (id, which) in [
|
||||
("view.slideMaster", MasterView::Slide),
|
||||
("view.handoutMaster", MasterView::Handout),
|
||||
("view.notesMaster", MasterView::Notes),
|
||||
] {
|
||||
for (id, which) in [("view.slideMaster", MasterView::Slide), ("view.handoutMaster", MasterView::Handout), ("view.notesMaster", MasterView::Notes)]
|
||||
{
|
||||
checked(states, CommandRef::with_params(id, json!({"toggle": true})), master_view_shown(&app.session, which));
|
||||
}
|
||||
for (id, on) in [
|
||||
|
||||
@@ -71,11 +71,9 @@ pub(crate) fn table_design(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
.collect();
|
||||
let mut more_pick = None;
|
||||
let mut body = |ui: &mut egui::Ui, cx: &mut BodyCx<'_>| {
|
||||
if let Some(style) =
|
||||
style_grid(ui, TileGrid::new("Table Styles"), &styles, Some(¤t), ThumbAspect::new(48, 36), |cx, rect, id| {
|
||||
paint_table_style(cx, rect, id, &sc)
|
||||
})
|
||||
{
|
||||
if let Some(style) = style_grid(ui, TileGrid::new("Table Styles"), &styles, Some(¤t), ThumbAspect::new(48, 36), |cx, rect, id| {
|
||||
paint_table_style(cx, rect, id, &sc)
|
||||
}) {
|
||||
more_pick = Some(style);
|
||||
cx.request_close();
|
||||
}
|
||||
@@ -139,12 +137,7 @@ pub(crate) fn table_design(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
] {
|
||||
let mut params = pen.clone();
|
||||
params["which"] = json!(which);
|
||||
if MenuItem::command(CommandRef::with_params("table.borders", params))
|
||||
.icon(Icon::Borders.id())
|
||||
.label(label)
|
||||
.show(ui)
|
||||
.ran
|
||||
{
|
||||
if MenuItem::command(CommandRef::with_params("table.borders", params)).icon(Icon::Borders.id()).label(label).show(ui).ran {
|
||||
cx.request_close();
|
||||
}
|
||||
}
|
||||
@@ -178,11 +171,7 @@ pub(crate) fn table_design(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
});
|
||||
row.group(RibbonGroup::new("table.draw", "Draw Borders", Icon::Pencil.id().into()), |ui| {
|
||||
for (icon, label, kind) in draw_borders() {
|
||||
ToggleButton::command(states::tool_ref(&kind, true))
|
||||
.icon(icon.id())
|
||||
.label(label)
|
||||
.arrangement(Arrangement::Stacked)
|
||||
.show(ui);
|
||||
ToggleButton::command(states::tool_ref(&kind, true)).icon(icon.id()).label(label).arrangement(Arrangement::Stacked).show(ui);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -302,11 +291,7 @@ pub(crate) fn table_layout(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
let opener = Button::new("Cell Margins").trailing_icon(DisclosureGlyph::menu_button()).popup(PopupKind::Menu).show(ui);
|
||||
Menu::new("Cell Margins").opened_by(&opener.response, Trigger::Click).show(ui, |ui, cx| {
|
||||
for (label, preset) in [("Normal", "normal"), ("None", "none"), ("Narrow", "narrow"), ("Wide", "wide")] {
|
||||
if MenuItem::command(CommandRef::with_params("table.cellMargins", json!({"preset": preset})))
|
||||
.label(label)
|
||||
.show(ui)
|
||||
.ran
|
||||
{
|
||||
if MenuItem::command(CommandRef::with_params("table.cellMargins", json!({"preset": preset}))).label(label).show(ui).ran {
|
||||
cx.request_close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,4 +251,3 @@ pub(super) fn transition_effect_rows(kind: &str, current: Option<&str>) -> Vec<(
|
||||
let opts = deckcraft_model::anim::TRANSITIONS.iter().find(|x| x.0 == kind).map(|x| x.4).unwrap_or(&[]);
|
||||
marked_options(opts, current)
|
||||
}
|
||||
|
||||
@@ -303,7 +303,11 @@ impl Show {
|
||||
self.hold.is_none()
|
||||
&& self.started
|
||||
&& !self.ended
|
||||
&& (self.state.playing || self.state.trigger_playing() || self.trans.is_some() || self.autoplay || self.state.advance_after(doc).is_some())
|
||||
&& (self.state.playing
|
||||
|| self.state.trigger_playing()
|
||||
|| self.trans.is_some()
|
||||
|| self.autoplay
|
||||
|| self.state.advance_after(doc).is_some())
|
||||
}
|
||||
|
||||
/// Advance the show's own clocks and automatic steps on a hidden logic pass. Drawing is a
|
||||
|
||||
@@ -14,11 +14,7 @@ const STRIP_HEIGHT: f32 = 34.0;
|
||||
|
||||
/// The slide's room, reserving the Reading View strip along its bottom edge.
|
||||
pub(super) fn slide_room(room: Rect, reading: bool) -> Rect {
|
||||
if reading {
|
||||
Rect::from_min_max(room.min, pos2(room.max.x, (room.max.y - STRIP_HEIGHT).max(room.min.y)))
|
||||
} else {
|
||||
room
|
||||
}
|
||||
if reading { Rect::from_min_max(room.min, pos2(room.max.x, (room.max.y - STRIP_HEIGHT).max(room.min.y))) } else { room }
|
||||
}
|
||||
|
||||
/// Shows command-bound audience controls and the document's Reading View slide count.
|
||||
@@ -44,15 +40,11 @@ pub(crate) fn show(ui: &mut Ui, show: &Show, doc: &Presentation, room: Rect) {
|
||||
Text::new(count.clone()).show(ui);
|
||||
});
|
||||
} else if !show.grid && (show.pointer_awake(frame::clock(ui.ctx())) || show.zoom_arm) {
|
||||
let rect = Rect::from_min_size(
|
||||
pos2(room.min.x + 16.0, room.max.y - 50.0),
|
||||
vec2((room.width() - 32.0).clamp(32.0, 520.0), STRIP_HEIGHT),
|
||||
);
|
||||
let rect = Rect::from_min_size(pos2(room.min.x + 16.0, room.max.y - 50.0), vec2((room.width() - 32.0).clamp(32.0, 520.0), STRIP_HEIGHT));
|
||||
let mut child = ui.new_child(UiBuilder::new().id_salt("show.floating.bar").max_rect(rect));
|
||||
Bar::new(Word::plain("Slide show controls"), BarKind::Tool)
|
||||
.look(BarLook::OverPicture)
|
||||
.background_press(BarBackgroundPress::Absorb)
|
||||
.show(&mut child, |ui, _| {
|
||||
Bar::new(Word::plain("Slide show controls"), BarKind::Tool).look(BarLook::OverPicture).background_press(BarBackgroundPress::Absorb).show(
|
||||
&mut child,
|
||||
|ui, _| {
|
||||
IconButton::command(IconId::new("chevron_left"), ShowCommands::Previous).show(ui);
|
||||
IconButton::command(IconId::new("chevron_right"), ShowCommands::Next).show(ui);
|
||||
ToggleButton::command(ShowCommands::Pen).icon(IconId::new("pencil")).icon_only().show(ui);
|
||||
@@ -62,6 +54,7 @@ pub(crate) fn show(ui: &mut Ui, show: &Show, doc: &Presentation, room: Rect) {
|
||||
ToggleButton::command(ShowCommands::Grid).label(Word::plain("All")).show(ui);
|
||||
ToggleButton::command(ShowCommands::Zoom).show(ui);
|
||||
Button::command(ShowCommands::End).label(Word::plain("End")).show(ui);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -164,11 +164,8 @@ impl ShowFrames {
|
||||
doc,
|
||||
slide,
|
||||
});
|
||||
let unchanged = self
|
||||
.wanted
|
||||
.as_ref()
|
||||
.zip(wanted.as_ref())
|
||||
.is_some_and(|(a, b)| Arc::ptr_eq(&a.doc, &b.doc) && a.slide == b.slide && a.size == b.size);
|
||||
let unchanged =
|
||||
self.wanted.as_ref().zip(wanted.as_ref()).is_some_and(|(a, b)| Arc::ptr_eq(&a.doc, &b.doc) && a.slide == b.slide && a.size == b.size);
|
||||
if !unchanged {
|
||||
self.next = None;
|
||||
if let Some(queues) = &self.queues {
|
||||
@@ -225,9 +222,11 @@ impl ShowFrames {
|
||||
self.next = Some((key, texture));
|
||||
}
|
||||
}
|
||||
if self.next.as_ref().is_some_and(|(key, _)| {
|
||||
store.source::<FrameSource>(ctx, key, key.revision()).is_none_or(|source| !Arc::ptr_eq(&source.doc, doc))
|
||||
}) {
|
||||
if self
|
||||
.next
|
||||
.as_ref()
|
||||
.is_some_and(|(key, _)| store.source::<FrameSource>(ctx, key, key.revision()).is_none_or(|source| !Arc::ptr_eq(&source.doc, doc)))
|
||||
{
|
||||
self.next = None;
|
||||
}
|
||||
queues.next.resume();
|
||||
@@ -440,9 +439,8 @@ pub(crate) fn prepare(
|
||||
let changed = show.frames.current.as_ref().is_none_or(|(key, _)| key != &frame_key);
|
||||
let texture = texture.unwrap_or_else(|| {
|
||||
let backdrop = animating.then(|| show.frames.backdrop(ctx, doc, back_key));
|
||||
let image = render_frame(
|
||||
doc, slide, tl.clone(), key.step, t, size, hidden.clone(), ×, render_threads(), &plays, &stamps, backdrop.as_deref(),
|
||||
);
|
||||
let image =
|
||||
render_frame(doc, slide, tl.clone(), key.step, t, size, hidden.clone(), ×, render_threads(), &plays, &stamps, backdrop.as_deref());
|
||||
put_frame(&store, ctx, frame_key.clone(), doc.clone(), image)
|
||||
});
|
||||
show.frames.current = Some((frame_key, texture));
|
||||
@@ -451,11 +449,8 @@ pub(crate) fn prepare(
|
||||
show.remote_preview = show.frames.current_source(ctx).and_then(|source| crate::presenter::Preview::from_image(&source.image));
|
||||
}
|
||||
show.next_preview = show.frames.next.as_ref().and_then(|_| show.frames.wanted.as_ref().map(|wanted| (wanted.doc.clone(), wanted.slide)));
|
||||
let framed: Vec<_> = clips
|
||||
.iter()
|
||||
.filter(|(id, _, clip)| clip.video && !hidden.contains(id) && media.texture(*id).is_some())
|
||||
.map(|clip| clip.0)
|
||||
.collect();
|
||||
let framed: Vec<_> =
|
||||
clips.iter().filter(|(id, _, clip)| clip.video && !hidden.contains(id) && media.texture(*id).is_some()).map(|clip| clip.0).collect();
|
||||
let full_screen = clips.iter().any(|(id, _, clip)| framed.contains(id) && clip.full_screen && media.is_playing(*id));
|
||||
let skip = if full_screen { vec![] } else { below_playing_video(doc, slide, &framed) };
|
||||
let overlay = if skip.is_empty() {
|
||||
@@ -474,10 +469,8 @@ pub(crate) fn prepare(
|
||||
if !animating && !tl.is_empty() {
|
||||
show.frames.prefetch_backdrop(ctx, doc, back_key);
|
||||
}
|
||||
let wanted = (!animating && show.trans.is_none() && !show.preview_only)
|
||||
.then(|| show.state.peek_next(doc))
|
||||
.flatten()
|
||||
.filter(|&next| !has_gifs(doc, next));
|
||||
let wanted =
|
||||
(!animating && show.trans.is_none() && !show.preview_only).then(|| show.state.peek_next(doc)).flatten().filter(|&next| !has_gifs(doc, next));
|
||||
if let Some(queues) = &show.frames.queues {
|
||||
let wanted = wanted.map(|slide| entry_key(doc, slide, size));
|
||||
queues.next.reprioritize(|queued, priority| (wanted.as_ref() == Some(queued)).then_some(priority));
|
||||
@@ -494,11 +487,7 @@ pub(crate) fn prepare(
|
||||
}
|
||||
}
|
||||
}
|
||||
if animating || show.trans.is_some() || clips.iter().any(|(id, _, _)| media.is_playing(*id)) {
|
||||
Some(0.0)
|
||||
} else {
|
||||
wake
|
||||
}
|
||||
if animating || show.trans.is_some() || clips.iter().any(|(id, _, _)| media.is_playing(*id)) { Some(0.0) } else { wake }
|
||||
}
|
||||
|
||||
fn prepare_transition(
|
||||
@@ -537,15 +526,17 @@ fn prepare_transition(
|
||||
let text: Vec<_> = morph
|
||||
.text
|
||||
.iter()
|
||||
.map(|text| deckcraft_render::TextMorph {
|
||||
old: text.old, new: text.new, from: text.from, to: text.to, chars: text.chars, t: morph.mix,
|
||||
})
|
||||
.map(|text| deckcraft_render::TextMorph { old: text.old, new: text.new, from: text.from, to: text.to, chars: text.chars, t: morph.mix })
|
||||
.collect();
|
||||
let paths: Vec<_> = morph
|
||||
.paths
|
||||
.iter()
|
||||
.map(|path| deckcraft_render::PathMorph {
|
||||
id: path.id, from: path.from.clone(), from_box: path.from_box, to_box: path.to_box, t: morph.mix,
|
||||
id: path.id,
|
||||
from: path.from.clone(),
|
||||
from_box: path.from_box,
|
||||
to_box: path.to_box,
|
||||
t: morph.mix,
|
||||
})
|
||||
.collect();
|
||||
let image = deckcraft_render::render_blend(doc, (from, slide), morph.mix, &morph.shapes, &text, &paths, &opts);
|
||||
@@ -555,9 +546,10 @@ fn prepare_transition(
|
||||
} else {
|
||||
if deckcraft_anim::uses_slide_parts(&tr.kind, &tr.option) {
|
||||
let keys: [FrameKey; 4] = std::array::from_fn(|part| FrameKey::Part { doc: frame.key.doc, from: tr.from, to: slide, size, part });
|
||||
let missing = keys.iter().enumerate().any(|(part, key)| {
|
||||
(part >= 2 || tr.from.is_some()) && store.state(ctx, key, key.revision()).shown().is_none()
|
||||
});
|
||||
let missing = keys
|
||||
.iter()
|
||||
.enumerate()
|
||||
.any(|(part, key)| (part >= 2 || tr.from.is_some()) && store.state(ctx, key, key.revision()).shown().is_none());
|
||||
if missing {
|
||||
for (key, image) in keys.iter().zip(part_textures(doc, tr.from, slide, size)) {
|
||||
if let Some(image) = image {
|
||||
|
||||
@@ -103,9 +103,10 @@ pub(super) fn media_bar_target(doc: &Presentation, show: &Show, view: CanvasView
|
||||
|
||||
/// The media shape under the pointer on the shown slide.
|
||||
pub(super) fn media_hit(doc: &Presentation, slide: usize, at: Point) -> Option<(ShapeId, deckcraft_model::MediaClip)> {
|
||||
crate::media::slide_media(doc, slide).into_iter().rev().find_map(|(id, x, clip)| {
|
||||
(at.x >= x.x && at.x <= x.x + x.w && at.y >= x.y && at.y <= x.y + x.h).then_some((id, clip))
|
||||
})
|
||||
crate::media::slide_media(doc, slide)
|
||||
.into_iter()
|
||||
.rev()
|
||||
.find_map(|(id, x, clip)| (at.x >= x.x && at.x <= x.x + x.w && at.y >= x.y && at.y <= x.y + x.h).then_some((id, clip)))
|
||||
}
|
||||
|
||||
/// What a click on the pointer's spot acts on.
|
||||
|
||||
@@ -49,12 +49,8 @@ fn a_still_cursor_hides_over_a_clickable_shape() {
|
||||
let size = session.active().unwrap().doc.slide_size;
|
||||
let r = session.execute("shape.insert", &json!({"preset": "rect", "rect": [0.0, 0.0, size.width, size.height]})).unwrap();
|
||||
session.execute("insert.hyperlink", &json!({"url": "https://example.org", "ids": [r["id"]]})).unwrap();
|
||||
let mut harness = harness_with(
|
||||
session,
|
||||
Services::default(),
|
||||
egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(0.25),
|
||||
|_| {},
|
||||
);
|
||||
let mut harness =
|
||||
harness_with(session, Services::default(), egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(0.25), |_| {});
|
||||
harness.state_mut().ui.presenter_view = false;
|
||||
harness.run_steps(3);
|
||||
harness.state_mut().start_show(0, false);
|
||||
@@ -76,12 +72,8 @@ fn keep_cursor_visible_leaves_a_still_cursor_over_a_link() {
|
||||
session.execute("slide.go", &json!({"index": 0})).unwrap();
|
||||
let r = session.execute("shape.insert", &json!({"preset": "rect", "rect": [0.0, 0.0, size.width, size.height]})).unwrap();
|
||||
session.execute("insert.hyperlink", &json!({"slide": 1, "ids": [r["id"]]})).unwrap();
|
||||
let mut harness = harness_with(
|
||||
session,
|
||||
Services::default(),
|
||||
egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(0.25),
|
||||
|_| {},
|
||||
);
|
||||
let mut harness =
|
||||
harness_with(session, Services::default(), egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(0.25), |_| {});
|
||||
harness.state_mut().ui.presenter_view = false;
|
||||
harness.state_mut().run("show.keepCursor", json!({"on": true})).unwrap();
|
||||
harness.run_steps(3);
|
||||
@@ -277,12 +269,8 @@ fn show_with_gif() -> (egui_kittest::Harness<'static, SlideApp>, ShapeId, Pos2)
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let mut harness = harness_with(
|
||||
session,
|
||||
Services::default(),
|
||||
egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(0.25),
|
||||
|_| {},
|
||||
);
|
||||
let mut harness =
|
||||
harness_with(session, Services::default(), egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(0.25), |_| {});
|
||||
harness.state_mut().ui.presenter_view = false;
|
||||
harness.run_steps(3);
|
||||
harness.state_mut().start_show(1, false);
|
||||
@@ -330,11 +318,14 @@ fn presenter_navigation_uses_its_own_keyboard_events() {
|
||||
let mut harness = harness_with(session, Services::default(), egui_kittest::Harness::builder().with_size(vec2(1100.0, 700.0)), |_| {});
|
||||
harness.state_mut().show = Some(Show::new(&doc, 0, false, true));
|
||||
harness.ctx.options_mut(|options| options.max_passes = 2.try_into().unwrap());
|
||||
harness.ctx.on_begin_pass("presenter input rerun", Arc::new(|ui| {
|
||||
if ui.ctx().current_pass_index() == 0 {
|
||||
ui.ctx().request_discard("exercise show input on a second pass with no events");
|
||||
}
|
||||
}));
|
||||
harness.ctx.on_begin_pass(
|
||||
"presenter input rerun",
|
||||
Arc::new(|ui| {
|
||||
if ui.ctx().current_pass_index() == 0 {
|
||||
ui.ctx().request_discard("exercise show input on a second pass with no events");
|
||||
}
|
||||
}),
|
||||
);
|
||||
harness.run_steps(2);
|
||||
harness.get_by_label("Next ▶").click();
|
||||
harness.run_steps(2);
|
||||
@@ -688,12 +679,8 @@ fn show_of_three() -> egui_kittest::Harness<'static, SlideApp> {
|
||||
let mut session = deckcraft_engine::Session::with_new();
|
||||
session.execute("slide.new", &json!({})).unwrap();
|
||||
session.execute("slide.new", &json!({})).unwrap();
|
||||
let mut harness = harness_with(
|
||||
session,
|
||||
Services::default(),
|
||||
egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(1.0 / 60.0),
|
||||
|_| {},
|
||||
);
|
||||
let mut harness =
|
||||
harness_with(session, Services::default(), egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(1.0 / 60.0), |_| {});
|
||||
harness.state_mut().ui.presenter_view = false;
|
||||
harness.run_steps(3);
|
||||
harness.state_mut().start_show(0, false);
|
||||
@@ -1006,12 +993,8 @@ fn back_leaves_a_slide_whose_first_animation_is_with_previous() {
|
||||
.execute("animation.add", &json!({"effect": "fade", "class": "entrance", "ids": [id.0], "start": "withPrevious", "duration": 500}))
|
||||
.unwrap();
|
||||
// PLAN: plan error: the kept Back animation trial needs 0.25 s steps to finish its entrance in eight steps.
|
||||
let mut harness = harness_with(
|
||||
session,
|
||||
Services::default(),
|
||||
egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(0.25),
|
||||
|_| {},
|
||||
);
|
||||
let mut harness =
|
||||
harness_with(session, Services::default(), egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(0.25), |_| {});
|
||||
harness.run_steps(3);
|
||||
harness.state_mut().start_show(0, false);
|
||||
harness.run_steps(2);
|
||||
|
||||
@@ -195,7 +195,9 @@ impl CanvasTool for ShowTool<'_> {
|
||||
self.hit(pointer, cx);
|
||||
// Canvas controls own their initiating presses before the background tool. Media shape
|
||||
// clicks are independent of the visibility of their playback controls.
|
||||
if self.on_slide() && let Some((id, _)) = media_hit(self.doc, self.show.state.slide, at) {
|
||||
if self.on_slide()
|
||||
&& let Some((id, _)) = media_hit(self.doc, self.show.state.slide, at)
|
||||
{
|
||||
self.show.media_cues.push((id, "pause".into()));
|
||||
} else if let Some(Pick::Text(link)) = self.under.as_ref().and_then(|under| under.pick.clone()) {
|
||||
match self.show.state.follow_link(self.doc, &link, self.show.last_viewed) {
|
||||
@@ -319,7 +321,10 @@ impl CanvasTool for ShowTool<'_> {
|
||||
draw.stroke(&PaintShape::Path(points), DataStrokeWidth::Data(DataWidth::points(INK_WIDTH)), ink);
|
||||
}
|
||||
}
|
||||
if self.show.laser && !self.show.ended && let Some(pointer) = cx.pointer {
|
||||
if self.show.laser
|
||||
&& !self.show.ended
|
||||
&& let Some(pointer) = cx.pointer
|
||||
{
|
||||
let color = data_color(self.doc.show.laser_color);
|
||||
draw.data_fill(
|
||||
&PaintShape::Circle(pointer.pos, LASER_HALO_RADIUS),
|
||||
@@ -376,10 +381,7 @@ fn hint(draw: &Draw<'_>, cx: &ToolContext<'_>, text: &str, top: bool) {
|
||||
let y = if top { room.top() } else { room.bottom() - size.y };
|
||||
let rect = Rect::from_min_size(pos2(room.center().x - size.x / 2.0, y), size);
|
||||
// PLAN: plan error: Draw::surface_look over-picture resolver (show-w2) is not in this tree; the scrim pill stays hand-built until it lands.
|
||||
draw.fill(
|
||||
&PaintShape::Rect(rect, UiTokens::corner(style.tokens.shape.radius.pill)),
|
||||
style.color(style.tokens.color.surface.scrim),
|
||||
);
|
||||
draw.fill(&PaintShape::Rect(rect, UiTokens::corner(style.tokens.shape.radius.pill)), style.color(style.tokens.color.surface.scrim));
|
||||
draw.clipped(rect, |draw| {
|
||||
draw.text(rect.shrink(pad), &run);
|
||||
});
|
||||
|
||||
@@ -81,11 +81,8 @@ pub(crate) fn ui(app: &mut SlideApp, ui: &mut Ui, bcx: &mut BodyCx<'_>) {
|
||||
}
|
||||
let mut out = Out { keep: true, actions: vec![] };
|
||||
let pass = PagePass { doc: &doc, doc_uid, now, room, zoom: ShowZoomInputs { size, pixels_per_point, scheme: &scheme } };
|
||||
let media_wake = if show.grid {
|
||||
grid_pass(app, ui, bcx, &mut show, &pass, &mut out)
|
||||
} else {
|
||||
canvas_pass(app, ui, bcx, &mut show, &pass, &mut out)
|
||||
};
|
||||
let media_wake =
|
||||
if show.grid { grid_pass(app, ui, bcx, &mut show, &pass, &mut out) } else { canvas_pass(app, ui, bcx, &mut show, &pass, &mut out) };
|
||||
if out.keep && show.presenter && !show.reading {
|
||||
out.keep &= presenter_pass(ui, app, &mut show, &doc, now);
|
||||
}
|
||||
@@ -101,7 +98,9 @@ pub(crate) fn ui(app: &mut SlideApp, ui: &mut Ui, bcx: &mut BodyCx<'_>) {
|
||||
(Some(a), Some(b)) => Some(a.min(b)),
|
||||
(a, b) => a.or(b),
|
||||
};
|
||||
if out.keep && let Some(wake) = wake {
|
||||
if out.keep
|
||||
&& let Some(wake) = wake
|
||||
{
|
||||
frame::request_repaint_after(&ctx, (wake - now).max(0.0));
|
||||
}
|
||||
finish(app, show, now, out.keep);
|
||||
@@ -113,12 +112,8 @@ fn grid_pass(app: &mut SlideApp, ui: &mut Ui, bcx: &mut BodyCx<'_>, show: &mut S
|
||||
bars::show(ui, show, p.doc, p.room);
|
||||
let thumbs = crate::thumb_source::thumbnails(&ctx);
|
||||
let source = crate::thumb_source::DeckThumbs::new(p.doc.clone(), app.ui.grayscale);
|
||||
let pick = grid::sheet(
|
||||
ui,
|
||||
grid::GridSource::Deck { doc: p.doc, thumbs: &thumbs, source: &source },
|
||||
show.state.slide,
|
||||
super::zoom::slide_aspect(p.doc),
|
||||
);
|
||||
let pick =
|
||||
grid::sheet(ui, grid::GridSource::Deck { doc: p.doc, thumbs: &thumbs, source: &source }, show.state.slide, super::zoom::slide_aspect(p.doc));
|
||||
if let Some(index) = pick.picked {
|
||||
show.grid = false;
|
||||
show.blank = None;
|
||||
@@ -144,54 +139,58 @@ fn canvas_pass(app: &mut SlideApp, ui: &mut Ui, bcx: &mut BodyCx<'_>, show: &mut
|
||||
bars::show(ui, show, p.doc, p.room);
|
||||
}
|
||||
let mut media_wake = None;
|
||||
with_env(ui, |env| {
|
||||
env.values.set(*p.zoom.scheme);
|
||||
}, |ui| {
|
||||
let mut child = ui.new_child(UiBuilder::new().id_salt("show.canvas.room").max_rect(room));
|
||||
Canvas::new(Word::plain("Slide show"))
|
||||
.document(target)
|
||||
.view(Bind::given(show.view))
|
||||
.navigation(navigation)
|
||||
.keys_to_body(true)
|
||||
.pasteboard(PasteboardColor::Black)
|
||||
.show(&mut child, |ui, body| {
|
||||
let Some(mut pass) = tool_pass(&body.env) else { return };
|
||||
let Some(mut space) = pass.space else { return };
|
||||
show.view = pass.view.unwrap_or_else(|| space.target());
|
||||
show.zoomed = zoom::device(&show.view, p.zoom.pixels_per_point) > p.zoom.scheme.hundred * 1.001;
|
||||
publish(bcx, show);
|
||||
if !show.reading {
|
||||
bars::show(ui, show, p.doc, p.room);
|
||||
}
|
||||
media_controls(app, ui, show, p.doc, p.doc_uid, p.now, space.view);
|
||||
commands(bcx, show, p.doc, p.now, &p.zoom, out);
|
||||
with_env(
|
||||
ui,
|
||||
|env| {
|
||||
env.values.set(*p.zoom.scheme);
|
||||
},
|
||||
|ui| {
|
||||
let mut child = ui.new_child(UiBuilder::new().id_salt("show.canvas.room").max_rect(room));
|
||||
Canvas::new(Word::plain("Slide show"))
|
||||
.document(target)
|
||||
.view(Bind::given(show.view))
|
||||
.navigation(navigation)
|
||||
.keys_to_body(true)
|
||||
.pasteboard(PasteboardColor::Black)
|
||||
.show(&mut child, |ui, body| {
|
||||
let Some(mut pass) = tool_pass(&body.env) else { return };
|
||||
let Some(mut space) = pass.space else { return };
|
||||
show.view = pass.view.unwrap_or_else(|| space.target());
|
||||
show.zoomed = zoom::device(&show.view, p.zoom.pixels_per_point) > p.zoom.scheme.hundred * 1.001;
|
||||
publish(bcx, show);
|
||||
if !show.reading {
|
||||
bars::show(ui, show, p.doc, p.room);
|
||||
}
|
||||
media_controls(app, ui, show, p.doc, p.doc_uid, p.now, space.view);
|
||||
commands(bcx, show, p.doc, p.now, &p.zoom, out);
|
||||
|
||||
// Commands may reset the view; the tool must receive that view in this pass.
|
||||
space.set_view(show.view);
|
||||
pass.space = Some(space);
|
||||
pass.view = Some(show.view);
|
||||
run_tool(ui, show, p, out, &pass);
|
||||
advance(app, show, p.doc_uid, p.doc, p.now, out);
|
||||
if !show.zoomed {
|
||||
show.view.rect = pass.rect;
|
||||
ViewCommands::FitOnScreen.apply(&mut show.view, &target, None, p.zoom.pixels_per_point, p.zoom.scheme);
|
||||
}
|
||||
media_wake = prepare(app, show, p.doc, p.doc_uid, &ctx, p.now, pass.rect);
|
||||
space.set_view(show.view);
|
||||
with_canvas_space(ui, space, |ui| {
|
||||
let frames = &show.frames;
|
||||
let media = &app.media;
|
||||
let picture = AppPaint::new(|cx, view| frames::paint(frames, media, p.doc, cx, view));
|
||||
RasterDisplay::painted(
|
||||
Word::plain("Slide"),
|
||||
PixelSize::new(p.zoom.size.width.max(1.0).ceil() as u32, p.zoom.size.height.max(1.0).ceil() as u32),
|
||||
picture,
|
||||
)
|
||||
.picture()
|
||||
.show_at(ui, pass.rect);
|
||||
// Commands may reset the view; the tool must receive that view in this pass.
|
||||
space.set_view(show.view);
|
||||
pass.space = Some(space);
|
||||
pass.view = Some(show.view);
|
||||
run_tool(ui, show, p, out, &pass);
|
||||
advance(app, show, p.doc_uid, p.doc, p.now, out);
|
||||
if !show.zoomed {
|
||||
show.view.rect = pass.rect;
|
||||
ViewCommands::FitOnScreen.apply(&mut show.view, &target, None, p.zoom.pixels_per_point, p.zoom.scheme);
|
||||
}
|
||||
media_wake = prepare(app, show, p.doc, p.doc_uid, &ctx, p.now, pass.rect);
|
||||
space.set_view(show.view);
|
||||
with_canvas_space(ui, space, |ui| {
|
||||
let frames = &show.frames;
|
||||
let media = &app.media;
|
||||
let picture = AppPaint::new(|cx, view| frames::paint(frames, media, p.doc, cx, view));
|
||||
RasterDisplay::painted(
|
||||
Word::plain("Slide"),
|
||||
PixelSize::new(p.zoom.size.width.max(1.0).ceil() as u32, p.zoom.size.height.max(1.0).ceil() as u32),
|
||||
picture,
|
||||
)
|
||||
.picture()
|
||||
.show_at(ui, pass.rect);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
media_wake
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,13 @@ use super::{Blank, Presentation, Rect, Show, ShowZoomInputs, json, view_zoom};
|
||||
impl Show {
|
||||
/// The label reflects whether a zoom is active or awaiting its placement click.
|
||||
pub(super) fn zoom_label(&self) -> &'static str {
|
||||
if self.zoomed { "Zoom on" } else if self.zoom_arm { "Zoom…" } else { "Zoom" }
|
||||
if self.zoomed {
|
||||
"Zoom on"
|
||||
} else if self.zoom_arm {
|
||||
"Zoom…"
|
||||
} else {
|
||||
"Zoom"
|
||||
}
|
||||
}
|
||||
|
||||
/// Open only the grid of the window that received the command.
|
||||
|
||||
+167
-175
@@ -100,7 +100,9 @@ pub fn show(app: &mut SlideApp, ui: &mut Ui) {
|
||||
if let Some(index) = section {
|
||||
let section = &doc.sections[index];
|
||||
let open = section.slides.first().is_none_or(|id| !app.sorter.collapsed.contains(&(uid, id.0)));
|
||||
heads.push(TileGroup::new(Key::Section(index), keys.len(), slides.len(), section.name.clone()).detail(slides.len().to_string()).open(open));
|
||||
heads.push(
|
||||
TileGroup::new(Key::Section(index), keys.len(), slides.len(), section.name.clone()).detail(slides.len().to_string()).open(open),
|
||||
);
|
||||
}
|
||||
keys.extend(slides.iter().map(|&index| Key::Slide(doc.slides[index].id)));
|
||||
}
|
||||
@@ -111,136 +113,132 @@ pub fn show(app: &mut SlideApp, ui: &mut Ui) {
|
||||
let aspect = (doc.slide_size.width / doc.slide_size.height.max(1.0)) as f32;
|
||||
// PLAN: assumed SlideApp::slide_reveal: Option<SlideId> (shell-w11).
|
||||
let reveal = app.slide_reveal.take().map(Key::Slide);
|
||||
Stack::new()
|
||||
.id_salt(("sorter-scope", uid))
|
||||
.command_scope(CommandScope::new("sorter"))
|
||||
.fill()
|
||||
.show(ui, |ui, cx| {
|
||||
let words = cx.words::<SorterWords>();
|
||||
cx.publish(EditCommands::SelectAll, CommandState::new().enabled(!keys.is_empty()));
|
||||
while let Some((command, fired)) = cx.take_command::<EditCommands>() {
|
||||
if command == EditCommands::SelectAll {
|
||||
let _ = app.run("edit.selectAll", json!({"scope": "slides"}));
|
||||
} else {
|
||||
let _ = app.run(&fired.command.id, fired.command.params);
|
||||
}
|
||||
Stack::new().id_salt(("sorter-scope", uid)).command_scope(CommandScope::new("sorter")).fill().show(ui, |ui, cx| {
|
||||
let words = cx.words::<SorterWords>();
|
||||
cx.publish(EditCommands::SelectAll, CommandState::new().enabled(!keys.is_empty()));
|
||||
while let Some((command, fired)) = cx.take_command::<EditCommands>() {
|
||||
if command == EditCommands::SelectAll {
|
||||
let _ = app.run("edit.selectAll", json!({"scope": "slides"}));
|
||||
} else {
|
||||
let _ = app.run(&fired.command.id, fired.command.params);
|
||||
}
|
||||
if Button::new(words.add_section.clone()).show(ui).clicked() {
|
||||
let _ = app.run("section.add", json!({"at": cur}));
|
||||
}
|
||||
let make_grid = || {
|
||||
TileGrid::new(words.sorter.clone())
|
||||
.id_salt(("sorter", uid))
|
||||
.caption(CaptionPlace::Below)
|
||||
.detail_line()
|
||||
.groups(&heads)
|
||||
.group_heads(GroupHeads::Titled)
|
||||
.collapsible()
|
||||
.can_rename_groups()
|
||||
.can_move_groups()
|
||||
.reorder(ReorderRule::new())
|
||||
.aspect(aspect)
|
||||
}
|
||||
if Button::new(words.add_section.clone()).show(ui).clicked() {
|
||||
let _ = app.run("section.add", json!({"at": cur}));
|
||||
}
|
||||
let make_grid = || {
|
||||
TileGrid::new(words.sorter.clone())
|
||||
.id_salt(("sorter", uid))
|
||||
.caption(CaptionPlace::Below)
|
||||
.detail_line()
|
||||
.groups(&heads)
|
||||
.group_heads(GroupHeads::Titled)
|
||||
.collapsible()
|
||||
.can_rename_groups()
|
||||
.can_move_groups()
|
||||
.reorder(ReorderRule::new())
|
||||
.aspect(aspect)
|
||||
};
|
||||
let mut grid = make_grid()
|
||||
.zoom(GridZoom::Bound(Bind::bound(&mut zoom), TileZoom::bounded(0.5, 3.0, 0.1, 1.0)))
|
||||
.selection(Bind::given(selection.clone()));
|
||||
if let Some(key) = reveal {
|
||||
grid = grid.reveal(key);
|
||||
}
|
||||
let out = grid.show_items(ui, &source, &mut |key, _| {
|
||||
let label = match *key {
|
||||
Key::Slide(id) => doc.slide_index(id).map(|index| (index + 1).to_string()).unwrap_or_else(|| id.0.to_string()),
|
||||
Key::Section(index) => doc.sections.get(index).map(|section| section.name.clone()).unwrap_or_default(),
|
||||
};
|
||||
let mut grid = make_grid()
|
||||
.zoom(GridZoom::Bound(Bind::bound(&mut zoom), TileZoom::bounded(0.5, 3.0, 0.1, 1.0)))
|
||||
.selection(Bind::given(selection.clone()));
|
||||
if let Some(key) = reveal {
|
||||
grid = grid.reveal(key);
|
||||
}
|
||||
let out = grid.show_items(ui, &source, &mut |key, _| {
|
||||
let label = match *key {
|
||||
Key::Slide(id) => doc.slide_index(id).map(|index| (index + 1).to_string()).unwrap_or_else(|| id.0.to_string()),
|
||||
Key::Section(index) => doc.sections.get(index).map(|section| section.name.clone()).unwrap_or_default(),
|
||||
};
|
||||
let mut tile = Tile::new(label);
|
||||
if let Key::Slide(id) = *key
|
||||
&& let Some(index) = doc.slide_index(id)
|
||||
{
|
||||
let slide = &doc.slides[index];
|
||||
tile = tile.picture(
|
||||
ThumbAspect::from_ratio(aspect),
|
||||
thumb_source::picture(words.slide.fill(&[("number", &(index + 1).to_string())]), ThumbKey::Slide(id), &thumbs, &pictures),
|
||||
);
|
||||
if let Some(transition) = slide.transition.as_ref().filter(|transition| transition.kind != "none") {
|
||||
tile = tile.detail(words.transition.fill(&[("kind", &transition.kind)]));
|
||||
}
|
||||
if slide.hidden {
|
||||
tile = tile.hidden();
|
||||
}
|
||||
}
|
||||
tile
|
||||
});
|
||||
app.ui.sorter_zoom = zoom as f32;
|
||||
let opener = &out.response.response;
|
||||
if let Some(index) = app.sorter.renaming.take() {
|
||||
craft::ui::contract::request_rename(ui.ctx(), opener.id, &Key::Section(index));
|
||||
}
|
||||
// PLAN: plan error: panels-w2 must retain pointer GroupMenu requests in CollectionResponse::menu; grid.rs emits them outside the collection menu lifecycle.
|
||||
if let Some(request) = &out.response.menu {
|
||||
match request.key {
|
||||
Key::Slide(id) => crate::thumbs::slide_menu(ui, app, u64::from(id.0), opener),
|
||||
Key::Section(index) => section_menu(app, ui, index, opener, &words),
|
||||
let mut tile = Tile::new(label);
|
||||
if let Key::Slide(id) = *key
|
||||
&& let Some(index) = doc.slide_index(id)
|
||||
{
|
||||
let slide = &doc.slides[index];
|
||||
tile = tile.picture(
|
||||
ThumbAspect::from_ratio(aspect),
|
||||
thumb_source::picture(words.slide.fill(&[("number", &(index + 1).to_string())]), ThumbKey::Slide(id), &thumbs, &pictures),
|
||||
);
|
||||
if let Some(transition) = slide.transition.as_ref().filter(|transition| transition.kind != "none") {
|
||||
tile = tile.detail(words.transition.fill(&[("kind", &transition.kind)]));
|
||||
}
|
||||
}
|
||||
for event in out.response.events {
|
||||
match event {
|
||||
CollectionEvent::Selection { change, .. } => {
|
||||
selection.apply(change);
|
||||
select_slides(app, &doc, &selection);
|
||||
}
|
||||
CollectionEvent::Picked { key: Key::Slide(id), .. } => {
|
||||
let _ = app.run("slide.go", json!({"id": id.0}));
|
||||
}
|
||||
CollectionEvent::Activate(Key::Slide(id)) => {
|
||||
let _ = app.run("slide.go", json!({"id": id.0}));
|
||||
let _ = app.run("view.normal", json!({}));
|
||||
}
|
||||
CollectionEvent::Reorder(edit) => {
|
||||
if let Some(movement) = edit.value()
|
||||
&& let Some(movement) = make_grid().tile_reorder(&source, movement)
|
||||
{
|
||||
// In [hA,A,hB,B,C], A after C has outline to=4 and tile to=2.
|
||||
let ids: Vec<_> = movement
|
||||
.keys
|
||||
.iter()
|
||||
.filter_map(|key| match key {
|
||||
Key::Slide(id) => Some(id.0),
|
||||
Key::Section(_) => None,
|
||||
})
|
||||
.collect();
|
||||
let _ = app.run("slide.move", json!({"ids": ids, "to": movement.to}));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
for event in out.events {
|
||||
match event {
|
||||
GridEvent::GroupOpen { group, open } => {
|
||||
if let Some(Key::Section(index)) = heads.get(group).map(|head| head.key)
|
||||
&& let Some(first) = doc.sections[index].slides.first()
|
||||
{
|
||||
if open {
|
||||
app.sorter.collapsed.remove(&(uid, first.0));
|
||||
} else {
|
||||
app.sorter.collapsed.insert((uid, first.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
GridEvent::GroupRenamed { group, title, .. } => {
|
||||
if let Some(Key::Section(index)) = heads.get(group).map(|head| head.key) {
|
||||
let _ = app.run("section.rename", json!({"index": index, "name": title}));
|
||||
}
|
||||
}
|
||||
GridEvent::GroupMoved { group, to, .. } => {
|
||||
if let Some(Key::Section(index)) = heads.get(group).map(|head| head.key) {
|
||||
let _ = app.run("section.move", json!({"index": index, "to": to}));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
if slide.hidden {
|
||||
tile = tile.hidden();
|
||||
}
|
||||
}
|
||||
tile
|
||||
});
|
||||
app.ui.sorter_zoom = zoom as f32;
|
||||
let opener = &out.response.response;
|
||||
if let Some(index) = app.sorter.renaming.take() {
|
||||
craft::ui::contract::request_rename(ui.ctx(), opener.id, &Key::Section(index));
|
||||
}
|
||||
// PLAN: plan error: panels-w2 must retain pointer GroupMenu requests in CollectionResponse::menu; grid.rs emits them outside the collection menu lifecycle.
|
||||
if let Some(request) = &out.response.menu {
|
||||
match request.key {
|
||||
Key::Slide(id) => crate::thumbs::slide_menu(ui, app, u64::from(id.0), opener),
|
||||
Key::Section(index) => section_menu(app, ui, index, opener, &words),
|
||||
}
|
||||
}
|
||||
for event in out.response.events {
|
||||
match event {
|
||||
CollectionEvent::Selection { change, .. } => {
|
||||
selection.apply(change);
|
||||
select_slides(app, &doc, &selection);
|
||||
}
|
||||
CollectionEvent::Picked { key: Key::Slide(id), .. } => {
|
||||
let _ = app.run("slide.go", json!({"id": id.0}));
|
||||
}
|
||||
CollectionEvent::Activate(Key::Slide(id)) => {
|
||||
let _ = app.run("slide.go", json!({"id": id.0}));
|
||||
let _ = app.run("view.normal", json!({}));
|
||||
}
|
||||
CollectionEvent::Reorder(edit) => {
|
||||
if let Some(movement) = edit.value()
|
||||
&& let Some(movement) = make_grid().tile_reorder(&source, movement)
|
||||
{
|
||||
// In [hA,A,hB,B,C], A after C has outline to=4 and tile to=2.
|
||||
let ids: Vec<_> = movement
|
||||
.keys
|
||||
.iter()
|
||||
.filter_map(|key| match key {
|
||||
Key::Slide(id) => Some(id.0),
|
||||
Key::Section(_) => None,
|
||||
})
|
||||
.collect();
|
||||
let _ = app.run("slide.move", json!({"ids": ids, "to": movement.to}));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
for event in out.events {
|
||||
match event {
|
||||
GridEvent::GroupOpen { group, open } => {
|
||||
if let Some(Key::Section(index)) = heads.get(group).map(|head| head.key)
|
||||
&& let Some(first) = doc.sections[index].slides.first()
|
||||
{
|
||||
if open {
|
||||
app.sorter.collapsed.remove(&(uid, first.0));
|
||||
} else {
|
||||
app.sorter.collapsed.insert((uid, first.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
GridEvent::GroupRenamed { group, title, .. } => {
|
||||
if let Some(Key::Section(index)) = heads.get(group).map(|head| head.key) {
|
||||
let _ = app.run("section.rename", json!({"index": index, "name": title}));
|
||||
}
|
||||
}
|
||||
GridEvent::GroupMoved { group, to, .. } => {
|
||||
if let Some(Key::Section(index)) = heads.get(group).map(|head| head.key) {
|
||||
let _ = app.run("section.move", json!({"index": index, "to": to}));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn select_slides(app: &mut SlideApp, doc: &Presentation, selection: &Selection<Key>) {
|
||||
@@ -332,60 +330,54 @@ pub(crate) fn outline_body(app: &mut SlideApp, ui: &mut Ui, cx: &mut BodyCx<'_>)
|
||||
let Some(st) = app.session.active() else { return };
|
||||
let (uid, doc, current) = (st.uid, st.doc.clone(), st.selection.slide);
|
||||
let words = cx.words::<SorterWords>();
|
||||
Stack::new()
|
||||
.id_salt(("outline", uid))
|
||||
.surface(SurfaceKind::Panel)
|
||||
.pad(Pad::Regular)
|
||||
.scroll(Scroll::vertical())
|
||||
.fill()
|
||||
.show(ui, |ui, _| {
|
||||
for (index, slide) in doc.slides.iter().enumerate() {
|
||||
let title = slide.shapes.iter().find(|shape| shape.ph_type().is_some_and(|kind| kind.is_title()));
|
||||
let body: Vec<_> = slide
|
||||
.shapes
|
||||
.iter()
|
||||
.filter(|shape| !shape.ph_type().is_some_and(|kind| kind.is_title() || kind.is_footer_kind()))
|
||||
.filter(|shape| shape.text.as_ref().is_some_and(|text| !text.is_empty()))
|
||||
.collect();
|
||||
// PLAN: plan error: Lazy::new has no estimate-free form; the first extent of an unshown row has no framework value.
|
||||
let _ = Lazy::new(("outline", uid, slide.id.0), 0.0).show(ui, |ui| {
|
||||
Stack::new().fill_width().show(ui, |ui, _| {
|
||||
Row::new().fill_width().show(ui, |ui, _| {
|
||||
Text::new((index + 1).to_string()).show(ui);
|
||||
Picture::painter(Label::Empty, ThumbAspect::new(4, 3), |cx, rect| {
|
||||
cx.with_draw(|draw| {
|
||||
let shape = PaintShape::Rect(rect, CornerRadius::ZERO);
|
||||
if index == current {
|
||||
draw.fill(&shape, draw.role(|color| color.accent.solid));
|
||||
} else {
|
||||
draw.stroke(&shape, StrokeWidth::Thin, draw.role(|color| color.line.frame));
|
||||
}
|
||||
});
|
||||
})
|
||||
.show(ui);
|
||||
if let Some(title) = title {
|
||||
let text = title.text.as_ref().map(|text| text.text()).unwrap_or_default();
|
||||
// PLAN: plan error: TextField has no title type role or weight prop for the Outline title.
|
||||
outline_field(app, ui, (uid, title.id.0), index, &text, words.slide_title.clone(), false);
|
||||
}
|
||||
});
|
||||
Stack::new().indent(2).fill_width().show(ui, |ui, _| {
|
||||
for shape in &body {
|
||||
if let Some(text) = &shape.text {
|
||||
let text = text
|
||||
.paragraphs
|
||||
.iter()
|
||||
.map(|paragraph| format!("{}{}", "\t".repeat(paragraph.level as usize), paragraph.text()))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
outline_field(app, ui, (uid, shape.id.0), index, &text, words.slide_text.clone(), true);
|
||||
Stack::new().id_salt(("outline", uid)).surface(SurfaceKind::Panel).pad(Pad::Regular).scroll(Scroll::vertical()).fill().show(ui, |ui, _| {
|
||||
for (index, slide) in doc.slides.iter().enumerate() {
|
||||
let title = slide.shapes.iter().find(|shape| shape.ph_type().is_some_and(|kind| kind.is_title()));
|
||||
let body: Vec<_> = slide
|
||||
.shapes
|
||||
.iter()
|
||||
.filter(|shape| !shape.ph_type().is_some_and(|kind| kind.is_title() || kind.is_footer_kind()))
|
||||
.filter(|shape| shape.text.as_ref().is_some_and(|text| !text.is_empty()))
|
||||
.collect();
|
||||
// PLAN: plan error: Lazy::new has no estimate-free form; the first extent of an unshown row has no framework value.
|
||||
let _ = Lazy::new(("outline", uid, slide.id.0), 0.0).show(ui, |ui| {
|
||||
Stack::new().fill_width().show(ui, |ui, _| {
|
||||
Row::new().fill_width().show(ui, |ui, _| {
|
||||
Text::new((index + 1).to_string()).show(ui);
|
||||
Picture::painter(Label::Empty, ThumbAspect::new(4, 3), |cx, rect| {
|
||||
cx.with_draw(|draw| {
|
||||
let shape = PaintShape::Rect(rect, CornerRadius::ZERO);
|
||||
if index == current {
|
||||
draw.fill(&shape, draw.role(|color| color.accent.solid));
|
||||
} else {
|
||||
draw.stroke(&shape, StrokeWidth::Thin, draw.role(|color| color.line.frame));
|
||||
}
|
||||
});
|
||||
})
|
||||
.show(ui);
|
||||
if let Some(title) = title {
|
||||
let text = title.text.as_ref().map(|text| text.text()).unwrap_or_default();
|
||||
// PLAN: plan error: TextField has no title type role or weight prop for the Outline title.
|
||||
outline_field(app, ui, (uid, title.id.0), index, &text, words.slide_title.clone(), false);
|
||||
}
|
||||
});
|
||||
Stack::new().indent(2).fill_width().show(ui, |ui, _| {
|
||||
for shape in &body {
|
||||
if let Some(text) = &shape.text {
|
||||
let text = text
|
||||
.paragraphs
|
||||
.iter()
|
||||
.map(|paragraph| format!("{}{}", "\t".repeat(paragraph.level as usize), paragraph.text()))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
outline_field(app, ui, (uid, shape.id.0), index, &text, words.slide_text.clone(), true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn outline_field(app: &mut SlideApp, ui: &mut Ui, key: (u64, u32), slide: usize, text: &str, label: Label, multiline: bool) {
|
||||
|
||||
@@ -4,12 +4,7 @@ use crate::{Platform, Services, Session, SlideApp};
|
||||
|
||||
/// Builds the production window on its own context with isolated settings and file picks.
|
||||
pub(crate) fn harness(session: Session, services: Services) -> egui_kittest::Harness<'static, SlideApp> {
|
||||
harness_with(
|
||||
session,
|
||||
services,
|
||||
egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0),
|
||||
|_| {},
|
||||
)
|
||||
harness_with(session, services, egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0), |_| {})
|
||||
}
|
||||
|
||||
/// The production window with the trial's own frame body, for trials that wrap the window's pass
|
||||
|
||||
@@ -1403,7 +1403,14 @@ fn input_target_changes_retract_a_queued_click() {
|
||||
let arrow = h.get_by_label("Scroll right").rect().center();
|
||||
WindowHost::of(&ctx).inject_move(egui::ViewportId::ROOT, arrow, craft::keymap::Mods::default(), 0.0);
|
||||
}
|
||||
WindowHost::of(&ctx).inject_click(egui::ViewportId::ROOT, point, craft::behavior::PointerButton::Primary, 1, craft::keymap::Mods::default(), false);
|
||||
WindowHost::of(&ctx).inject_click(
|
||||
egui::ViewportId::ROOT,
|
||||
point,
|
||||
craft::behavior::PointerButton::Primary,
|
||||
1,
|
||||
craft::keymap::Mods::default(),
|
||||
false,
|
||||
);
|
||||
h.state_mut().note_injected(&ctx);
|
||||
match case {
|
||||
"show" | "show instance" => h.state_mut().start_show(0, true),
|
||||
@@ -1458,7 +1465,6 @@ fn input_target_changes_retract_a_queued_click() {
|
||||
h.state_mut().palette_open = false;
|
||||
h.state_mut().palette_state = Default::default();
|
||||
if crate::dialogs::modal_open(&ctx) {
|
||||
|
||||
crate::dialogs::control(h.state_mut(), &ctx, "ui.dialog.close", &json!({})).unwrap().unwrap();
|
||||
}
|
||||
h.state_mut().ui.tab = original_tab;
|
||||
|
||||
@@ -46,9 +46,10 @@ impl DeckThumbs {
|
||||
match *key {
|
||||
ThumbKey::Slide(id) => {
|
||||
let slide = self.doc.slides.iter().find(|slide| slide.id == id)?;
|
||||
let master = self.doc.master_for(slide).and_then(|(master, _)| {
|
||||
self.doc.masters.iter().find(|candidate| std::ptr::eq(candidate.as_ref(), master))
|
||||
});
|
||||
let master = self
|
||||
.doc
|
||||
.master_for(slide)
|
||||
.and_then(|(master, _)| self.doc.masters.iter().find(|candidate| std::ptr::eq(candidate.as_ref(), master)));
|
||||
Some(Inputs { slide: Some(slide), master })
|
||||
}
|
||||
ThumbKey::Layout { master, layout } => {
|
||||
@@ -71,12 +72,7 @@ impl ThumbSource<ThumbKey> for DeckThumbs {
|
||||
|
||||
fn revision(&self, key: &ThumbKey, _request: &ThumbRequest) -> Revision {
|
||||
let Some(Inputs { slide, master }) = self.inputs(key) else { return Revision::new(0) };
|
||||
Revision::of(&(
|
||||
key,
|
||||
slide.map(|slide| Arc::as_ptr(slide) as usize),
|
||||
master.map(|master| Arc::as_ptr(master) as usize),
|
||||
self.grayscale,
|
||||
))
|
||||
Revision::of(&(key, slide.map(|slide| Arc::as_ptr(slide) as usize), master.map(|master| Arc::as_ptr(master) as usize), self.grayscale))
|
||||
}
|
||||
|
||||
fn render(&self, key: &ThumbKey, request: &ThumbRequest) -> ThumbRender {
|
||||
|
||||
@@ -6,7 +6,6 @@ use deckcraft_engine::Session;
|
||||
use serde_json::json;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
||||
#[test]
|
||||
fn a_thumbnail_is_rendered_again_only_when_its_slide_or_master_changes() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut session = Session::with_new();
|
||||
|
||||
@@ -25,4 +25,3 @@ pub fn note_missing_fonts(app: &mut SlideApp) {
|
||||
app.notify(text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,13 +39,7 @@ fn dialog_method(h: &mut Harness<'_, SlideApp>, method: &str, params: serde_json
|
||||
}
|
||||
|
||||
fn dialog_fields(h: &Harness<'_, SlideApp>, key: &str) -> serde_json::Value {
|
||||
crate::control::inspect(h.state(), &h.ctx)["dialogs"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.find(|d| d["key"] == key)
|
||||
.unwrap()["fields"]
|
||||
.clone()
|
||||
crate::control::inspect(h.state(), &h.ctx)["dialogs"].as_array().unwrap().iter().find(|d| d["key"] == key).unwrap()["fields"].clone()
|
||||
}
|
||||
|
||||
fn selected_xfrm(app: &SlideApp) -> deckcraft_geom::Xfrm {
|
||||
@@ -161,10 +155,7 @@ fn ok_and_size(h: &mut Harness<'_, SlideApp>) -> (f64, f64) {
|
||||
/// be 960.09 pt; in inches 16:9, A4, B4 and B5 drift the same way).
|
||||
#[test]
|
||||
fn a_slide_size_preset_gives_its_exact_size() {
|
||||
for (units, label, size) in [
|
||||
(Unit::Centimeters, "Widescreen (16:9)", (960.0, 540.0)),
|
||||
(Unit::Inches, "A4 Paper (210x297 mm)", (780.0, 540.0)),
|
||||
] {
|
||||
for (units, label, size) in [(Unit::Centimeters, "Widescreen (16:9)", (960.0, 540.0)), (Unit::Inches, "A4 Paper (210x297 mm)", (780.0, 540.0))] {
|
||||
let mut h = slide_size_dialog(units, 720.0, 540.0);
|
||||
// PLAN: assumed preset: SLIDE_SIZES label (dialogs-w8)
|
||||
dialog_method(&mut h, "ui.dialog.set", json!({"dialog": "top", "field": "preset", "value": label}));
|
||||
|
||||
Reference in new issue
Block a user