diff --git a/crates/ui-egui/src/menus/menubar.rs b/crates/ui-egui/src/menus/menubar.rs index 45854bce66..672c7cbccc 100644 --- a/crates/ui-egui/src/menus/menubar.rs +++ b/crates/ui-egui/src/menus/menubar.rs @@ -200,7 +200,6 @@ const LAYOUT: &[(&str, &[&str])] = &[ "view.faceBoxes", "view.focusPoint", "view.zoomToFocus", - "view.reduceMotion", "view.filmstrip", "view.histogram", "view.navigator", @@ -409,7 +408,6 @@ pub fn checked(app: &LightcraftApp, id: &str) -> Option { "view.faceBoxes" => Some(u.face_boxes), "view.focusPoint" => Some(u.settings.focus_point), "view.zoomToFocus" => Some(u.settings.zoom_to_focus), - "view.reduceMotion" => Some(u.settings.reduce_motion), "view.filmstrip" => Some(u.filmstrip), "view.frameRate" => Some(u.frame_rate), "view.histogram" => Some(u.histogram), diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 7e322dddaa..cc0b73d879 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -75,7 +75,7 @@ pub const UI_COMMANDS: &[UiCommand] = &[ ("view.faceBoxes", "Face Boxes", None, "View"), ("view.focusPoint", "Focus Point", Some("Alt+F"), "View"), ("view.zoomToFocus", "Zoom to Focus Point", None, "View"), - ("view.reduceMotion", "Reduce Motion", None, "View"), + ("view.reduceMotion", "Reduce Motion", None, ""), ("view.reference", "Reference View", Some("Shift+R"), "View"), ("photo.setReference", "Set as Reference Photo", None, ""), ("compare.swap", "Swap Compare Photos", None, "View"), diff --git a/crates/ui-egui/src/motion.rs b/crates/ui-egui/src/motion.rs index c2564f6b54..d01c4d30e7 100644 --- a/crates/ui-egui/src/motion.rs +++ b/crates/ui-egui/src/motion.rs @@ -7,7 +7,7 @@ //! [`LightcraftApp::sync_theme`](crate::LightcraftApp::sync_theme) stores the setting in the egui //! context every frame ([`sync`]), so drawing code needs only the `Context`, not the app. -use egui::{Context, Id, Sense, Ui, vec2}; +use egui::{Context, Id}; /// egui's widget easing time when motion is on. const ANIMATION_TIME: f32 = 0.08; @@ -42,15 +42,3 @@ pub fn animation_time(reduced: bool) -> f32 { pub fn zoom_tween_seconds(ctx: &Context) -> f32 { if reduced(ctx) { 0.0 } else { ZOOM_TWEEN_SECONDS } } - -/// A "working" indicator: egui's turning spinner, or with reduced motion a still dot of the same size -/// (so the layout doesn't move). -pub fn spinner(ui: &mut Ui) { - if !reduced(ui.ctx()) { - ui.spinner(); - return; - } - let side = ui.spacing().interact_size.y; - let (rect, _) = ui.allocate_exact_size(vec2(side, side), Sense::hover()); - ui.painter().circle_filled(rect.center(), side * 0.18, ui.visuals().text_color()); -} diff --git a/crates/ui-egui/src/panels/activity.rs b/crates/ui-egui/src/panels/activity.rs index 1a92c79922..c8398ca5c8 100644 --- a/crates/ui-egui/src/panels/activity.rs +++ b/crates/ui-egui/src/panels/activity.rs @@ -147,23 +147,10 @@ fn row(ui: &mut egui::Ui, t: &Tokens, task: &TaskInfo, width: f32) -> bool { } /// The progress bar, named after its task for screen readers; while the amount of work isn't -/// known, a segment sweeps across. +/// known, a segment sweeps across (it stands still with Reduce motion on). pub(crate) fn bar(ui: &mut egui::Ui, task: &TaskInfo, width: f32) -> egui::Response { let fraction = (task.total > 0).then(|| (task.done as f64 / task.total as f64) as f32); let response = crate::progress::Progress::new(fraction).width(width).dimmed(task.cancelling).show(ui); crate::widgets::screen_reader_name(ui.ctx(), response.id, tr(&task.label)); response } - -/// The progress bar; while the amount of work isn't known, a segment sweeps across. -/// The sweeping segment of an indeterminate bar, as offsets from the bar's left edge. Reduced motion -/// leaves a still segment (a quarter of the bar, at its left end) that says "working" without moving. -pub(crate) fn indeterminate_span(width: f32, time: f64, reduced: bool) -> (f32, f32) { - if reduced { - return (0.0, width * 0.25); - } - let phase = (time * 0.7).fract() as f32; - let w = width * 0.3; - let x = (width + w) * phase - w; - (x.max(0.0), (x + w).min(width)) -} diff --git a/crates/ui-egui/src/tests/reduce_motion.rs b/crates/ui-egui/src/tests/reduce_motion.rs index e684ecc6b9..1aa3e97930 100644 --- a/crates/ui-egui/src/tests/reduce_motion.rs +++ b/crates/ui-egui/src/tests/reduce_motion.rs @@ -115,10 +115,10 @@ fn egui_easing_stops_with_reduce_motion_on_and_returns_when_off() { #[test] fn the_activity_bar_stands_still_with_reduce_motion_on() { - use crate::panels::activity::indeterminate_span; - let still: Vec<_> = (0..120).map(|f| indeterminate_span(200.0, f as f64 / 60.0, true)).collect(); + use crate::progress::sweep_span; + let still: Vec<_> = (0..120).map(|f| sweep_span(200.0, f as f64 / 60.0, true)).collect(); assert!(still.windows(2).all(|w| w[0] == w[1]), "no movement between frames"); assert!(still[0].1 > still[0].0, "but something is shown"); - let moving: Vec<_> = (0..120).map(|f| indeterminate_span(200.0, f as f64 / 60.0, false)).collect(); + let moving: Vec<_> = (0..120).map(|f| sweep_span(200.0, f as f64 / 60.0, false)).collect(); assert!(moving.windows(2).any(|w| w[0] != w[1]), "it sweeps when motion is on"); } diff --git a/crates/ui-egui/src/widgets/button.rs b/crates/ui-egui/src/widgets/button.rs index d3fa988219..aa94ff7647 100644 --- a/crates/ui-egui/src/widgets/button.rs +++ b/crates/ui-egui/src/widgets/button.rs @@ -404,8 +404,11 @@ impl<'a> Button<'a> { let slot_rect = Rect::from_center_size(pos2(x + slot / 2.0, rect.center().y), vec2(slot, slot)); if self.busy { if ui.is_rect_visible(rect) { - crate::progress::paint_spinner(p, slot_rect, lk.content, ui.input(|i| i.time)); - ui.ctx().request_repaint_after(std::time::Duration::from_millis(33)); + let reduced = crate::motion::reduced(ui.ctx()); + crate::progress::paint_spinner(p, slot_rect, lk.content, ui.input(|i| i.time), reduced); + if !reduced { + ui.ctx().request_repaint_after(std::time::Duration::from_millis(33)); + } } } else if let Some(icon) = self.icon { paint(p, slot_rect, icon, lk.content); diff --git a/crates/ui-egui/src/widgets/progress.rs b/crates/ui-egui/src/widgets/progress.rs index ab7ba9603d..b34a4180b1 100644 --- a/crates/ui-egui/src/widgets/progress.rs +++ b/crates/ui-egui/src/widgets/progress.rs @@ -9,8 +9,9 @@ //! ``` //! //! A bar announces itself to screen readers as a progress indicator with its percentage. Motion -//! asks for repaints only while it is on screen. There is no reduced-motion setting in the app, -//! so the motion is kept slow and small: one gentle sweep, one slow turning arc. +//! asks for repaints only while it is on screen. The motion is kept slow and small (one gentle +//! sweep, one slow turning arc), and with Settings ▸ Interface ▸ Reduce motion on ([`crate::motion`]) +//! it stands still: the sweeping segment stays at the bar's left end and the arc becomes a dot. use std::f32::consts::TAU; @@ -129,13 +130,14 @@ impl Progress { let fill = match self.fraction { Some(f) => Rect::from_min_size(inner.min, vec2(inner.width() * f, inner.height())), None => { - // a short bar sweeping across and back, eased so it slows at the ends - let phase = (ui.input(|i| i.time) / SWEEP_SECONDS).fract() as f32; - let eased = 0.5 - 0.5 * (phase * TAU).cos(); - let len = inner.width() * 0.3; - let x = inner.left() + (inner.width() - len) * eased; - ui.ctx().request_repaint_after(FRAME); - Rect::from_min_size(pos2(x, inner.top()), vec2(len, inner.height())) + // a short bar sweeping across and back, eased so it slows at the ends (still when + // motion is reduced) + let reduced = crate::motion::reduced(ui.ctx()); + let (x, len) = sweep_span(inner.width(), ui.input(|i| i.time), reduced); + if !reduced { + ui.ctx().request_repaint_after(FRAME); + } + Rect::from_min_size(pos2(inner.left() + x, inner.top()), vec2(len, inner.height())) } }; if fill.width() > 0.0 { @@ -155,6 +157,18 @@ impl Progress { } } +/// The sweeping segment of an indeterminate bar `width` wide at `time` seconds: its offset from the +/// bar's left edge and its length. With reduced motion it stands at the left end. +pub(crate) fn sweep_span(width: f32, time: f64, reduced: bool) -> (f32, f32) { + let len = width * 0.3; + if reduced { + return (0.0, len); + } + let phase = (time / SWEEP_SECONDS).fract() as f32; + let eased = 0.5 - 0.5 * (phase * TAU).cos(); + ((width - len) * eased, len) +} + /// The arc a spinner draws at `time` seconds: points on a circle of `radius` around `center`, /// covering three quarters of the turn and rotating once per [`TURN_SECONDS`]. fn arc_points(center: Pos2, radius: f32, time: f64) -> Vec { @@ -168,10 +182,15 @@ fn arc_points(center: Pos2, radius: f32, time: f64) -> Vec { .collect() } -/// Draw a spinner of `size` points centred in `rect`, in `color`, at `time` seconds. Callers that -/// draw by hand (a busy button) use this; it asks for no repaint itself. -pub fn paint_spinner(p: &egui::Painter, rect: Rect, color: Color32, time: f64) { +/// Draw a spinner of `size` points centred in `rect`, in `color`, at `time` seconds; with `reduced` +/// motion a still dot of the same room. Callers that draw by hand (a busy button) use this; it asks +/// for no repaint itself. +pub fn paint_spinner(p: &egui::Painter, rect: Rect, color: Color32, time: f64, reduced: bool) { let size = rect.width().min(rect.height()); + if reduced { + p.circle_filled(rect.center(), size * 0.18, color); + return; + } let width = (size / 8.0).max(1.5); let radius = ((size - width) / 2.0).max(0.5); p.add(Shape::line(arc_points(rect.center(), radius, time), Stroke::new(width, color))); @@ -184,8 +203,11 @@ pub fn spinner(ui: &mut Ui, size: f32) -> Response { let (rect, resp) = ui.allocate_exact_size(vec2(size, size), Sense::hover()); resp.widget_info(|| egui::WidgetInfo::new(egui::Role::ProgressIndicator)); if ui.is_rect_visible(rect) { - paint_spinner(ui.painter(), rect, t.text_dim, ui.input(|i| i.time)); - ui.ctx().request_repaint_after(FRAME); + let reduced = crate::motion::reduced(ui.ctx()); + paint_spinner(ui.painter(), rect, t.text_dim, ui.input(|i| i.time), reduced); + if !reduced { + ui.ctx().request_repaint_after(FRAME); + } } resp } diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 15b8e78cc3..f9618a36bf 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -479,7 +479,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-BEHAV-TOOLTIPS | Tooltips with shortcuts | P0 | ✅ | `crates/ui-egui/src/panels/bottombar.rs` | | | LR-BEHAV-TEXTFIELD | Text fields behave alike | P1 | 🟡 | `crates/ui-egui/src/widgets/text_field.rs`, `crates/ui-egui/src/panels/topbar.rs`, `crates/ui-egui/src/widgets.rs`, `crates/ui-egui/src/panels/right.rs` (`meta_field`), `crates/ui-egui/src/dialogs.rs`, `crates/ui-egui/src/panels/unnamed.rs` | one shared field: right-click Cut / Copy / Paste / Select All (no Paste in the browser), Esc gives back the text from before the edit, Return / leaving / Esc reported to the caller, optional select-on-focus; agents use `ui.clipboard` (MCP `clipboard`) and `ui.inspect` → `copied`. Used by Search Photos, slider values, the Info panel's metadata fields (multi-line captions), the one-field dialogs (New / Rename Album, New Smart Album, Rename / Merge Keywords, text prompts) and the unnamed faces' name field so far; the other text fields (most dialogs, import, settings, masking, keywords …) still use egui's own and have no menu | | LR-BEHAV-HEADLESS | Headless UI snapshots | P2 | ✅ | `apps/lightcraft-cli/src/main.rs`, `crates/ui-egui/src/headless.rs`, `docs/control-protocol.md` | `snapshot` rasterizes the UI and defaults photo development to the CPU before the first frame, without adapter discovery; scaled dimensions are validated before allocation, and UI zoom preserves the requested physical viewport; JSON-lines control scripts are supported | -| LR-BEHAV-ACCESS | Accessibility | P2 | 🟡 | `crates/ui-egui/src/widgets.rs`, `crates/ui-egui/src/widgets/text_field.rs`, `crates/ui-egui/src/panels/grid.rs`, `crates/ui-egui/tests/it/accessibility.rs` | AccessKit (VoiceOver / Narrator / AT-SPI): sliders announce control, value, range and step and take Increment / Decrement (the value field beside each is named ` value` and describes how to type or drag), buttons / icon buttons / dropdowns / section headers / sources their labels and state, text fields their caption, grid thumbnails file name, rating, flag and label. `tests/it/accessibility.rs` fails on an unnamed control, a slider without range or an untitled dialog in every view, Develop tool and 13 dialogs, and checks that Crop and Remove sliders are reached with Tab and that Tab walks the right panels top to bottom. Canvas tools by keyboard (`crates/ui-egui/src/canvas_keys.rs`, `crates/ui-egui/src/tests/canvas_keys.rs`): crop corners, edges and box, spot targets and sources, a New spot point (Return adds), radial / linear gradient handles and mask pins take the focus, are announced with their position and move with the arrows (Shift: further). Dialogs with one name field (New Album, New Smart Album, Save Metadata Preset, the renames) take the focus once when they open, so Tab and Shift+Tab reach their check box, Cancel and OK, and Return and Esc still confirm and cancel (`crates/ui-egui/src/tests/dialog_tab.rs`). The photo in Detail is named like its grid cell, `Photo: , , ,