diff --git a/crates/ui-egui/src/dialogs/preferences.rs b/crates/ui-egui/src/dialogs/preferences.rs index 9fe9d72fd..ee6840982 100644 --- a/crates/ui-egui/src/dialogs/preferences.rs +++ b/crates/ui-egui/src/dialogs/preferences.rs @@ -375,7 +375,8 @@ impl StackDialog for PreferencesDialog { if field == "uiScale" { self.scale_shown = self.draft.ui_scale; } - Ok(()) + // A setting set through automation applies live, as one changed in the window does. + self.apply() } } @@ -413,6 +414,7 @@ pub(crate) fn open_autocorrect(app: &mut SlideApp, ctx: &Context, host: &mut Dia /// Applies live settings and restores opening values for every external or window Cancel path. pub(crate) fn pump(app: &mut SlideApp, _ctx: &Context, host: &mut DialogHost) { for action in host.take_actions(dialog_id("preferences")) { + eprintln!("DIAG autocorrect_list_edits_survive_nested_and_preferences_cancel: action {action}"); match app.run("text.autocorrect", action) { Ok(reply) => { if let Some(form) = host.get_mut::().and_then(|dialog| dialog.autocorrect.as_mut()) { diff --git a/crates/ui-egui/src/reuse_picker_tests.rs b/crates/ui-egui/src/reuse_picker_tests.rs index b8c718a6a..d1e03c43a 100644 --- a/crates/ui-egui/src/reuse_picker_tests.rs +++ b/crates/ui-egui/src/reuse_picker_tests.rs @@ -56,8 +56,8 @@ fn open_dialog(h: &mut Harness<'_, SlideApp>) { } fn press_insert(h: &mut Harness<'_, SlideApp>, ticked: &[usize]) { - control(h, "ui.dialog.set", json!({"field": "ticked", "value": ticked})); - control(h, "ui.dialog.confirm", json!({})); + control(h, "ui.dialog.set", json!({"dialog": "top", "field": "ticked", "value": ticked})); + control(h, "ui.dialog.confirm", json!({"dialog": "top"})); h.run_steps(4); } diff --git a/crates/ui-egui/src/show/frames.rs b/crates/ui-egui/src/show/frames.rs index 670ddec74..4420c21a7 100644 --- a/crates/ui-egui/src/show/frames.rs +++ b/crates/ui-egui/src/show/frames.rs @@ -8,7 +8,6 @@ use craft::host::Wake; use craft::host::queue::{JobQueue, Priority, QueueOptions}; use craft::ui::primitives::{CachedTexture, ContentPainterCx, Revision, TextureStore, TextureStoreOptions, texture_side}; use egui::{Color32, ColorImage, Context, Rect, Vec2}; -use std::cell::Cell; use std::sync::Arc; use std::time::Duration; @@ -119,7 +118,7 @@ pub(crate) struct ShowFrames { current: Option<(FrameKey, CachedTexture)>, next: Option<(FrameKey, CachedTexture)>, prepared: Option, - shown: Cell>, + shown: Option, } /// Scheduling options for the independent frame, backdrop and preview queues. @@ -297,7 +296,7 @@ impl ShowFrames { /// The slide painted last, even after navigation selects its successor. pub(crate) fn shown_slide(&self) -> Option { - self.shown.get() + self.shown } /// The prepared current presenter picture. @@ -396,6 +395,7 @@ pub(crate) fn prepare( let wake = gifs.iter().filter(|gif| !gif.paused).map(|gif| gif.next).reduce(f64::min); if slide >= doc.slides.len() { show.frames.current = None; + show.frames.shown = None; show.frames.prepared = None; return wake; } @@ -446,6 +446,7 @@ pub(crate) fn prepare( put_frame(&store, ctx, frame_key.clone(), doc.clone(), image) }); show.frames.current = Some((frame_key, texture)); + show.frames.shown = Some(slide); if show.remote_opened && show.presenter && (rendered || changed || show.remote_preview.is_none()) { show.remote_preview = show.frames.current_source(ctx).and_then(|source| crate::presenter::Preview::from_image(&source.image)); } @@ -593,7 +594,6 @@ pub(crate) fn paint(frames: &ShowFrames, media: &MediaHost, doc: &Presentation, let image = |texture: CachedTexture| cx.painter.image(texture.id, rect, texture.uv(), Color32::WHITE); if let Some(texture) = texture(&FrameKey::Frame(frame.key.clone())) { image(texture); - frames.shown.set(Some(frame.key.slide)); } let mut shapes = vec![]; for (id, x, clip) in crate::media::slide_media(doc, frame.key.slide) { diff --git a/crates/ui-egui/src/show/tool.rs b/crates/ui-egui/src/show/tool.rs index 3e75afa0a..a342e399d 100644 --- a/crates/ui-egui/src/show/tool.rs +++ b/crates/ui-egui/src/show/tool.rs @@ -1,3 +1,4 @@ +use super::commands::{ShowCommands, ShowWindow, run_command}; use super::media::{Pick, Under, media_hit, shapes_under_pointer}; use super::{Blank, Click, LinkJump, Show, ShowZoomInputs}; use craft::behavior::kurbo::{Point, Size}; @@ -251,8 +252,31 @@ impl CanvasTool for ShowTool<'_> { } } - fn key(&mut self, _key: &ToolKey, _cx: &mut ToolContext<'_>) -> bool { - false + /// The canvas routes the arrows and Escape to its tool, not to the scope's shortcuts: they run the show + /// commands that bind them. + fn key(&mut self, key: &ToolKey, cx: &mut ToolContext<'_>) -> bool { + let command = match key { + ToolKey::Nudge { direction, mods, .. } if mods.is_none() => { + if direction.x > 0.0 || direction.y > 0.0 { + ShowCommands::Next + } else { + ShowCommands::Previous + } + } + ToolKey::Cancel => ShowCommands::Cancel, + _ => return false, + }; + let Some(space) = cx.space() else { return false }; + let scheme = space.zoom_scheme(); + let zoom = ShowZoomInputs { + size: Size::new(self.doc.slide_size.width, self.doc.slide_size.height), + pixels_per_point: space.pixels_per_point, + scheme: &scheme, + }; + let now = self.time(cx); + self.out.keep &= run_command(self.show, self.doc, now, command, ShowWindow::Audience, &zoom); + cx.request_repaint(); + true } fn takes_every_move(&self) -> bool { @@ -266,7 +290,7 @@ impl CanvasTool for ShowTool<'_> { fn cursor(&self, cx: &ToolContext<'_>) -> Cursor { let icon = if self.show.pen || self.show.zoom_arm || self.show.grid { CursorIcon::Crosshair - } else if self.show.laser || self.show.hides_idle_cursor(self.time(cx)) { + } else if self.show.laser { CursorIcon::None } else if self.under.as_ref().is_some_and(|under| under.pick.is_some()) { CursorIcon::PointingHand diff --git a/crates/ui-egui/src/show/ui.rs b/crates/ui-egui/src/show/ui.rs index 44bcc7b4f..3142fffc4 100644 --- a/crates/ui-egui/src/show/ui.rs +++ b/crates/ui-egui/src/show/ui.rs @@ -209,6 +209,10 @@ fn run_tool(ui: &mut Ui, show: &mut Show, p: &PagePass<'_>, out: &mut Out, pass: if let Some(view) = reply.view { show.view = view; } + // A still pointer hides over everything, links included; the pen's and the magnifier's crosshair stay. + if !show.pen && !show.zoom_arm && show.hides_idle_cursor(show.hold.unwrap_or(p.now)) { + pass.hide_pointer(ui); + } } fn publish(bcx: &mut BodyCx<'_>, show: &Show) {