S038: expressive restyle with shaped containers, ripples and rounded surfaces

Shape library (cookies, clover, scallop) with morphing Shape component,
press ripple in StateLayer, content card shell, shaped file glyphs,
card grid tiles, dialog header shapes, menu pills, wavy toast progress.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-18 19:24:41 -06:00
commit 321ce8c244
32 changed files with 535 additions and 87 deletions

View file

@ -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.

View file

@ -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

View file

@ -9,6 +9,7 @@ mod open;
mod properties;
mod screenshot;
mod settings;
mod shapes;
mod shell;
mod theme_bridge;

101
crates/tunal/src/shapes.rs Normal file
View file

@ -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<HashMap<i32, SharedString>> = 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()
}

View file

@ -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::<MotionPrefs>()
}
fn shapes(&self) -> Shapes<'_> {
self.global::<Shapes>()
}
})*
};
}
@ -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);

View file

@ -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";

View file

@ -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 <string> title;
// Glyph from `Icons` shown in a cookie above the title, which then centres; empty for none.
in property <string> glyph;
in property <string> 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;

View file

@ -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 <string> icon;
in property <bool> toggle;
// A tonal circle at rest (toolbar buttons) instead of a bare glyph.
in property <bool> tonal;
in-out property <bool> checked;
in property <length> size: 40px;
in property <length> 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;

View file

@ -55,4 +55,13 @@ export global Icons {
out property <string> drag-handle: "\u{e945}";
out property <string> restore: "\u{e8b3}";
out property <string> create-new-folder: "\u{e2cc}";
out property <string> settings: "\u{e8b8}";
// File categories (icons.rs).
out property <string> image: "\u{e3f4}";
out property <string> audio: "\u{eb82}";
out property <string> video: "\u{eb87}";
out property <string> code: "\u{e86f}";
out property <string> pdf: "\u{e415}";
out property <string> archive: "\u{eb2c}";
out property <string> program: "\u{eb8e}";
}

View file

@ -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 <string> title;
in property <string> supporting;
in property <bool> selected;
// Draws the icon in a shaped tonal container that morphs to `active-shape` when selected.
in property <bool> shaped;
in property <ShapeKind> shape: ShapeKind.circle;
in property <ShapeKind> active-shape: ShapeKind.cookie9;
in property <length> shape-size: 36px;
in property <color> shape-fill: Theme.secondary-container;
in property <color> shape-ink: Theme.on-secondary-container;
// Shows the title as an edit field (see RenameField); `edit-select` bytes are preselected.
in property <bool> editing;
in property <int> 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 {

View file

@ -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 <Point> 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 <length> row-y: surface.y + root.sub-row-y - Theme.space-1;
property <length> 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;

View file

@ -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 <ShapeKind> shape: ShapeKind.circle;
in property <ShapeKind> active-shape: root.shape;
in property <bool> active;
// Degrees the outline is turned; the active outline turns a little more as it morphs.
in property <float> turn;
in property <brush> fill: Theme.secondary-container;
in property <brush> active-fill: root.fill;
in property <string> glyph;
in property <color> glyph-color: Theme.on-secondary-container;
in property <length> size: 40px;
// Glyph size as a share of the container.
in property <float> glyph-ratio: 0.55;
// 0 = `shape`, 1 = `active-shape`.
property <float> 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
}

View file

@ -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 <length> ring-offset: Theme.focus-ring-offset;
// Off for rows of a list that owns the keyboard itself: no Tab stop per row.
in property <bool> focusable: true;
// Press ripple spreading from the pointer; off for controls that draw their own press.
in property <bool> ripple: true;
out property <bool> hovered: enabled && (touch.has-hover || force-state == ForceState.hover);
out property <bool> pressed: enabled && (touch.pressed || force-state == ForceState.pressed);
out property <bool> focused: enabled && (keyboard-focus || force-state == ForceState.focused);
out property <float> 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 <float> 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 <length> ripple-x: root.width / 2;
property <length> ripple-y: root.height / 2;
property <int> ripple-epoch;
property <length> 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 <float> 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 <float> 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;

View file

@ -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 <length> stroke: Theme.wave-stroke;
property <length> amplitude: Theme.wave-amplitude;
property <float> part: root.data.progress-kind == ToastProgress.determinate ? clamp(root.data.progress, 0, 1) : 1;
property <length> done: self.width * self.shown;
property <float> shown: self.part;
property <float> 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 <float> 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);
}
}
}

View file

@ -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 <string> action-text: "Delete";
callback answered(bool);

View file

@ -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 <ConflictInfo> info;
in-out property <bool> apply-all;
callback chosen(int, bool);

View file

@ -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);

View file

@ -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 <int> selected: -1;
in-out property <bool> as-default;

View file

@ -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 <PropertiesInfo> info;
callback closed();

View file

@ -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 <SettingsData> data;
in-out property <int> page;
// The context menu editor (page 4).

Some files were not shown because too many files have changed in this diff Show more