diff --git a/Plans/02 App skeleton/S038-expressive-restyle.md b/Plans/02 App skeleton/S038-expressive-restyle.md index e03a313..a18df6d 100644 --- a/Plans/02 App skeleton/S038-expressive-restyle.md +++ b/Plans/02 App skeleton/S038-expressive-restyle.md @@ -10,13 +10,13 @@ The user finds the current UI bland ("not enough rounded stuff, material icons, CLAUDE.md §2 Design references, §3; D-027, D-028, D-035; the prototype (look only, never copy): `/home/astar76/Documents/Apps/tunal-files/tunal/widgets.py` (`shape_path`, `ShapeWidget`, `RippleButton`, `SegmentedButton`, `Breadcrumb`, `Snackbar`, `WavyProgress`, `PlayFab`), `theme.py` (radii, lines ~360–430), `panels.py`, `views.py`, `dialogs.py`; Damson `src/motion.rs`; `app-taste` and `animate` skills. ## Steps -- [ ] Shape tokens: larger radii (cards 24–28, controls full pill, menus 14 with 10 px item pills, text fields 12), `Theme` shape library for M3 Expressive shapes (circle, cookie4/6/9/12, clover, scallop, pill) as Slint `Path` commands generated at build time or by a Rust helper; a `Shape` component (shape, size, fill role, glyph, rotation) that can morph between two shapes. -- [ ] Ripple state layer: press ripple spreading from the pointer plus the existing hover tint and squeeze; selected/toggled states morph shape (e.g. circle → cookie9) and fill. -- [ ] Shell as rounded surfaces: sidebar on `surface-container` with pill place rows and a shaped glyph container per place; content pane as a rounded card with a gap from the window edge; tab bar of pills with a sliding indicator; breadcrumb crumbs as pills; toolbar buttons tonal circles; segmented view switch. -- [ ] Views: folder/file glyphs in shaped tonal containers (folder cookie, file by category), rounded row highlight with selection morph, grid tiles as rounded cards; item fade/slide-in on load (honour reduced motion, stop when idle). -- [ ] Dialogs, menus, toasts: shaped header glyph in dialogs (cookie6), menu item pills, snackbar with wavy progress for running jobs, card shadows from the design references. -- [ ] Gallery + screenshots light/dark of the shell, a music folder, grid view, a dialog and a menu; compare with the prototype's look by reading its code; tokens only (literal grep empty). -- [ ] PROGRESS entry, INDEX line, commit `S038: …` +- [x] Shape tokens: larger radii (cards 24–28, controls full pill, menus 14 with 10 px item pills, text fields 12), `Theme` shape library for M3 Expressive shapes (circle, cookie4/6/9/12, clover, scallop, pill) as Slint `Path` commands generated at build time or by a Rust helper; a `Shape` component (shape, size, fill role, glyph, rotation) that can morph between two shapes. +- [x] Ripple state layer: press ripple spreading from the pointer plus the existing hover tint and squeeze; selected/toggled states morph shape (e.g. circle → cookie9) and fill. +- [x] Shell as rounded surfaces: sidebar on `surface-container` with pill place rows and a shaped glyph container per place; content pane as a rounded card with a gap from the window edge; tab bar of pills with a sliding indicator; breadcrumb crumbs as pills; toolbar buttons tonal circles; segmented view switch. +- [x] Views: folder/file glyphs in shaped tonal containers (folder cookie, file by category), rounded row highlight with selection morph, grid tiles as rounded cards; item fade/slide-in on load (honour reduced motion, stop when idle). +- [x] Dialogs, menus, toasts: shaped header glyph in dialogs (cookie6), menu item pills, snackbar with wavy progress for running jobs, card shadows from the design references. +- [x] Gallery + screenshots light/dark of the shell, a music folder, grid view, a dialog and a menu; compare with the prototype's look by reading its code; tokens only (literal grep empty). +- [x] PROGRESS entry, INDEX line, commit `S038: …` ## End criteria - `cargo build --workspace`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo fmt --check` pass. diff --git a/Plans/INDEX.md b/Plans/INDEX.md index 650da3b..8799b49 100644 --- a/Plans/INDEX.md +++ b/Plans/INDEX.md @@ -14,7 +14,7 @@ Tracker: https://claude.ai/artifact/4X8YCk3cQjUGyuyCqGuU7v - [x] [S003 — Window, Theme and Motion globals, screenshot command](02%20App%20skeleton/S003-window-tokens.md) · Opus high - [x] [S004 — Base animated controls](02%20App%20skeleton/S004-base-controls.md) · Opus high - [x] [S005 — Menus, dialogs and toasts](02%20App%20skeleton/S005-menus-dialogs.md) · Opus high -- [ ] [S038 — Expressive restyle (shapes, ripples, rounded surfaces)](02%20App%20skeleton/S038-expressive-restyle.md) · Opus high (runs after S013, before S014) +- [x] [S038 — Expressive restyle (shapes, ripples, rounded surfaces)](02%20App%20skeleton/S038-expressive-restyle.md) · Opus high (runs after S013, before S014) ## 03 File browsing diff --git a/crates/tunal/src/main.rs b/crates/tunal/src/main.rs index 2c007d1..e4262b6 100644 --- a/crates/tunal/src/main.rs +++ b/crates/tunal/src/main.rs @@ -9,6 +9,7 @@ mod open; mod properties; mod screenshot; mod settings; +mod shapes; mod shell; mod theme_bridge; diff --git a/crates/tunal/src/shapes.rs b/crates/tunal/src/shapes.rs new file mode 100644 index 0000000..911277e --- /dev/null +++ b/crates/tunal/src/shapes.rs @@ -0,0 +1,101 @@ +//! Path commands for the `Shapes` global: Material 3 Expressive container shapes as polar +//! curves `r(θ) = 1 + depth · cos(lobes · θ)`, sampled at the same angles so two shapes morph +//! point by point. + +use std::{cell::RefCell, collections::HashMap, fmt::Write}; + +use slint::SharedString; + +use crate::ShapeKind; + +/// Points per outline: smooth at the largest container (56 px) without costing much. +const SAMPLES: usize = 72; + +/// Lobe count and depth (share of the radius) of each shape. +fn curve(kind: ShapeKind) -> (f32, f32) { + match kind { + ShapeKind::Circle => (0.0, 0.0), + ShapeKind::Cookie4 => (4.0, 0.10), + ShapeKind::Cookie6 => (6.0, 0.075), + ShapeKind::Cookie9 => (9.0, 0.055), + ShapeKind::Cookie12 => (12.0, 0.04), + ShapeKind::Clover => (4.0, 0.22), + ShapeKind::Scallop => (16.0, 0.03), + } +} + +thread_local! { + /// Shapes at rest (no morph, no turn) are asked for once per row; keep them. + static RESTING: RefCell> = RefCell::default(); +} + +pub fn path(from: ShapeKind, to: ShapeKind, t: f32, turn: f32) -> SharedString { + let t = t.clamp(0.0, 1.0); + let resting = turn == 0.0 && (t == 0.0 || t == 1.0 || from == to); + if resting { + let kind = if t == 1.0 { to } else { from }; + return RESTING.with(|cache| { + cache + .borrow_mut() + .entry(kind as i32) + .or_insert_with(|| outline(kind, kind, 0.0, 0.0)) + .clone() + }); + } + outline(from, to, t, turn) +} + +fn outline(from: ShapeKind, to: ShapeKind, t: f32, turn: f32) -> SharedString { + let (na, da) = curve(from); + let (nb, db) = curve(to); + // Scale so the outermost lobe of either shape touches the viewbox edge. + let scale = 50.0 / (1.0 + da.max(db)); + let turn = turn.to_radians(); + let mut commands = String::with_capacity(SAMPLES * 14); + for i in 0..SAMPLES { + let theta = std::f32::consts::TAU * i as f32 / SAMPLES as f32; + let ra = 1.0 + da * (na * theta).cos(); + let rb = 1.0 + db * (nb * theta).cos(); + let r = (ra + (rb - ra) * t) * scale; + let x = 50.0 + r * (theta + turn).cos(); + let y = 50.0 + r * (theta + turn).sin(); + let op = if i == 0 { 'M' } else { 'L' }; + let _ = write!(commands, "{op}{x:.2} {y:.2} "); + } + commands.push('Z'); + commands.into() +} + +/// Units between the points of a wave. +const WAVE_STEP: f32 = 2.0; + +/// A filled band `thickness` thick along a sine line (a stroked path scales unevenly in the +/// software renderer), `2 · amplitude + thickness` high. +pub fn wave( + length: f32, + wavelength: f32, + amplitude: f32, + thickness: f32, + phase: f32, +) -> SharedString { + let length = length.max(0.0); + let wavelength = wavelength.max(WAVE_STEP); + let points = (length / WAVE_STEP).ceil() as usize; + let top = |i: usize| { + let x = (i as f32 * WAVE_STEP).min(length); + let angle = std::f32::consts::TAU * (x / wavelength - phase); + (x, amplitude * (1.0 - angle.sin())) + }; + let mut commands = String::with_capacity((points + 1) * 28); + for i in 0..=points { + let (x, y) = top(i); + let op = if i == 0 { 'M' } else { 'L' }; + let _ = write!(commands, "{op}{x:.2} {y:.2} "); + } + for i in (0..=points).rev() { + let (x, y) = top(i); + let _ = write!(commands, "L{x:.2} {:.2} ", y + thickness); + } + commands.push('Z'); + commands.into() +} diff --git a/crates/tunal/src/theme_bridge.rs b/crates/tunal/src/theme_bridge.rs index 77ee85b..9e6aa54 100644 --- a/crates/tunal/src/theme_bridge.rs +++ b/crates/tunal/src/theme_bridge.rs @@ -6,7 +6,7 @@ use slint::{Color, ComponentHandle}; use tunal_theme::{Appearance, ColorScheme, Palette, Palettes}; use crate::config; -use crate::{Gallery, MainWindow, MotionPrefs, Theme}; +use crate::{Gallery, MainWindow, MotionPrefs, Shapes, Theme, shapes}; /// Overrides for agents and screenshots: `TUNAL_SEED=#rrggbb`, `TUNAL_SCHEME=light|dark`, /// `TUNAL_REDUCED_MOTION=1`. Unset or invalid values leave the portal value in place. @@ -68,6 +68,7 @@ fn reduced(forced: bool) -> bool { pub trait Themed: ComponentHandle + 'static { fn theme(&self) -> Theme<'_>; fn motion_prefs(&self) -> MotionPrefs<'_>; + fn shapes(&self) -> Shapes<'_>; } macro_rules! themed { @@ -79,6 +80,9 @@ macro_rules! themed { fn motion_prefs(&self) -> MotionPrefs<'_> { self.global::() } + fn shapes(&self) -> Shapes<'_> { + self.global::() + } })* }; } @@ -103,6 +107,8 @@ pub fn apply(ui: &impl Themed, appearance: &Appearance, overrides: Overrides) { ColorScheme::Light => palettes.light, ColorScheme::Dark => palettes.dark, }; + ui.shapes().on_path(shapes::path); + ui.shapes().on_wave(shapes::wave); let theme = ui.theme(); theme.set_dark(scheme == ColorScheme::Dark); set_colors(&theme, &palette); diff --git a/crates/tunal/ui/app.slint b/crates/tunal/ui/app.slint index ace1cdc..d385fd9 100644 --- a/crates/tunal/ui/app.slint +++ b/crates/tunal/ui/app.slint @@ -1,5 +1,7 @@ import "../../../assets/fonts/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].ttf"; import { Theme } from "theme.slint"; +import { Shapes, ShapeKind } from "shapes.slint"; +import { Icons } from "components/icon.slint"; import { Motion, MotionPrefs } from "motion.slint"; import { Menu, MenuItem, MenuEntry } from "components/menu.slint"; import { Dialog } from "components/dialog.slint"; @@ -22,7 +24,7 @@ import { PropertiesDialog, PropertiesInfo, PropRow } from "dialogs/properties.sl import { OpenWithDialog, AppRow } from "dialogs/open-with.slint"; import { SettingsDialog, SettingsData, EditRow } from "dialogs/settings.slint"; -export { Theme, MotionPrefs, MenuItem, MenuEntry, DetailRow, FolderState, FolderStatus, Grouping, NavKey, SortColumn, Travel, ViewMode, GridRow } +export { Theme, Shapes, ShapeKind, MotionPrefs, MenuItem, MenuEntry, DetailRow, FolderState, FolderStatus, Grouping, NavKey, SortColumn, Travel, ViewMode, GridRow } export { ButtonKind, TabData, PaneData, Crumb, Completion, SidebarSection, PlaceItem, ToastData, ToastProgress, DialogAction, ConflictInfo, SettingsData, EditRow } export { PropertiesInfo, PropRow, AppRow } export { Gallery, GalleryPage } from "gallery.slint"; @@ -36,7 +38,8 @@ export component MainWindow inherits Window { min-height: 480px; preferred-width: 960px; preferred-height: 640px; - background: Theme.surface; + // The sidebar and tab bar sit on the window; the panes on a rounded card above it. + background: Theme.surface-container; animate background { duration: Motion.time(Motion.medium2); easing: Motion.standard; } // Tabs, by opening order (see TabData). @@ -338,6 +341,22 @@ export component MainWindow inherits Window { } } + // The content card: toolbar, panes and status bar, inset from the window edge. + HorizontalLayout { + padding-right: Theme.space-2; + padding-bottom: Theme.space-2; + padding-left: root.show-sidebar ? 0 : Theme.space-2; + + Rectangle { + border-radius: Theme.corner-card; + background: Theme.surface; + drop-shadow-blur: Theme.card-shadow-blur; + drop-shadow-offset-y: Theme.card-shadow-offset; + drop-shadow-color: Theme.shadow.with-alpha(Theme.card-shadow-opacity); + clip: true; + animate background { duration: Motion.time(Motion.medium2); easing: Motion.standard; } + + VerticalLayout { toolbar := Toolbar { can-back: root.can-back; can-forward: root.can-forward; @@ -464,6 +483,9 @@ export component MainWindow inherits Window { StatusBar { text: root.status; } + } + } + } } } } @@ -523,6 +545,7 @@ export component MainWindow inherits Window { } rename-dialog := Dialog { + glyph: Icons.edit; width: 100%; height: 100%; title: "Rename bookmark"; diff --git a/crates/tunal/ui/components/dialog.slint b/crates/tunal/ui/components/dialog.slint index e55b35b..85be65f 100644 --- a/crates/tunal/ui/components/dialog.slint +++ b/crates/tunal/ui/components/dialog.slint @@ -1,5 +1,6 @@ import { Theme } from "../theme.slint"; import { Motion } from "../motion.slint"; +import { Shape, ShapeKind } from "shape.slint"; import { Button, ButtonKind } from "button.slint"; import { Overlay } from "overlay.slint"; @@ -20,6 +21,8 @@ export struct DialogAction { // `content-focus` and focus it in `focus-content`. export component Dialog inherits Overlay { in property title; + // Glyph from `Icons` shown in a cookie above the title, which then centres; empty for none. + in property glyph; in property body; // Left to right; the main action last. in property <[DialogAction]> actions; @@ -100,10 +103,10 @@ export component Dialog inherits Overlay { x: (root.width - self.width) / 2; y: max(Theme.window-margin, (root.height - self.height) / 2); background: Theme.surface-container-high; - border-radius: Theme.corner-xl; - drop-shadow-blur: Theme.float-shadow-blur; - drop-shadow-offset-y: Theme.float-shadow-offset; - drop-shadow-color: Theme.shadow.with-alpha(Theme.float-shadow-opacity); + border-radius: Theme.corner-card; + drop-shadow-blur: Theme.dialog-shadow-blur; + drop-shadow-offset-y: Theme.dialog-shadow-offset; + drop-shadow-color: Theme.shadow.with-alpha(Theme.dialog-shadow-opacity); opacity: root.progress; transform-scale: Motion.enter-scale + (1 - Motion.enter-scale) * root.progress; @@ -138,8 +141,24 @@ export component Dialog inherits Overlay { padding: Theme.space-6; spacing: Theme.space-4; + // The cookie turns into place as the dialog opens. + if root.glyph != "": HorizontalLayout { + alignment: center; + + Shape { + size: 56px; + shape: ShapeKind.cookie6; + turn: (1 - root.progress) * Theme.shape-enter-turn; + fill: Theme.secondary-container; + glyph: root.glyph; + glyph-color: Theme.on-secondary-container; + glyph-ratio: 0.5; + } + } + Text { text: root.title; + horizontal-alignment: root.glyph != "" ? center : left; color: Theme.on-surface; font-size: Theme.title-large.size; font-weight: Theme.title-large.weight; diff --git a/crates/tunal/ui/components/icon-button.slint b/crates/tunal/ui/components/icon-button.slint index 67ebdc0..48ed7ca 100644 --- a/crates/tunal/ui/components/icon-button.slint +++ b/crates/tunal/ui/components/icon-button.slint @@ -2,13 +2,16 @@ import { Theme } from "../theme.slint"; import { Motion } from "../motion.slint"; import { Icon } from "icon.slint"; import { StateLayer } from "state-layer.slint"; +import { Shape, ShapeKind } from "shape.slint"; // An icon-only button. Always give it a `tooltip` naming its action. With `toggle` it flips -// `checked` on click and shows a tonal container while checked. +// `checked` on click; checked, its circle morphs into a tonal cookie. export component IconButton inherits StateLayer { // Glyph from `Icons`. in property icon; in property toggle; + // A tonal circle at rest (toolbar buttons) instead of a bare glyph. + in property tonal; in-out property checked; in property size: 40px; in property icon-size: 24px; @@ -22,17 +25,14 @@ export component IconButton inherits StateLayer { height: root.size; // Pressed, the circle squashes towards a squircle on top of the squeeze. border-radius: root.pressed ? (root.size >= 40px ? Theme.corner-md : Theme.corner-sm) : Theme.corner-full(root.size); - background: !root.on ? transparent : root.enabled ? Theme.secondary-container : Theme.on-surface.with-alpha(Theme.disabled-container); + // Disabled, only the glyph dims: a darker disabled fill would read as pressed. + background: !root.tonal || root.on ? transparent : Theme.surface-container-high; tint: root.content; squeeze: Motion.squeeze-small; animate border-radius { duration: Motion.time(root.pressed ? Motion.short2 : Motion.short3); easing: Motion.standard; } - animate background { - duration: Motion.time(Motion.short4); - easing: Motion.standard; - } activated => { if root.toggle { @@ -49,6 +49,15 @@ export component IconButton inherits StateLayer { self.activate(); } + if root.toggle: Shape { + size: root.size; + shape: ShapeKind.circle; + active-shape: ShapeKind.cookie9; + active: root.on; + fill: transparent; + active-fill: root.enabled ? Theme.secondary-container : Theme.on-surface.with-alpha(Theme.disabled-container); + } + Icon { x: (root.width - self.width) / 2; y: (root.height - self.height) / 2; diff --git a/crates/tunal/ui/components/icon.slint b/crates/tunal/ui/components/icon.slint index 26663ff..b940189 100644 --- a/crates/tunal/ui/components/icon.slint +++ b/crates/tunal/ui/components/icon.slint @@ -55,4 +55,13 @@ export global Icons { out property drag-handle: "\u{e945}"; out property restore: "\u{e8b3}"; out property create-new-folder: "\u{e2cc}"; + out property settings: "\u{e8b8}"; + // File categories (icons.rs). + out property image: "\u{e3f4}"; + out property audio: "\u{eb82}"; + out property video: "\u{eb87}"; + out property code: "\u{e86f}"; + out property pdf: "\u{e415}"; + out property archive: "\u{eb2c}"; + out property program: "\u{eb8e}"; } diff --git a/crates/tunal/ui/components/list-row.slint b/crates/tunal/ui/components/list-row.slint index 4412dd6..7b1c9d8 100644 --- a/crates/tunal/ui/components/list-row.slint +++ b/crates/tunal/ui/components/list-row.slint @@ -3,6 +3,7 @@ import { Motion } from "../motion.slint"; import { Icon } from "icon.slint"; import { StateLayer } from "state-layer.slint"; import { RenameField } from "rename-field.slint"; +import { Shape, ShapeKind } from "shape.slint"; // One row of a list: leading icon, title, optional supporting line, and a trailing slot for // the row's children. Selection grows a tonal fill from the centre. @@ -14,6 +15,13 @@ export component ListRow inherits StateLayer { in property title; in property supporting; in property selected; + // Draws the icon in a shaped tonal container that morphs to `active-shape` when selected. + in property shaped; + in property shape: ShapeKind.circle; + in property active-shape: ShapeKind.cookie9; + in property shape-size: 36px; + in property shape-fill: Theme.secondary-container; + in property shape-ink: Theme.on-secondary-container; // Shows the title as an edit field (see RenameField); `edit-select` bytes are preselected. in property editing; in property edit-select; @@ -54,11 +62,34 @@ export component ListRow inherits StateLayer { } HorizontalLayout { - padding-left: Theme.space-4; + padding-left: root.shaped ? Theme.space-1 : Theme.space-4; padding-right: Theme.space-2; spacing: Theme.space-3; - if root.icon != "": VerticalLayout { + if root.icon != "" && root.shaped: VerticalLayout { + alignment: center; + + Shape { + size: root.shape-size; + shape: root.shape; + active-shape: root.active-shape; + active: root.selected; + glyph: root.icon; + fill: root.enabled ? root.shape-fill : Theme.on-surface.with-alpha(Theme.disabled-container); + active-fill: root.enabled ? Theme.primary : Theme.on-surface.with-alpha(Theme.disabled-container); + glyph-color: !root.enabled ? root.detail-color : root.selected ? Theme.on-primary : root.shape-ink; + + if root.badge != "": Icon { + x: parent.width - self.width; + y: parent.height - self.height; + glyph: root.badge; + size: 14px; + color: Theme.primary; + } + } + } + + if root.icon != "" && !root.shaped: VerticalLayout { alignment: center; Rectangle { diff --git a/crates/tunal/ui/components/menu.slint b/crates/tunal/ui/components/menu.slint index 782ad30..21b96de 100644 --- a/crates/tunal/ui/components/menu.slint +++ b/crates/tunal/ui/components/menu.slint @@ -37,8 +37,8 @@ component MenuRow inherits StateLayer { enabled: !root.entry.separator && !root.entry.disabled; force-state: root.highlighted ? ForceState.hover : ForceState.none; - height: root.entry.separator ? Theme.space-2 + Theme.hairline : 32px; - border-radius: Theme.corner-xs; + height: root.entry.separator ? Theme.space-2 + Theme.hairline : 36px; + border-radius: Theme.corner-menu-item; squeeze: Motion.squeeze-large; accessible-role: list-item; @@ -109,7 +109,7 @@ component MenuSurface inherits Rectangle { in property origin; background: Theme.surface-container; - border-radius: Theme.corner-sm; + border-radius: Theme.corner-menu; drop-shadow-blur: Theme.float-shadow-blur; drop-shadow-offset-y: Theme.float-shadow-offset; drop-shadow-color: Theme.shadow.with-alpha(Theme.float-shadow-opacity); @@ -327,7 +327,7 @@ export component Menu inherits Overlay { progress: root.progress; column := VerticalLayout { - padding: Theme.space-1; + padding: Theme.space-2; for item[i] in root.items: MenuRow { entry: { text: item.text, icon: item.icon, shortcut: item.shortcut, disabled: item.disabled, separator: item.separator }; @@ -355,7 +355,7 @@ export component Menu inherits Overlay { MenuSurface { // The parent row's top, so the first submenu row lines up with it. - property row-y: surface.y + root.sub-row-y - Theme.space-1; + property row-y: surface.y + root.sub-row-y - Theme.space-2; width: clamp(sub-column.preferred-width, 180px, 280px); height: sub-column.preferred-height; @@ -365,7 +365,7 @@ export component Menu inherits Overlay { progress: root.sub-progress; sub-column := VerticalLayout { - padding: Theme.space-1; + padding: Theme.space-2; for entry[j] in root.sub-items: MenuRow { entry: entry; diff --git a/crates/tunal/ui/components/shape.slint b/crates/tunal/ui/components/shape.slint new file mode 100644 index 0000000..20d8efe --- /dev/null +++ b/crates/tunal/ui/components/shape.slint @@ -0,0 +1,85 @@ +import { Theme } from "../theme.slint"; +import { Motion } from "../motion.slint"; +import { Shapes, ShapeKind } from "../shapes.slint"; +import { Icon, Icons } from "icon.slint"; + +export { ShapeKind } + +// The container of an entry's glyph, by file category: folders are cookies, media get the +// tertiary role, other files the secondary one. Selected entries morph to `active-shape`. +export global FileShapes { + public pure function shape(glyph: string) -> ShapeKind { + glyph == Icons.folder ? ShapeKind.cookie9 + : glyph == Icons.audio ? ShapeKind.clover + : glyph == Icons.image ? ShapeKind.cookie6 + : glyph == Icons.video ? ShapeKind.cookie4 + : glyph == Icons.archive ? ShapeKind.cookie12 + : glyph == Icons.program ? ShapeKind.scallop + : ShapeKind.circle + } + public pure function active-shape(glyph: string) -> ShapeKind { + glyph == Icons.folder ? ShapeKind.cookie4 : ShapeKind.cookie9 + } + public pure function fill(glyph: string) -> color { + glyph == Icons.folder ? Theme.primary-container + : glyph == Icons.audio || glyph == Icons.image || glyph == Icons.video ? Theme.tertiary-container + : Theme.secondary-container + } + public pure function ink(glyph: string) -> color { + glyph == Icons.folder ? Theme.on-primary-container + : glyph == Icons.audio || glyph == Icons.image || glyph == Icons.video ? Theme.on-tertiary-container + : Theme.on-secondary-container + } +} + +// A shaped glyph container (M3 Expressive). `active` morphs it from `shape` to +// `active-shape` (e.g. circle → cookie9 when selected); the morph runs only while `active` +// changes and is instant under reduced motion. +export component Shape { + in property shape: ShapeKind.circle; + in property active-shape: root.shape; + in property active; + // Degrees the outline is turned; the active outline turns a little more as it morphs. + in property turn; + in property fill: Theme.secondary-container; + in property active-fill: root.fill; + in property glyph; + in property glyph-color: Theme.on-secondary-container; + in property size: 40px; + // Glyph size as a share of the container. + in property glyph-ratio: 0.55; + + // 0 = `shape`, 1 = `active-shape`. + property t: root.active ? 1 : 0; + animate t { + duration: Motion.time(Motion.medium2); + easing: Motion.emphasized; + } + + width: root.size; + height: root.size; + + Path { + width: 100%; + height: 100%; + viewbox-width: 100; + viewbox-height: 100; + fill: root.active ? root.active-fill : root.fill; + commands: Shapes.path(root.shape, root.active-shape, root.t, root.turn + root.t * Theme.shape-morph-turn); + animate fill { + duration: Motion.time(Motion.short4); + easing: Motion.standard; + } + } + + if root.glyph != "": Icon { + x: (root.width - self.width) / 2; + y: (root.height - self.height) / 2; + glyph: root.glyph; + size: root.size * root.glyph-ratio; + color: root.glyph-color; + } + + // Overlays such as a link badge. + @children +} diff --git a/crates/tunal/ui/components/state-layer.slint b/crates/tunal/ui/components/state-layer.slint index 411f49b..4b92b1c 100644 --- a/crates/tunal/ui/components/state-layer.slint +++ b/crates/tunal/ui/components/state-layer.slint @@ -1,5 +1,5 @@ import { Theme } from "../theme.slint"; -import { Motion } from "../motion.slint"; +import { Motion, MotionClock } from "../motion.slint"; import { Tooltip } from "tooltip.slint"; // A state shown regardless of the pointer and focus, for gallery screenshots. @@ -23,11 +23,14 @@ export component StateLayer inherits Rectangle { in property ring-offset: Theme.focus-ring-offset; // Off for rows of a list that owns the keyboard itself: no Tab stop per row. in property focusable: true; + // Press ripple spreading from the pointer; off for controls that draw their own press. + in property ripple: true; out property hovered: enabled && (touch.has-hover || force-state == ForceState.hover); out property pressed: enabled && (touch.pressed || force-state == ForceState.pressed); out property focused: enabled && (keyboard-focus || force-state == ForceState.focused); - out property tint-opacity: pressed ? Theme.state-press : focused ? Theme.state-focus : hovered ? Theme.state-hover : 0; + // With a ripple the press shows in the ripple; the flat tint stays at hover strength. + out property tint-opacity: pressed && !ripple ? Theme.state-press : focused ? Theme.state-focus : hovered || pressed ? Theme.state-hover : 0; // For users of the control. callback clicked; @@ -104,6 +107,11 @@ export component StateLayer inherits Rectangle { pointer-event(event) => { if event.kind == PointerEventKind.down { root.modifiers = event.modifiers; + if event.button == PointerEventButton.left { + root.ripple-x = self.mouse-x; + root.ripple-y = self.mouse-y; + root.ripple-epoch += 1; + } } root.pointer(event); } @@ -132,6 +140,38 @@ export component StateLayer inherits Rectangle { background: root.tint.with-alpha(root.tint-opacity); } + // The ripple: a circle from the press point that grows to cover the far corner, then fades + // after release. Its clock ticks only while it spreads. + property ripple-x: root.width / 2; + property ripple-y: root.height / 2; + property ripple-epoch; + property ripple-reach: sqrt(pow(max(root.ripple-x, root.width - root.ripple-x) / 1px, 2) + pow(max(root.ripple-y, root.height - root.ripple-y) / 1px, 2)) * 1px; + property ripple-fade: root.pressed ? 1 : 0; + animate ripple-fade { + duration: Motion.time(root.pressed ? Motion.short1 : Motion.medium2); + easing: Motion.standard; + } + ripple-clock := MotionClock { + epoch: root.ripple-epoch; + duration: Motion.time(Motion.medium4); + } + + if root.ripple && root.fill-tint && root.ripple-fade > 0: Rectangle { + clip: true; + border-radius: root.border-radius; + + // A forced press (gallery) shows the ripple half spread. + property spread: root.force-state == ForceState.pressed ? 0.5 : Motion.settle(ripple-clock.progress); + Rectangle { + width: 2 * root.ripple-reach * parent.spread; + height: self.width; + x: root.ripple-x - self.width / 2; + y: root.ripple-y - self.height / 2; + border-radius: self.width / 2; + background: root.tint.with-alpha(Theme.state-press * root.ripple-fade); + } + } + if root.focused: Rectangle { x: -root.ring-inset; y: -root.ring-inset; diff --git a/crates/tunal/ui/components/toast.slint b/crates/tunal/ui/components/toast.slint index cec2ed2..f6cae78 100644 --- a/crates/tunal/ui/components/toast.slint +++ b/crates/tunal/ui/components/toast.slint @@ -1,5 +1,6 @@ import { Theme } from "../theme.slint"; import { Motion } from "../motion.slint"; +import { Shapes } from "../shapes.slint"; import { Icon, Icons } from "icon.slint"; import { StateLayer } from "state-layer.slint"; @@ -86,11 +87,11 @@ component Toast inherits Rectangle { self.entered = true; } - height: 48px; + height: 56px; y: root.base-y - root.stack-offset + (1 - root.progress) * Theme.space-6; opacity: root.progress; background: Theme.inverse-surface; - border-radius: Theme.corner-xs; + border-radius: Theme.corner-lg; drop-shadow-blur: Theme.float-shadow-blur; drop-shadow-offset-y: Theme.float-shadow-offset; drop-shadow-color: Theme.shadow.with-alpha(Theme.float-shadow-opacity); @@ -124,7 +125,7 @@ component Toast inherits Rectangle { HorizontalLayout { padding-left: Theme.space-4; padding-right: Theme.space-2; - padding-bottom: root.data.progress-kind == ToastProgress.none ? 0 : Theme.space-1; + padding-bottom: root.data.progress-kind == ToastProgress.none ? 0 : Theme.space-3; spacing: Theme.space-1; Text { @@ -165,38 +166,43 @@ component Toast inherits Rectangle { } } - if root.data.progress-kind != ToastProgress.none: track := Rectangle { + // Wavy progress: the done part is a sine line that travels while the job runs (the work is + // moving, so the line does too), the rest a flat track. Indeterminate: the whole width + // waves. Reduced motion: the wave stands still. + if root.data.progress-kind != ToastProgress.none: bar := Rectangle { + property stroke: Theme.wave-stroke; + property amplitude: Theme.wave-amplitude; + property part: root.data.progress-kind == ToastProgress.determinate ? clamp(root.data.progress, 0, 1) : 1; + property done: self.width * self.shown; + property shown: self.part; + property phase: Motion.reduced || root.leaving ? 0 : Math.mod(animation-tick() / Motion.wave-period, 1); + animate shown { + duration: Motion.time(Motion.short4); + easing: Motion.standard; + } + x: Theme.space-4; - y: root.height - Theme.space-2; + y: root.height - Theme.space-2 - self.height; width: root.width - 2 * Theme.space-4; - height: Theme.space-1; - border-radius: Theme.corner-full(self.height); - background: Theme.inverse-on-surface.with-alpha(Theme.disabled-container); - clip: true; + height: 2 * self.amplitude + self.stroke; - if root.data.progress-kind == ToastProgress.determinate: Rectangle { + Path { x: 0; - width: parent.width * clamp(root.data.progress, 0, 1); - border-radius: parent.border-radius; - background: Theme.inverse-primary; - animate width { - duration: Motion.time(Motion.short4); - easing: Motion.standard; - } + width: bar.done; + height: bar.height; + viewbox-width: max(1, bar.done / 1px); + viewbox-height: bar.height / 1px; + commands: Shapes.wave(bar.done / 1px, Theme.wave-length / 1px, bar.amplitude / 1px, bar.stroke / 1px, bar.phase); + fill: root.data.progress-kind == ToastProgress.indeterminate && Motion.reduced ? Theme.inverse-primary.with-alpha(Theme.disabled-content) : Theme.inverse-primary; } - // A segment sweeps while the toast shows (the work is moving, so the bar does too). - // Reduced motion: a still, dimmed full bar instead. - if root.data.progress-kind == ToastProgress.indeterminate && Motion.reduced: Rectangle { - background: Theme.inverse-primary.with-alpha(Theme.disabled-content); - } - if root.data.progress-kind == ToastProgress.indeterminate && !Motion.reduced && !root.leaving: Rectangle { - property phase: Math.mod(animation-tick() / Motion.indeterminate-period, 1); - - width: parent.width * 0.4; - x: -self.width + self.phase * (parent.width + self.width); - border-radius: parent.border-radius; - background: Theme.inverse-primary; + if bar.part < 1: Rectangle { + x: bar.done + Theme.space-1; + y: (bar.height - self.height) / 2; + width: max(0, bar.width - self.x); + height: bar.stroke; + border-radius: Theme.corner-full(self.height); + background: Theme.inverse-on-surface.with-alpha(Theme.disabled-container); } } } diff --git a/crates/tunal/ui/dialogs/confirm.slint b/crates/tunal/ui/dialogs/confirm.slint index 2568054..abda2fc 100644 --- a/crates/tunal/ui/dialogs/confirm.slint +++ b/crates/tunal/ui/dialogs/confirm.slint @@ -1,8 +1,10 @@ +import { Icons } from "../components/icon.slint"; import { Dialog } from "../components/dialog.slint"; import { ButtonKind } from "../components/button.slint"; // Asks before something that can't be undone. `answered(true)` runs it; Esc cancels. export component ConfirmDialog inherits Dialog { + glyph: Icons.delete; in property action-text: "Delete"; callback answered(bool); diff --git a/crates/tunal/ui/dialogs/conflict.slint b/crates/tunal/ui/dialogs/conflict.slint index 64ab318..fd56e9c 100644 --- a/crates/tunal/ui/dialogs/conflict.slint +++ b/crates/tunal/ui/dialogs/conflict.slint @@ -1,3 +1,4 @@ +import { Icons } from "../components/icon.slint"; import { Theme } from "../theme.slint"; import { Dialog } from "../components/dialog.slint"; import { ButtonKind } from "../components/button.slint"; @@ -46,6 +47,7 @@ component Side inherits VerticalLayout { // Asked when a copy, move or restore finds the name taken. `chosen(0|1|2, all)`: skip, // keep both (the new item gets a numbered name), replace. export component ConflictDialog inherits Dialog { + glyph: Icons.content-copy; in property info; in-out property apply-all; callback chosen(int, bool); diff --git a/crates/tunal/ui/dialogs/errors.slint b/crates/tunal/ui/dialogs/errors.slint index 8f24ed0..00ab377 100644 --- a/crates/tunal/ui/dialogs/errors.slint +++ b/crates/tunal/ui/dialogs/errors.slint @@ -1,3 +1,4 @@ +import { Icons } from "../components/icon.slint"; import { ListView } from "std-widgets.slint"; import { Theme } from "../theme.slint"; import { Dialog } from "../components/dialog.slint"; @@ -6,6 +7,7 @@ import { Dialog } from "../components/dialog.slint"; // owner sets `actions` (retry/skip/abort while a job waits, OK for the final list) and // `answered(i)` reports the button. export component ErrorsDialog inherits Dialog { + glyph: Icons.error; in property <[string]> lines; callback answered(int); diff --git a/crates/tunal/ui/dialogs/open-with.slint b/crates/tunal/ui/dialogs/open-with.slint index cc54e1f..5ba61e0 100644 --- a/crates/tunal/ui/dialogs/open-with.slint +++ b/crates/tunal/ui/dialogs/open-with.slint @@ -1,7 +1,7 @@ import { ListView } from "std-widgets.slint"; import { Theme } from "../theme.slint"; import { Motion } from "../motion.slint"; -import { Icon } from "../components/icon.slint"; +import { Icon, Icons } from "../components/icon.slint"; import { Dialog } from "../components/dialog.slint"; import { ButtonKind } from "../components/button.slint"; import { StateLayer } from "../components/state-layer.slint"; @@ -20,6 +20,7 @@ export struct AppRow { // Asks which application opens the files. `chosen(row, as-default)` runs on Open or a double // click; the owner closes the dialog. export component OpenWithDialog inherits Dialog { + glyph: Icons.open-in-new; in property <[AppRow]> apps; in-out property selected: -1; in-out property as-default; diff --git a/crates/tunal/ui/dialogs/properties.slint b/crates/tunal/ui/dialogs/properties.slint index c74f5e5..2b1e30e 100644 --- a/crates/tunal/ui/dialogs/properties.slint +++ b/crates/tunal/ui/dialogs/properties.slint @@ -96,6 +96,7 @@ component PermissionRow inherits HorizontalLayout { // Read-only facts about the selection; the folder size is counted in the background and // `info.scanning` shows while it grows. export component PropertiesDialog inherits Dialog { + glyph: Icons.info; in property info; callback closed(); diff --git a/crates/tunal/ui/dialogs/settings.slint b/crates/tunal/ui/dialogs/settings.slint index e351a30..757ad10 100644 --- a/crates/tunal/ui/dialogs/settings.slint +++ b/crates/tunal/ui/dialogs/settings.slint @@ -112,6 +112,7 @@ component ChoiceSetting inherits VerticalLayout { // The settings, one page at a time; the pages are listed on the left. export component SettingsDialog inherits Dialog { + glyph: Icons.settings; in-out property data; in-out property page; // The context menu editor (page 4). diff --git a/crates/tunal/ui/gallery.slint b/crates/tunal/ui/gallery.slint index f52d3f6..fc72227 100644 --- a/crates/tunal/ui/gallery.slint +++ b/crates/tunal/ui/gallery.slint @@ -1,5 +1,6 @@ import { Theme } from "theme.slint"; import { Icon, Icons } from "components/icon.slint"; +import { Shape, ShapeKind, FileShapes } from "components/shape.slint"; import { ForceState } from "components/state-layer.slint"; import { Tooltip } from "components/tooltip.slint"; import { Button, ButtonKind } from "components/button.slint"; @@ -89,6 +90,29 @@ export component Gallery inherits Window { } } + Row { + name: "Shapes"; + HorizontalLayout { + spacing: Theme.space-3; + for kind[i] in [ShapeKind.circle, ShapeKind.cookie4, ShapeKind.cookie6, ShapeKind.cookie9, ShapeKind.cookie12, ShapeKind.clover, ShapeKind.scallop]: Shape { + shape: kind; + size: 48px; + glyph: i == 0 ? Icons.folder : Icons.music-note; + fill: mod(i, 2) == 0 ? Theme.primary-container : Theme.tertiary-container; + glyph-color: mod(i, 2) == 0 ? Theme.on-primary-container : Theme.on-tertiary-container; + } + Shape { + shape: ShapeKind.circle; + active-shape: ShapeKind.cookie9; + active: true; + size: 48px; + glyph: Icons.check; + active-fill: Theme.primary; + glyph-color: Theme.on-primary; + } + } + } + Row { name: "Filled button"; for state[i] in root.states: Cell { @@ -235,6 +259,8 @@ export component Gallery inherits Window { ListRow { icon: Icons.folder; title: "Documents"; + shaped: true; + shape: ShapeKind.cookie6; force-state: state; enabled: i != root.disabled-column; } @@ -243,6 +269,8 @@ export component Gallery inherits Window { icon: Icons.folder; title: "Pictures"; selected: true; + shaped: true; + shape: ShapeKind.cookie6; force-state: state; enabled: i != root.disabled-column; } @@ -351,6 +379,11 @@ export component Gallery inherits Window { width: 360px; icon: i < 5 ? Icons.folder : Icons.description; title: name; + shaped: true; + shape: FileShapes.shape(self.icon); + active-shape: FileShapes.active-shape(self.icon); + shape-fill: FileShapes.fill(self.icon); + shape-ink: FileShapes.ink(self.icon); selected: i == 2; } } @@ -389,6 +422,7 @@ export component Gallery inherits Window { } dialog := Dialog { + glyph: Icons.create-new-folder; width: 100%; height: 100%; title: "Rename folder"; diff --git a/crates/tunal/ui/motion.slint b/crates/tunal/ui/motion.slint index c1d3e43..9082b2b 100644 --- a/crates/tunal/ui/motion.slint +++ b/crates/tunal/ui/motion.slint @@ -51,12 +51,16 @@ export global Motion { out property toast-timeout: 4s; // One sweep of an indeterminate progress bar. out property indeterminate-period: 1500ms; + // Time a wavy progress line takes to travel one wavelength. + out property wave-period: 1000ms; // Hover time before a tooltip shows. A delay, not motion: reduced motion keeps it. out property tooltip-delay: 500ms; // How far content slides when a folder opens in a direction of travel. out property travel-shift: 32px; + // How far content rises as it fades in when a folder opens. + out property rise-shift: 12px; public pure function time(d: duration) -> duration { reduced ? 0ms : d diff --git a/crates/tunal/ui/shapes.slint b/crates/tunal/ui/shapes.slint new file mode 100644 index 0000000..b1af927 --- /dev/null +++ b/crates/tunal/ui/shapes.slint @@ -0,0 +1,13 @@ +// Material 3 Expressive shapes for glyph containers. Each shape is a closed polar curve +// drawn in a 100 x 100 viewbox; Rust (`shapes.rs`) builds the path commands, so any two +// shapes can morph point by point. A pill is not a polar curve: use a Rectangle with +// `Theme.corner-full`. +export enum ShapeKind { circle, cookie4, cookie6, cookie9, cookie12, clover, scallop } + +export global Shapes { + // Path commands of `from` morphed `t` (0..1) of the way to `to`, turned `turn` degrees. + pure callback path(from: ShapeKind, to: ShapeKind, t: float, turn: float) -> string; + // A sine band `length` units long and `thickness` thick, its top line between 0 and + // 2 * `amplitude`, for wavy progress; `phase` in 0..1 shifts it by that share of a wavelength. + pure callback wave(length: float, wavelength: float, amplitude: float, thickness: float, phase: float) -> string; +} diff --git a/crates/tunal/ui/shell/breadcrumb.slint b/crates/tunal/ui/shell/breadcrumb.slint index 04f4c0f..a1ee8f2 100644 --- a/crates/tunal/ui/shell/breadcrumb.slint +++ b/crates/tunal/ui/shell/breadcrumb.slint @@ -20,11 +20,13 @@ component CrumbChip inherits StateLayer { in property glyph; in property last; - property content: root.last ? Theme.on-surface : Theme.on-surface-variant; + property content: root.last ? Theme.on-secondary-container : Theme.on-surface-variant; height: 32px; min-width: 32px; border-radius: Theme.corner-full(self.height); + // The current folder is a filled pill; the crumbs before it show only on hover. + background: root.last ? Theme.secondary-container : transparent; squeeze: Motion.squeeze; tint: root.content; focusable: false; @@ -214,7 +216,7 @@ export component CompletionList inherits Rectangle { height: root.shown * root.row-height + 2 * Theme.space-1; visible: root.shown > 0; - border-radius: Theme.corner-md; + border-radius: Theme.corner-menu; background: Theme.surface-container; drop-shadow-blur: Theme.float-shadow-blur; drop-shadow-offset-y: Theme.float-shadow-offset; @@ -226,7 +228,7 @@ export component CompletionList inherits Rectangle { y: Theme.space-1 + i * root.row-height; width: parent.width - 2 * Theme.space-1; height: root.row-height; - border-radius: Theme.corner-sm; + border-radius: Theme.corner-menu-item; focusable: false; background: i == root.highlight ? Theme.secondary-container : transparent; clicked => { diff --git a/crates/tunal/ui/shell/pane.slint b/crates/tunal/ui/shell/pane.slint index 417d151..5830fe2 100644 --- a/crates/tunal/ui/shell/pane.slint +++ b/crates/tunal/ui/shell/pane.slint @@ -51,7 +51,7 @@ export component Pane inherits Rectangle { property header-height: root.split ? 32px : 0; - border-radius: root.split ? Theme.corner-md : 0; + border-radius: root.split ? Theme.corner-lg : 0; clip: true; background: Theme.surface; diff --git a/crates/tunal/ui/shell/sidebar.slint b/crates/tunal/ui/shell/sidebar.slint index b18d173..347648b 100644 --- a/crates/tunal/ui/shell/sidebar.slint +++ b/crates/tunal/ui/shell/sidebar.slint @@ -4,6 +4,7 @@ import { Icon, Icons } from "../components/icon.slint"; import { IconButton } from "../components/icon-button.slint"; import { ListRow } from "../components/list-row.slint"; import { StateLayer } from "../components/state-layer.slint"; +import { ShapeKind } from "../components/shape.slint"; export struct PlaceItem { name: string, @@ -96,10 +97,11 @@ export component Sidebar inherits Rectangle { // Right click on an item, at window coordinates. callback item-menu(section: int, index: int, x: length, y: length); - property row-height: 40px; + property row-height: 44px; + // Resting shapes of the place glyphs, in turn; the current place morphs to a cookie9. + property <[ShapeKind]> shapes: [ShapeKind.cookie6, ShapeKind.clover, ShapeKind.cookie12, ShapeKind.scallop, ShapeKind.cookie4]; - background: Theme.surface-container-low; - animate background { duration: Motion.time(Motion.medium2); easing: Motion.standard; } + // On the window's surface-container: the sidebar has no fill of its own. Flickable { content-height: max(self.height, column.preferred-height); @@ -150,6 +152,8 @@ export component Sidebar inherits Rectangle { icon: item.glyph; title: item.name; selected: item.current; + shaped: true; + shape: root.shapes[mod(i, root.shapes.length)]; focusable: false; clicked => { root.open(s, i, false); diff --git a/crates/tunal/ui/shell/toolbar.slint b/crates/tunal/ui/shell/toolbar.slint index 18e5eb4..7db442d 100644 --- a/crates/tunal/ui/shell/toolbar.slint +++ b/crates/tunal/ui/shell/toolbar.slint @@ -50,7 +50,7 @@ export component Toolbar inherits Rectangle { HorizontalLayout { padding-left: Theme.space-2; padding-right: Theme.space-2; - spacing: Theme.space-1; + spacing: Theme.space-2; alignment: stretch; VerticalLayout { @@ -70,6 +70,7 @@ export component Toolbar inherits Rectangle { alignment: center; IconButton { icon: Icons.arrow-back; + tonal: true; enabled: root.can-back; tooltip: "Back (Alt+Left)"; clicked => { @@ -82,6 +83,7 @@ export component Toolbar inherits Rectangle { alignment: center; IconButton { icon: Icons.arrow-forward; + tonal: true; enabled: root.can-forward; tooltip: "Forward (Alt+Right)"; clicked => { @@ -94,6 +96,7 @@ export component Toolbar inherits Rectangle { alignment: center; IconButton { icon: Icons.arrow-upward; + tonal: true; enabled: root.can-up; tooltip: "Parent folder (Alt+Up)"; clicked => { @@ -141,6 +144,7 @@ export component Toolbar inherits Rectangle { alignment: center; IconButton { icon: Icons.more-vert; + tonal: true; tooltip: "File actions"; clicked => { root.actions(self.absolute-position.x + self.width, self.absolute-position.y + self.height); diff --git a/crates/tunal/ui/theme.slint b/crates/tunal/ui/theme.slint index 056d751..689d970 100644 --- a/crates/tunal/ui/theme.slint +++ b/crates/tunal/ui/theme.slint @@ -52,6 +52,18 @@ export global Theme { out property corner-md: 12px; out property corner-lg: 16px; out property corner-xl: 28px; + // Expressive surfaces: cards and panes, menus and their item pills. + out property corner-card: 24px; + out property corner-menu: 14px; + out property corner-menu-item: 10px; + // Degrees a shaped container turns while it morphs to its active shape. + out property shape-morph-turn: 20; + // Degrees a dialog's header shape turns through while the dialog opens. + out property shape-enter-turn: -60; + // Wavy progress line: stroke, height of the wave above its centre, one wavelength. + out property wave-stroke: 3px; + out property wave-amplitude: 2px; + out property wave-length: 20px; // Fully rounded ends for a shape of the given height. public pure function corner-full(height: length) -> length { height / 2 @@ -69,11 +81,19 @@ export global Theme { out property hairline: 1px; // Floating surfaces (menus, dialogs, toasts, tooltips): one soft shadow, mixed from - // `shadow`. Resting surfaces have none. - out property float-shadow-blur: 24px; - out property float-shadow-offset: 6px; - // Dark surfaces need a deeper shadow to read as lifted. - out property float-shadow-opacity: root.dark ? 0.59 : 0.27; + // `shadow`. Resting surfaces have none except the content card's faint lift. + // Values from the design references (Nacre): popups (menus, toasts, tooltips) lie close, + // dialogs higher; dark surfaces need a deeper shadow to read as lifted. + out property float-shadow-blur: 10px; + out property float-shadow-offset: 2px; + out property float-shadow-opacity: root.dark ? 0.31 : 0.13; + out property dialog-shadow-blur: 16px; + out property dialog-shadow-offset: 4px; + out property dialog-shadow-opacity: root.dark ? 0.35 : 0.16; + // The content card rests just above the window. + out property card-shadow-blur: 6px; + out property card-shadow-offset: 1px; + out property card-shadow-opacity: root.dark ? 0.24 : 0.08; // Dims the window behind a modal dialog, mixed from `scrim`. out property scrim-opacity: 0.32; // Gap kept between a floating surface and the window edge. diff --git a/crates/tunal/ui/views/details-view.slint b/crates/tunal/ui/views/details-view.slint index 8c1d4aa..1eaeae8 100644 --- a/crates/tunal/ui/views/details-view.slint +++ b/crates/tunal/ui/views/details-view.slint @@ -4,6 +4,7 @@ import { Motion } from "../motion.slint"; import { Icon, Icons } from "../components/icon.slint"; import { ForceState, StateLayer } from "../components/state-layer.slint"; import { ListRow } from "../components/list-row.slint"; +import { FileShapes } from "../components/shape.slint"; import { IconButton } from "../components/icon-button.slint"; import { Chip, ChipKind } from "../components/chip.slint"; @@ -371,6 +372,7 @@ export component DetailsView inherits Rectangle { in property motion: 1; in property travel-x; in property travel-opacity: 1; + in property travel-y; callback sort-by(SortColumn); // Window coordinates of the point the sort menu should open at. @@ -549,6 +551,7 @@ export component DetailsView inherits Rectangle { Rectangle { x: root.travel-x; + y: root.travel-y; opacity: root.travel-opacity; list := ListView { @@ -586,6 +589,12 @@ export component DetailsView inherits Rectangle { focusable: false; icon: row.glyph; badge: row.badge; + shaped: true; + shape-size: 32px; + shape: FileShapes.shape(row.glyph); + active-shape: FileShapes.active-shape(row.glyph); + shape-fill: FileShapes.fill(row.glyph); + shape-ink: FileShapes.ink(row.glyph); title: row.name; selected: row.selected; editing: row.editing; diff --git a/crates/tunal/ui/views/grid-view.slint b/crates/tunal/ui/views/grid-view.slint index 207a5b2..5cd4ff1 100644 --- a/crates/tunal/ui/views/grid-view.slint +++ b/crates/tunal/ui/views/grid-view.slint @@ -3,6 +3,7 @@ import { Theme } from "../theme.slint"; import { Motion } from "../motion.slint"; import { Icon, Icons } from "../components/icon.slint"; import { ForceState, StateLayer } from "../components/state-layer.slint"; +import { Shape, FileShapes } from "../components/shape.slint"; import { RenameField } from "../components/rename-field.slint"; import { IconButton } from "../components/icon-button.slint"; import { @@ -24,12 +25,12 @@ export struct GridRow { global Grid { out property min-cell-width: 112px; out property cell-height: 116px; - out property icon-size: 48px; + out property icon-size: 56px; // Gap around each cell's shape, inside its slot. out property gap: Theme.space-1; } -// One entry of the grid: icon over a two-line name. Selection grows a tonal fill like a +// One entry of the grid: a rounded card with a shaped glyph over a two-line name. Selection grows a tonal fill like a // list row's; the cursor shows the focus ring while the view has focus. component GridCell inherits StateLayer { in property entry; @@ -41,7 +42,9 @@ component GridCell inherits StateLayer { property content: root.entry.selected ? Theme.on-secondary-container : Theme.on-surface-variant; focusable: false; - border-radius: Theme.corner-md; + // A resting card; selection fills it with the tonal role. + border-radius: Theme.corner-lg; + background: Theme.surface-container-low; squeeze: Motion.squeeze; ring-offset: -Theme.focus-ring-width; force-state: root.cursor-ring ? ForceState.focused : ForceState.none; @@ -73,22 +76,23 @@ component GridCell inherits StateLayer { HorizontalLayout { alignment: center; - Rectangle { - width: Grid.icon-size; - height: Grid.icon-size; - - Icon { - glyph: root.entry.glyph; - size: Grid.icon-size; - color: root.content; - } + Shape { + size: Grid.icon-size; + shape: FileShapes.shape(root.entry.glyph); + active-shape: FileShapes.active-shape(root.entry.glyph); + active: root.entry.selected; + fill: FileShapes.fill(root.entry.glyph); + active-fill: Theme.primary; + glyph: root.entry.glyph; + glyph-color: root.entry.selected ? Theme.on-primary : FileShapes.ink(root.entry.glyph); + glyph-ratio: 0.5; if root.entry.badge != "": Icon { x: parent.width - self.width; y: parent.height - self.height; glyph: root.entry.badge; size: 18px; - color: root.entry.selected ? Theme.on-secondary-container : Theme.primary; + color: Theme.primary; } } } @@ -130,6 +134,7 @@ export component GridView inherits Rectangle { in property motion: 1; in property travel-x; in property travel-opacity: 1; + in property travel-y; callback sort-by(SortColumn); callback open-sort-menu(length, length); @@ -290,6 +295,7 @@ export component GridView inherits Rectangle { Rectangle { x: root.travel-x; + y: root.travel-y; opacity: root.travel-opacity; list := ListView { diff --git a/crates/tunal/ui/views/view-switch.slint b/crates/tunal/ui/views/view-switch.slint index 8a35133..27d6d85 100644 --- a/crates/tunal/ui/views/view-switch.slint +++ b/crates/tunal/ui/views/view-switch.slint @@ -141,6 +141,8 @@ export component FolderView inherits Rectangle { : root.state.travel == Travel.none ? 0 : -1; property travel-x: Motion.travel-shift * root.travel-side * (1 - root.travel-settle); property travel-opacity: travel-clock.running ? root.travel-settle : 1; + // Content also rises a little as it fades in, whichever way it came. + property travel-y: Motion.rise-shift * (1 - root.travel-settle); background: Theme.surface; @@ -150,6 +152,7 @@ export component FolderView inherits Rectangle { motion: list-clock.progress; travel-x: root.travel-x; travel-opacity: root.travel-opacity; + travel-y: root.travel-y; opacity: root.grid ? 0 : 1; visible: self.opacity > 0; animate opacity { duration: Motion.time(Motion.short4); easing: Motion.standard; } @@ -201,6 +204,7 @@ export component FolderView inherits Rectangle { motion: list-clock.progress; travel-x: root.travel-x; travel-opacity: root.travel-opacity; + travel-y: root.travel-y; opacity: root.grid ? 1 : 0; visible: self.opacity > 0; animate opacity { duration: Motion.time(Motion.short4); easing: Motion.standard; } diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 8579921..f0eb8c8 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -128,5 +128,14 @@ One entry per session, newest last, ≤ 15 lines: done, verified how, not done, - Not done: no live window (double-click open, portal call, a real launch); Alt+Enter shortcut; mixed file+folder selection with Open sends folders to the portal. - Later: properties editing (permissions, owner); open folders in new tabs; Alt+Enter; icons loaded lazily for long lists. +## S038 — Expressive restyle +- Done: `ui/shapes.slint` `ShapeKind { circle, cookie4, cookie6, cookie9, cookie12, clover, scallop }` + `Shapes.path(from, to, t, turn)` / `Shapes.wave(length, wavelength, amplitude, thickness, phase)` (Rust `shapes.rs`, polar curves in a 100x100 viewbox, resting shapes cached; set in `theme_bridge::apply`). `components/shape.slint` **`Shape`** (`shape`, `active-shape`, `active` morphs + turns `Theme.shape-morph-turn`, `turn`, `fill`/`active-fill`, `glyph`, `glyph-color`, `size`, `glyph-ratio`, `@children` for badges) and `FileShapes.shape/active-shape/fill/ink(glyph)` (folder cookie9 primary, media tertiary, others secondary). Pill = Rectangle + `corner-full`. +- `StateLayer` ripple (on by default, `ripple: false` to opt out): spreads from the left-press point over `MotionClock`, fades after release; flat tint stays at hover strength while pressed. `ListRow.shaped` (+ `shape`, `active-shape`, `shape-size`, `shape-fill`, `shape-ink`): selected morphs to the active shape on `primary`. `IconButton.tonal` (resting circle) and toggles morph circle → cookie9. +- Tokens: `corner-card` 24, `corner-menu` 14, `corner-menu-item` 10, `shape-morph-turn`, `shape-enter-turn`, `wave-stroke/amplitude/length`, `dialog-shadow-*`, `card-shadow-*` (float shadow now the design refs' popup values); `Motion.rise-shift`, `Motion.wave-period`. Icons: settings + file categories. +- Shell: window on `surface-container`, content (toolbar, panes, status) on a rounded `surface` card with a faint lift; sidebar rows shaped (resting shapes cycle, current = cookie9); tonal toolbar circles; current crumb a filled pill. Views: shaped glyphs per category in rows (32 px) and grid (56 px, tiles are `surface-container-low` cards); content rises `rise-shift` as it fades in. `Dialog.glyph` (cookie6 that turns in while opening, centred title; set on every dialog); menus 14 px with 36 px item pills; toasts 56 px, `corner-lg`, wavy progress (moves only while the job runs, still under reduced motion). +- Verified: workspace build, clippy -D warnings, fmt --check, literal grep empty; looked at gallery light/dark, shell light (split, real places), music folder dark, grid dark, menu + toasts, dialog dark, settings dialog. +- Not done: ripple/morph motion not watched (single frames); the software renderer draws stroked paths unevenly, so the wave is a filled band. Settings page list still plain rows. +- Later: tune clover depth (reads like a plus); shaped rows in the settings nav. + ## Later -