Show: the frame shown is the prepared one, an idle pointer hides over everything, arrows and Escape run show commands; Preferences set through automation applies live; reuse picker test names its dialog

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. Taylor
2026-11-27 18:03:56 +00:00
co-authored by Claude Opus 5.5
parent cdedef1429
commit a53e165daf
5 changed files with 40 additions and 10 deletions
+3 -1
View File
@@ -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::<PreferencesDialog>().and_then(|dialog| dialog.autocorrect.as_mut()) {
+2 -2
View File
@@ -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);
}
+4 -4
View File
@@ -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<PaintFrame>,
shown: Cell<Option<usize>>,
shown: Option<usize>,
}
/// 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<usize> {
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) {
+27 -3
View File
@@ -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
+4
View File
@@ -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) {