From 53f09d3d8448a4dcb08ba369c8dc6f4cef47b6b8 Mon Sep 17 00:00:00 2001 From: astar76 Date: Wed, 25 Nov 2026 22:53:25 -0600 Subject: [PATCH] S034: motion and look pass: drop overlay fade, queue card glide, rules empty state and copy, test file Co-Authored-By: Claude Opus 5.5 --- .../08 Motion and polish/S034-motion-audit.md | 14 +++--- Plans/INDEX.md | 2 +- crates/app/src/drop.rs | 19 +++++--- crates/app/src/views/queues.rs | 27 +++++++++--- crates/app/src/views/rules.rs | 17 +++++--- crates/app/src/views/target.rs | 5 ++- crates/core/lang/en.json | 1 + docs/PROGRESS.md | 4 ++ docs/tests/S034-motion-audit.md | 43 +++++++++++++++++++ 9 files changed, 105 insertions(+), 27 deletions(-) create mode 100644 docs/tests/S034-motion-audit.md diff --git a/Plans/08 Motion and polish/S034-motion-audit.md b/Plans/08 Motion and polish/S034-motion-audit.md index f190f87..dcc4446 100644 --- a/Plans/08 Motion and polish/S034-motion-audit.md +++ b/Plans/08 Motion and polish/S034-motion-audit.md @@ -11,13 +11,13 @@ One look and feel, and motion that earns its place (D-008, FEATURES 9.7). Was S0 - crates/app/src/{motion,tokens}*, then the views by `rg` hits only ## Steps -- [ ] One list of faults across all screens, by leverage: motion, edges, grid, radii, sizes, states, copy, focus; drop what is by design -- [ ] Fix every high and medium motion fault -- [ ] Fix every high and medium look fault; no literal colours or radii outside tokens -- [ ] Hide every setting, menu entry and tab of a feature that is Later (PLAN.md), so nothing on screen does nothing -- [ ] Copy, empty states, AccessKit names, focus and 32 px hit targets -- [ ] Test file `docs/tests/S034-motion-audit.md`: each fixed motion with normal, reduced and off; keyboard only; sizes 480, 900, 1600, 3440; light, dark, AMOLED; long names and big numbers -- [ ] `docs/PROGRESS.md` entry, tick `Plans/INDEX.md`, commit `S034: …`, push +- [x] One list of faults across all screens, by leverage: motion, edges, grid, radii, sizes, states, copy, focus; drop what is by design +- [x] Fix every high and medium motion fault +- [x] Fix every high and medium look fault; no literal colours or radii outside tokens +- [x] Hide every setting, menu entry and tab of a feature that is Later (PLAN.md), so nothing on screen does nothing +- [x] Copy, empty states, AccessKit names, focus and 32 px hit targets +- [x] Test file `docs/tests/S034-motion-audit.md`: each fixed motion with normal, reduced and off; keyboard only; sizes 480, 900, 1600, 3440; light, dark, AMOLED; long names and big numbers +- [x] `docs/PROGRESS.md` entry, tick `Plans/INDEX.md`, commit `S034: …`, push ## End criteria `nice cargo check -q -j 2 -p medlar` clean diff --git a/Plans/INDEX.md b/Plans/INDEX.md index 2ce84d1..0700b27 100644 --- a/Plans/INDEX.md +++ b/Plans/INDEX.md @@ -53,7 +53,7 @@ Tracker: https://claude.ai/artifact/XouimfVJS6FYVKskGJ8s7H ## 08 Motion and polish -- [ ] [S034](08%20Motion%20and%20polish/S034-motion-audit.md) Motion and look pass +- [x] [S034](08%20Motion%20and%20polish/S034-motion-audit.md) Motion and look pass ## 09 Test and release diff --git a/crates/app/src/drop.rs b/crates/app/src/drop.rs index 355517e..558956f 100644 --- a/crates/app/src/drop.rs +++ b/crates/app/src/drop.rs @@ -4,7 +4,7 @@ use crate::fonts; use crate::theme::{Theme, alpha}; -use crate::tokens::{radius, space, text}; +use crate::tokens::{radius, size, space, spring, text}; use crate::views::add::Request; use crate::ui::widgets::cr; use eframe::egui::{Align2, Context, Id, LayerId, Order, Stroke, StrokeKind}; @@ -41,16 +41,21 @@ pub fn hovering(ctx: &Context) -> bool { ctx.input(|i| !i.raw.hovered_files.is_empty()) } -/// The full-window state: the window dims, a dashed-looking frame and a line say what happens. +/// How much the window dims under the drop state. +const DIM: f32 = 0.86; + +/// The full-window state: the window dims, a frame and a line say what happens. It fades in and out. pub fn overlay(ctx: &Context, t: &Theme) { - if !hovering(ctx) { + let shown = crate::motion::spring(id().with("shown"), f32::from(hovering(ctx)), spring::EFFECT).clamp(0.0, 1.0); + if shown <= 0.0 { return; } let rect = ctx.content_rect(); let p = ctx.layer_painter(LayerId::new(Order::Foreground, id())); - p.rect_filled(rect, 0.0, alpha(t.surface, 0.86)); + p.rect_filled(rect, 0.0, alpha(t.surface, DIM * shown)); let frame = rect.shrink(space::L); - p.rect_stroke(frame, cr(radius::L), Stroke::new(3.0, t.primary), StrokeKind::Inside); - p.text(frame.center(), Align2::CENTER_CENTER, tr!("drop.here"), fonts::med(text::TITLE), t.on_surface); - p.text(frame.center() + eframe::egui::vec2(0.0, 30.0), Align2::CENTER_CENTER, tr!("drop.what"), fonts::ui(text::BODY), t.on_variant); + p.rect_stroke(frame, cr(radius::L), Stroke::new(size::FOCUS_RING, alpha(t.primary, shown)), StrokeKind::Inside); + p.text(frame.center(), Align2::CENTER_CENTER, tr!("drop.here"), fonts::med(text::TITLE), alpha(t.on_surface, shown)); + let below = frame.center() + eframe::egui::vec2(0.0, text::TITLE + space::M); + p.text(below, Align2::CENTER_CENTER, tr!("drop.what"), fonts::ui(text::BODY), alpha(t.on_variant, shown)); } diff --git a/crates/app/src/views/queues.rs b/crates/app/src/views/queues.rs index c96a78a..3c9b0ce 100644 --- a/crates/app/src/views/queues.rs +++ b/crates/app/src/views/queues.rs @@ -4,12 +4,14 @@ use super::list::model::queue_name; use super::schedule::{self, Level}; use crate::bridge::{Bridge, Lists}; use crate::fonts; -use crate::theme::Theme; +use crate::theme::{Theme, mix}; use crate::tokens::{radius, size, space, text}; use crate::ui::field::{Field, Number}; use crate::ui::widgets::{Button, Choice, Kind, cr, left, line}; use crate::icons; -use eframe::egui::{Layout, Align, Id, Rect, RichText, Sense, Ui, UiBuilder, pos2, vec2}; +use crate::motion::{self, spring, spring_from}; +use crate::tokens::spring::{DEFAULT, EFFECT}; +use eframe::egui::{CursorIcon, Layout, Align, Id, Rect, RichText, Sense, Ui, UiBuilder, pos2, vec2}; use medlar_core::manager::Command; use medlar_core::model::{MAIN_QUEUE, Queue, QueueId, State, TaskId}; use medlar_core::snapshot::Snapshot; @@ -69,11 +71,22 @@ impl Page { let width = ui.available_width(); let mut cards = vec![]; let mut released = None; + // Places are measured from the top of the list, so scrolling moves cards 1:1 and only a new order glides. + let top = ui.cursor().top(); for (i, q) in order.iter().enumerate() { let (slot, _) = ui.allocate_exact_size(vec2(width, CARD), Sense::hover()); ui.add_space(space::S); - let pulled = self.grab.filter(|(id, _)| *id == q.id).map_or(0.0, |(_, dy)| dy); - let rect = slot.translate(vec2(0.0, pulled)); + let key = ("queue card", q.id); + let y = match self.grab.filter(|(id, _)| *id == q.id) { + // In hand: under the pointer, and the spring starts from here when it is let go. + Some((_, dy)) => { + motion::forget(key); + let y = slot.top() - top + dy; + spring_from(key, y, y, DEFAULT) + } + None => spring(key, slot.top() - top, DEFAULT), + }; + let rect = slot.translate(vec2(0.0, y + top - slot.top())); cards.push(rect); let n = totals(shot, q.id); let mut moved = None; @@ -115,11 +128,15 @@ impl Page { #[allow(clippy::too_many_arguments)] fn card(&mut self, ui: &mut Ui, t: &Theme, rect: Rect, q: &Queue, lists: &Lists, n: Totals, i: usize, count: usize, selected: &[TaskId], bridge: &Bridge, moved: &mut Option, released: &mut Option) { let held = self.grab.is_some_and(|(id, _)| id == q.id); - ui.painter().rect_filled(rect, cr(radius::L), if held { t.highest } else { t.container }); + let lift = spring(("queue lift", q.id), f32::from(held), EFFECT); + ui.painter().rect_filled(rect, cr(radius::L), mix(t.container, t.highest, lift)); let inner = rect.shrink(space::M); let handle = Rect::from_min_size(inner.min, vec2(size::HIT, size::HIT)); let r = ui.interact(handle, Id::unique(("queue handle", q.id)), Sense::drag()); icons::paint(ui.painter(), handle.center(), crate::tokens::icon::M, "drag_indicator", t.on_variant); + if r.hovered() || r.dragged() { + ui.ctx().set_cursor_icon(if r.dragged() { CursorIcon::Grabbing } else { CursorIcon::Grab }); + } if r.dragged() { let dy = self.grab.filter(|(id, _)| *id == q.id).map_or(0.0, |(_, d)| d) + r.drag_delta().y; self.grab = Some((q.id, dy)); diff --git a/crates/app/src/views/rules.rs b/crates/app/src/views/rules.rs index b8cbe40..def7912 100644 --- a/crates/app/src/views/rules.rs +++ b/crates/app/src/views/rules.rs @@ -143,18 +143,22 @@ pub fn list(view: &mut View, cx: &mut Cx, ui: &mut Ui) { let mut moved: Option<(usize, i32)> = None; let mut gone = None; let mut flip = None; + if cx.s.rules.is_empty() { + ui.label(RichText::new(tr!("rule.none")).font(fonts::ui(text::BODY)).color(t.on_variant)); + ui.add_space(space::S); + } for (i, r) in cx.s.rules.iter().enumerate() { - let (rect, resp) = plate(ui, t, ROW, &tr!("rule.change", rule = r.name)); + let name = if r.name.is_empty() { tr!("rule.unnamed") } else { r.name.clone() }; + let (rect, resp) = plate(ui, t, ROW, &tr!("rule.change", rule = name)); let p = ui.painter(); let x = rect.left() + space::M; icons::paint(p, pos2(x + icon::M / 2.0, rect.center().y), icon::M, if r.enabled { "check_circle" } else { "visibility_off" }, t.on_variant); let x = x + icon::M + space::M; let room = rect.right() - x - 4.0 * size::HIT - space::M; - let name = if r.name.is_empty() { tr!("rule.unnamed") } else { r.name.clone() }; left(p, pos2(x, rect.center().y - 9.0), line(p, &name, fonts::med(text::BODY), if r.enabled { t.on_surface } else { t.on_variant }, room)); left(p, pos2(x, rect.center().y + 10.0), line(p, &summary(r, &lists), fonts::ui(text::LABEL), t.on_variant, room)); let mut hit = true; - for (k, (icon, label)) in [("delete", tr!("rule.remove", rule = r.name)), ("arrow_downward", tr!("rule.down", rule = r.name)), ("arrow_upward", tr!("rule.up", rule = r.name)), (if r.enabled { "visibility" } else { "visibility_off" }, tr!("rule.toggle", rule = r.name))].into_iter().enumerate() { + for (k, (icon, label)) in [("delete", tr!("rule.remove", rule = name)), ("arrow_downward", tr!("rule.down", rule = name)), ("arrow_upward", tr!("rule.up", rule = name)), (if r.enabled { "visibility" } else { "visibility_off" }, tr!("rule.toggle", rule = name))].into_iter().enumerate() { let place = Rect::from_center_size(pos2(rect.right() - space::S - size::HIT * (k as f32 + 0.5), rect.center().y), Vec2::splat(size::HIT)); let mut child = ui.new_child(UiBuilder::new().max_rect(place).id_salt(("rule button", i, k))); if small(&mut child, t, icon, &label) { @@ -183,7 +187,8 @@ pub fn list(view: &mut View, cx: &mut Cx, ui: &mut Ui) { if let Some(i) = gone { let before = cx.s.clone(); let r = cx.s.rules.remove(i); - cx.toasts.undo("delete", tr!("rule.removed", rule = r.name), crate::views::main::Reply::Settings(Box::new(before))); + let name = if r.name.is_empty() { tr!("rule.unnamed") } else { r.name }; + cx.toasts.undo("delete", tr!("rule.removed", rule = name), crate::views::main::Reply::Settings(Box::new(before))); } ui.horizontal(|ui| { if Button::new(&tr!("rule.add")).with_icon("add").kind(Kind::Tonal).show(ui, t).clicked() { @@ -264,9 +269,9 @@ impl State { let (both, _) = ui.allocate_exact_size(vec2(ui.available_width(), NUMBER), Sense::hover()); let mut half = |x: f32, salt: &str| ui.new_child(UiBuilder::new().max_rect(Rect::from_min_size(pos2(x, both.top()), vec2(side, NUMBER))).id_salt(salt)); let mut first = half(both.left(), "min"); - Number { label: &tr!("rule.min"), unit: "MB", range: 0.0..=1_000_000.0, step: 1.0, enabled: true, width: side, bare: false }.show(&mut first, t, &mut e.min); + Number { label: &tr!("rule.min"), unit: &tr!("unit.mb_short"), range: 0.0..=1_000_000.0, step: 1.0, enabled: true, width: side, bare: false }.show(&mut first, t, &mut e.min); let mut second = half(both.right() - side, "max"); - Number { label: &tr!("rule.max"), unit: "MB", range: 0.0..=1_000_000.0, step: 1.0, enabled: true, width: side, bare: false }.show(&mut second, t, &mut e.max); + Number { label: &tr!("rule.max"), unit: &tr!("unit.mb_short"), range: 0.0..=1_000_000.0, step: 1.0, enabled: true, width: side, bare: false }.show(&mut second, t, &mut e.max); Field::new(&tr!("rule.pattern")).hint("*-setup-*.exe").show(ui, t, &mut e.pattern); Field::new(&tr!("rule.folder")).hint("Video").help(&tr!("rule.folder_help")).error(bad_folder.as_deref()).show(ui, t, &mut e.folder); ui.horizontal_top(|ui| { diff --git a/crates/app/src/views/target.rs b/crates/app/src/views/target.rs index d0d265b..9ac2613 100644 --- a/crates/app/src/views/target.rs +++ b/crates/app/src/views/target.rs @@ -19,6 +19,9 @@ use medlar_core::tr; const RING: f32 = 84.0; const SMALL: f32 = 112.0; +/// The window: the ring and its speed line, and with the menu open room for three text buttons. +const CLOSED: [f32; 2] = [SMALL, SMALL + space::XL - space::XS]; +const OPEN: [f32; 2] = [SMALL + space::XXL + space::XL + space::XS, SMALL + 3.0 * size::CONTROL]; #[derive(Default)] pub struct Target { @@ -43,7 +46,7 @@ impl Target { self.menu = false; return; } - let big = if self.menu { vec2(SMALL + 60.0, SMALL + 120.0) } else { vec2(SMALL, SMALL + 20.0) }; + let big = if self.menu { OPEN.into() } else { CLOSED.into() }; let builder = ViewportBuilder::default() .with_title("Medlar") .with_app_id(crate::app::APP_ID) diff --git a/crates/core/lang/en.json b/crates/core/lang/en.json index c7aea58..b39e109 100644 --- a/crates/core/lang/en.json +++ b/crates/core/lang/en.json @@ -519,6 +519,7 @@ "rule.down": "Move {rule} down", "rule.toggle": "Turn {rule} on or off", "rule.unnamed": "Rule without a name", + "rule.none": "No rules yet. A rule picks the folder, queue, priority and tags for downloads that fit it. Add one, or add the set by type.", "rule.any": "Any download", "rule.off": "Off", "rule.keep": "Leave as it is", diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 4c2ebe3..068a4cc 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -231,3 +231,7 @@ Seen: boxes were ticked together after the tests, against rule 3. ## S033 — Tray, notifications, autostart (compiled, not tested) - `app::{shell,tray,notify,launcher,autostart}`: `Shell` (in `App`) feeds ksni tray (ring icon, speed tooltip, mode/pause/resume/add/show/quit), notifications (Watcher diffs snapshots; summaries over 3; quiet hours; actions open/folder/continue/retry via zbus), Unity launcher signal, autostart file (`--minimised`). New settings: tray, close_to_tray, start_minimised, autostart, notify, quiet*. Close-to-tray only with a tray host. Did not reuse `views/target.rs`. `assets/medlar.metainfo.xml`, `tools/validate-desktop.sh` (appstreamcli warns: homepage). - Not done: no settings page rows for the new settings; hidden-window redraw on Wayland unverified; fake-bus tests not written (`docs/tests/S033-tray-notify.md`). + +## S034 — Motion and look pass (compiled, not tested) +- Audit by `rg`: springs and colours all from tokens, no Later feature on screen. Fixed: drop overlay fades (EFFECT); queue cards glide to new places after a drop, held card colour fades, grab cursors; rules page empty state, unit via catalogue, nameless rules named in labels and toast; target window sizes named. +- Later: cards making room while one is dragged; settings rows for S033's tray and notification settings. Tests: `docs/tests/S034-motion-audit.md`. diff --git a/docs/tests/S034-motion-audit.md b/docs/tests/S034-motion-audit.md new file mode 100644 index 0000000..edca200 --- /dev/null +++ b/docs/tests/S034-motion-audit.md @@ -0,0 +1,43 @@ +# S034 — Motion and look pass: test file + +Written by the worker that built it, run by the test phase. Nothing here has been tested until its Result says so. + +## Built +Audit (by `rg` over crates/app): springs everywhere come from `tokens::spring`, colours use EFFECT, no literal colours or radii outside tokens/theme, no Later feature (PLAN.md) has a setting, menu entry or tab. Faults found and fixed: +- `crates/app/src/drop.rs` · `overlay`: the drop state now fades in and out (EFFECT spring) instead of popping; stroke is `size::FOCUS_RING`, text offset from tokens. Reach: drag a file over the main window. +- `crates/app/src/views/queues.rs` · `Page::show`, `card`: a dropped queue card glides from where it was let go to its new place, the other cards glide when the order changes, the held card's colour fades container to highest, the handle shows grab / grabbing cursors. Reach: Queues page, drag a card by its handle. +- `crates/app/src/views/rules.rs` · `list`: empty state line (`rule.none`), size unit through the catalogue (`unit.mb_short`), rules without a name are named "Rule without a name" in AccessKit labels, tooltips and the removed toast. Reach: Settings, Rules. +- `crates/app/src/views/target.rs`: window sizes as named constants (`CLOSED` 112x132, `OPEN` 172x232, same as before). +Left as is by design: target window resizes instantly (a viewport resize); rule row text offsets; backups page (D-048). + +## Checks +Risk: HIGH = data loss, security, crash, wrong result · MED = feature broken · LOW = looks or comfort. +How: unit · integration · screen · by hand. + +| # | Risk | Do this | Expect | How | Result | +|---|---|---|---|---|---| +| 1 | MED | Motion normal: drag a file over the main window (hidden.sh driver or kittest with `hovered_files` set), grab frames 0, 3, 10, 30; then clear hovered files and grab again | Overlay alpha rises over a few frames to full, then falls back to nothing; no frame after it is gone (`motion::busy()` false) | screen | — | +| 2 | MED | Same as 1 with motion reduced, then off | Reduced: same fade, never above full. Off: full on the first frame, gone on the first frame after | screen | — | +| 3 | MED | Queues page with 3 queues; drag queue 1's handle down past queue 3 and release; grab frames for 30 frames after release, motion normal | Card follows the pointer 1:1 while held; after release it moves smoothly to the last place, others move up smoothly; no jump back to the old slot at the end | screen | — | +| 4 | MED | Repeat 3 with motion reduced and off | Reduced: no overshoot past the final slot. Off: cards are in their final places on the next frame | screen | — | +| 5 | MED | Queues page with more queues than fit; scroll the page with the wheel | Cards scroll 1:1 with the content, no lag or glide while scrolling | by hand | — | +| 6 | LOW | Hover the queue handle, then press and drag it | Cursor grab on hover, grabbing while dragging; held card tint fades in and out, no instant switch | screen | — | +| 7 | MED | Settings, Rules with no rules | The line "No rules yet. ..." shows above "Add rule" and "Add the set by type" | screen | — | +| 8 | LOW | Add a rule with an empty name; read AccessKit names of its row and buttons (kittest `query_by_label`), remove it | Labels read "Change rule Rule without a name" etc.; toast "Rule Rule without a name removed" with Undo; Undo brings it back | unit (kittest) | — | +| 9 | LOW | Edit a rule; look at the At least / At most fields | Unit shows the catalogue's "MB" | screen | — | +| 10 | LOW | Turn on the drop target (Settings, Clipboard and drops); right click the ring, then pick each entry | Window 112x132 closed, 172x232 with the menu, all three buttons fully inside | screen | — | +| 11 | MED | Keyboard only, from launch: reach Add, Settings (every page), Queues, Rules, the list, the palette with Tab, arrows, Enter, Escape | Every control gets a visible focus ring, every action can be done, Escape closes dialogs and menus | by hand / kittest | — | +| 12 | MED | Shots of main, settings (each page), queues, rules, add and the drop overlay at 480x360, 900x600, 1600x1000, 3440x1440, light, dark, AMOLED (`MEDLAR_SHOTS`, `SIZES=`, contact sheet) | Nothing overflows or overlaps, panels flush, popups inside the window, AMOLED surface black | screen | — | +| 13 | MED | Same shots with a 200-character download and queue and rule name, sizes over 1 TB, speeds over 1 GB/s, counts over 10,000 | Names end in an ellipsis on one line, numbers fit their columns, no row grows | screen | — | +| 14 | LOW | Every clickable thing in the shots from 12: measure hit rects (kittest response rects) | None smaller than 32x32 px | unit (kittest) | — | +| 15 | MED | Idle app 10 s after the last change, with the drop overlay gone and no drag | No frames drawn (`tools/hidden.sh` cpu near 0, frame counter flat) | screen | — | + +## Needs +Throwaway `XDG_*` home, `tools/hidden.sh` or kittest shots, a few queues and rules in the throwaway settings. No network. + +## Doubts +- Queue drop: the card springs toward its old slot until the bridge saves the new order, then retargets. If the save is slow the card may drift back then forward (check 3). Fix would be keeping the drop order locally until the next snapshot. +- While a card is held the others do not make room; they only glide after the drop. By design for this pass, may look flat. +- The drop overlay fade needs repaints after hovered files clear; it relies on `motion::busy()` asking for frames (check 1 last part). +- S033 settings (tray, notifications, autostart, quiet hours) still have no settings rows; not a dead control, but not reachable from the UI. +- No existing tests should break; the queues key strings changed only inside motion springs.