S003: window, Theme and Motion tokens, theme bridge, screenshot command
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
parent
7f94978bfb
commit
89b60028eb
17 changed files with 496 additions and 18 deletions
|
|
@ -82,7 +82,7 @@ Never modify: `PROMPT.md` (the user's brief), the reference app checkout (`/home
|
|||
| `cargo clippy --workspace --all-targets -- -D warnings`, `cargo fmt --check` | lint, format | phase 1 |
|
||||
| `busctl --user call org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings ReadOne ss org.freedesktop.appearance accent-color` | inspect portal values | now |
|
||||
| `fc-list` | check bundled/system fonts | now |
|
||||
| Screenshot harness (software renderer → PNG, light/dark, hover/press, empty/full, min size) | visual checks | phase 2 (plan adds its exact command here) |
|
||||
| `cargo run -p tunal -- --screenshot <png> [--dark] [--size WxH]` (software renderer, offscreen, default 960x640; env `TUNAL_SEED=#rrggbb`, `TUNAL_REDUCED_MOTION=1`) | single-PNG visual check; full state matrix in phase 12 | S003 |
|
||||
|
||||
Don't assume a tool exists: check first. When your plan creates a tool, add its row here.
|
||||
|
||||
|
|
|
|||
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -4553,8 +4553,10 @@ checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31"
|
|||
name = "tunal"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"png",
|
||||
"slint",
|
||||
"slint-build",
|
||||
"tunal-theme",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -13,3 +13,4 @@ slint = "1.19"
|
|||
slint-build = "1.19"
|
||||
zbus = { version = "5.19", default-features = false, features = ["async-io", "blocking-api"] }
|
||||
material-colors = "0.5"
|
||||
png = "0.18"
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ The app window themed from the portal with live re-theme, the `Theme` and `Motio
|
|||
CLAUDE.md §2 Theme/Icons/Motion rules, §3, §4; `app-taste` skill; crates/tunal-theme public API.
|
||||
|
||||
## Steps
|
||||
- [ ] `build.rs` with `slint-build`, std-widgets style `material`; import the bundled Material Symbols font in Slint.
|
||||
- [ ] `Theme` global: colour roles, shape (corner radii xs…xl, full), type scale, spacing grid (4 px), state-layer opacities. `Motion` global: M3 durations and easings, `reduced` flag; a helper so durations become 0 when reduced.
|
||||
- [ ] Theme bridge: apply the palette at start; watcher → `invoke_from_event_loop` → update `Theme`; env overrides `TUNAL_SEED=#rrggbb`, `TUNAL_SCHEME=light|dark`, `TUNAL_REDUCED_MOTION=1` for agents.
|
||||
- [ ] `Icon` component: glyph by codepoint, size, weight, fill (check which variable axes Slint 1.19 can set; fall back to the default instance).
|
||||
- [ ] Window: title, `assets/tunal.png` icon, minimum size (choose and record in DECISIONS.md), placeholder layout (sidebar + content).
|
||||
- [ ] `tunal --screenshot <png> [--dark] [--size WxH]`: render offscreen with the software renderer to PNG and exit. Add its row to CLAUDE.md §5 (single PNG; the full state matrix comes in phase 12).
|
||||
- [ ] PROGRESS entry, INDEX line, commit `S003: …`
|
||||
- [x] `build.rs` with `slint-build`, std-widgets style `material`; import the bundled Material Symbols font in Slint.
|
||||
- [x] `Theme` global: colour roles, shape (corner radii xs…xl, full), type scale, spacing grid (4 px), state-layer opacities. `Motion` global: M3 durations and easings, `reduced` flag; a helper so durations become 0 when reduced.
|
||||
- [x] Theme bridge: apply the palette at start; watcher → `invoke_from_event_loop` → update `Theme`; env overrides `TUNAL_SEED=#rrggbb`, `TUNAL_SCHEME=light|dark`, `TUNAL_REDUCED_MOTION=1` for agents.
|
||||
- [x] `Icon` component: glyph by codepoint, size, weight, fill (check which variable axes Slint 1.19 can set; fall back to the default instance).
|
||||
- [x] Window: title, `assets/tunal.png` icon, minimum size (choose and record in DECISIONS.md), placeholder layout (sidebar + content).
|
||||
- [x] `tunal --screenshot <png> [--dark] [--size WxH]`: render offscreen with the software renderer to PNG and exit. Add its row to CLAUDE.md §5 (single PNG; the full state matrix comes in phase 12).
|
||||
- [x] PROGRESS entry, INDEX line, commit `S003: …`
|
||||
|
||||
## End criteria
|
||||
- `cargo build --workspace`, `cargo clippy --workspace --all-targets -- -D warnings` and `cargo fmt --check` pass.
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ Tracker: https://claude.ai/artifact/4X8YCk3cQjUGyuyCqGuU7v
|
|||
## 02 App skeleton
|
||||
|
||||
- [x] [S002 — Portal theme and Material schemes](02%20App%20skeleton/S002-theme-portal.md) · Opus high
|
||||
- [ ] [S003 — Window, Theme and Motion globals, screenshot command](02%20App%20skeleton/S003-window-tokens.md) · Opus high
|
||||
- [x] [S003 — Window, Theme and Motion globals, screenshot command](02%20App%20skeleton/S003-window-tokens.md) · Opus high
|
||||
- [ ] [S004 — Base animated controls](02%20App%20skeleton/S004-base-controls.md) · Opus high
|
||||
- [ ] [S005 — Menus, dialogs and toasts](02%20App%20skeleton/S005-menus-dialogs.md) · Opus high
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ publish.workspace = true
|
|||
|
||||
[dependencies]
|
||||
slint.workspace = true
|
||||
tunal-theme = { path = "../tunal-theme" }
|
||||
png.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
slint-build.workspace = true
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
fn main() {
|
||||
slint_build::compile("ui/main.slint").expect("failed to compile the Slint UI");
|
||||
let config = slint_build::CompilerConfiguration::new().with_style("material".into());
|
||||
slint_build::compile_with_config("ui/app.slint", config)
|
||||
.expect("failed to compile the Slint UI");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,58 @@
|
|||
mod screenshot;
|
||||
mod theme_bridge;
|
||||
|
||||
use std::process::ExitCode;
|
||||
|
||||
use slint::ComponentHandle;
|
||||
|
||||
slint::include_modules!();
|
||||
|
||||
fn main() -> Result<(), slint::PlatformError> {
|
||||
MainWindow::new()?.run()
|
||||
const USAGE: &str = "usage: tunal [--screenshot <png> [--dark] [--size WxH]]";
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
let result = if args.is_empty() {
|
||||
run().map_err(|e| e.to_string())
|
||||
} else {
|
||||
parse_screenshot(&args).and_then(screenshot::run)
|
||||
};
|
||||
match result {
|
||||
Ok(()) => ExitCode::SUCCESS,
|
||||
Err(message) => {
|
||||
eprintln!("tunal: {message}");
|
||||
ExitCode::FAILURE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn run() -> Result<(), slint::PlatformError> {
|
||||
let ui = MainWindow::new()?;
|
||||
theme_bridge::start(&ui, theme_bridge::Overrides::from_env());
|
||||
ui.run()
|
||||
}
|
||||
|
||||
fn parse_screenshot(args: &[String]) -> Result<screenshot::Options, String> {
|
||||
let mut options = screenshot::Options {
|
||||
path: String::new(),
|
||||
dark: false,
|
||||
size: (960, 640),
|
||||
};
|
||||
let mut args = args.iter();
|
||||
while let Some(arg) = args.next() {
|
||||
match arg.as_str() {
|
||||
"--screenshot" => options.path = args.next().ok_or(USAGE)?.clone(),
|
||||
"--dark" => options.dark = true,
|
||||
"--size" => {
|
||||
let size = args.next().ok_or(USAGE)?;
|
||||
let (w, h) = size.split_once('x').ok_or(USAGE)?;
|
||||
let parse = |n: &str| n.parse::<u32>().ok().filter(|&n| n > 0).ok_or(USAGE);
|
||||
options.size = (parse(w)?, parse(h)?);
|
||||
}
|
||||
_ => return Err(USAGE.into()),
|
||||
}
|
||||
}
|
||||
if options.path.is_empty() {
|
||||
return Err(USAGE.into());
|
||||
}
|
||||
Ok(options)
|
||||
}
|
||||
|
|
|
|||
73
crates/tunal/src/screenshot.rs
Normal file
73
crates/tunal/src/screenshot.rs
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
//! `tunal --screenshot`: renders the window offscreen with the software renderer to a PNG.
|
||||
|
||||
use std::{fs::File, io::BufWriter, path::Path, rc::Rc};
|
||||
|
||||
use slint::{
|
||||
ComponentHandle, PhysicalSize,
|
||||
platform::{
|
||||
Platform, PlatformError, WindowAdapter,
|
||||
software_renderer::{MinimalSoftwareWindow, PremultipliedRgbaColor, RepaintBufferType},
|
||||
},
|
||||
};
|
||||
use tunal_theme::ColorScheme;
|
||||
|
||||
use crate::{
|
||||
MainWindow,
|
||||
theme_bridge::{self, Overrides},
|
||||
};
|
||||
|
||||
struct Offscreen(Rc<MinimalSoftwareWindow>);
|
||||
|
||||
impl Platform for Offscreen {
|
||||
fn create_window_adapter(&self) -> Result<Rc<dyn WindowAdapter>, PlatformError> {
|
||||
Ok(self.0.clone())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Options {
|
||||
pub path: String,
|
||||
pub dark: bool,
|
||||
pub size: (u32, u32),
|
||||
}
|
||||
|
||||
pub fn run(options: Options) -> Result<(), String> {
|
||||
let window = MinimalSoftwareWindow::new(RepaintBufferType::NewBuffer);
|
||||
slint::platform::set_platform(Box::new(Offscreen(window.clone())))
|
||||
.map_err(|e| e.to_string())?;
|
||||
let ui = MainWindow::new().map_err(|e| e.to_string())?;
|
||||
let scheme = if options.dark {
|
||||
ColorScheme::Dark
|
||||
} else {
|
||||
ColorScheme::Light
|
||||
};
|
||||
let overrides = Overrides {
|
||||
scheme: Some(scheme),
|
||||
..Overrides::from_env()
|
||||
};
|
||||
theme_bridge::apply(&ui, &tunal_theme::read(), overrides);
|
||||
|
||||
let (width, height) = options.size;
|
||||
window.set_size(PhysicalSize::new(width, height));
|
||||
ui.show().map_err(|e| e.to_string())?;
|
||||
let mut pixels = vec![PremultipliedRgbaColor::default(); (width * height) as usize];
|
||||
window.request_redraw();
|
||||
window.draw_if_needed(|renderer| {
|
||||
renderer.render(&mut pixels, width as usize);
|
||||
});
|
||||
ui.hide().map_err(|e| e.to_string())?;
|
||||
|
||||
// The window background is opaque, so premultiplied equals straight alpha here.
|
||||
let bytes: Vec<u8> = pixels
|
||||
.iter()
|
||||
.flat_map(|p| [p.red, p.green, p.blue, p.alpha])
|
||||
.collect();
|
||||
write_png(Path::new(&options.path), width, height, &bytes)
|
||||
.map_err(|e| format!("couldn't write {}: {e}", options.path))
|
||||
}
|
||||
|
||||
fn write_png(path: &Path, width: u32, height: u32, rgba: &[u8]) -> Result<(), png::EncodingError> {
|
||||
let mut encoder = png::Encoder::new(BufWriter::new(File::create(path)?), width, height);
|
||||
encoder.set_color(png::ColorType::Rgba);
|
||||
encoder.set_depth(png::BitDepth::Eight);
|
||||
encoder.write_header()?.write_image_data(rgba)
|
||||
}
|
||||
113
crates/tunal/src/theme_bridge.rs
Normal file
113
crates/tunal/src/theme_bridge.rs
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
//! Feeds the desktop appearance (and agent overrides) into the Slint `Theme` and `MotionPrefs`.
|
||||
|
||||
use slint::{Color, ComponentHandle};
|
||||
use tunal_theme::{Appearance, ColorScheme, Palette, Palettes};
|
||||
|
||||
use crate::{MainWindow, MotionPrefs, Theme};
|
||||
|
||||
/// 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.
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct Overrides {
|
||||
pub seed: Option<u32>,
|
||||
pub scheme: Option<ColorScheme>,
|
||||
pub reduced_motion: bool,
|
||||
}
|
||||
|
||||
impl Overrides {
|
||||
pub fn from_env() -> Self {
|
||||
let var = |name| std::env::var(name).ok().filter(|v: &String| !v.is_empty());
|
||||
let seed = var("TUNAL_SEED").and_then(|v| {
|
||||
let hex = v.strip_prefix('#').filter(|h| h.len() == 6);
|
||||
let seed = hex.and_then(|h| u32::from_str_radix(h, 16).ok());
|
||||
if seed.is_none() {
|
||||
eprintln!("tunal: ignoring TUNAL_SEED={v:?}, expected #rrggbb");
|
||||
}
|
||||
seed
|
||||
});
|
||||
let scheme = var("TUNAL_SCHEME").and_then(|v| match v.as_str() {
|
||||
"light" => Some(ColorScheme::Light),
|
||||
"dark" => Some(ColorScheme::Dark),
|
||||
_ => {
|
||||
eprintln!("tunal: ignoring TUNAL_SCHEME={v:?}, expected light or dark");
|
||||
None
|
||||
}
|
||||
});
|
||||
let reduced_motion = var("TUNAL_REDUCED_MOTION").is_some_and(|v| v == "1");
|
||||
Self {
|
||||
seed,
|
||||
scheme,
|
||||
reduced_motion,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Reads the portal, applies it, and keeps the UI in step with later changes.
|
||||
pub fn start(ui: &MainWindow, overrides: Overrides) {
|
||||
apply(ui, &tunal_theme::read(), overrides);
|
||||
let weak = ui.as_weak();
|
||||
tunal_theme::watch(move |appearance| {
|
||||
// Fails only once the event loop has quit; nothing left to theme then.
|
||||
let _ = weak.upgrade_in_event_loop(move |ui| apply(&ui, &appearance, overrides));
|
||||
});
|
||||
}
|
||||
|
||||
pub fn apply(ui: &MainWindow, appearance: &Appearance, overrides: Overrides) {
|
||||
let seed = overrides.seed.unwrap_or_else(|| appearance.seed());
|
||||
let scheme = overrides.scheme.unwrap_or(appearance.scheme);
|
||||
let palettes = Palettes::from_seed(seed);
|
||||
let palette = match scheme {
|
||||
ColorScheme::Light => palettes.light,
|
||||
ColorScheme::Dark => palettes.dark,
|
||||
};
|
||||
let theme = ui.global::<Theme>();
|
||||
theme.set_dark(scheme == ColorScheme::Dark);
|
||||
set_colors(&theme, &palette);
|
||||
let reduced = overrides.reduced_motion || appearance.animations == Some(false);
|
||||
ui.global::<MotionPrefs>().set_reduced(reduced);
|
||||
}
|
||||
|
||||
macro_rules! colors {
|
||||
($($role:ident: $setter:ident),* $(,)?) => {
|
||||
fn set_colors(theme: &Theme, palette: &Palette) {
|
||||
$(theme.$setter(Color::from_argb_encoded(palette.$role));)*
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
colors!(
|
||||
primary: set_primary,
|
||||
on_primary: set_on_primary,
|
||||
primary_container: set_primary_container,
|
||||
on_primary_container: set_on_primary_container,
|
||||
inverse_primary: set_inverse_primary,
|
||||
secondary: set_secondary,
|
||||
on_secondary: set_on_secondary,
|
||||
secondary_container: set_secondary_container,
|
||||
on_secondary_container: set_on_secondary_container,
|
||||
tertiary: set_tertiary,
|
||||
on_tertiary: set_on_tertiary,
|
||||
tertiary_container: set_tertiary_container,
|
||||
on_tertiary_container: set_on_tertiary_container,
|
||||
error: set_error,
|
||||
on_error: set_on_error,
|
||||
error_container: set_error_container,
|
||||
on_error_container: set_on_error_container,
|
||||
surface: set_surface,
|
||||
surface_dim: set_surface_dim,
|
||||
surface_bright: set_surface_bright,
|
||||
surface_container_lowest: set_surface_container_lowest,
|
||||
surface_container_low: set_surface_container_low,
|
||||
surface_container: set_surface_container,
|
||||
surface_container_high: set_surface_container_high,
|
||||
surface_container_highest: set_surface_container_highest,
|
||||
on_surface: set_on_surface,
|
||||
surface_variant: set_surface_variant,
|
||||
on_surface_variant: set_on_surface_variant,
|
||||
inverse_surface: set_inverse_surface,
|
||||
inverse_on_surface: set_inverse_on_surface,
|
||||
outline: set_outline,
|
||||
outline_variant: set_outline_variant,
|
||||
shadow: set_shadow,
|
||||
scrim: set_scrim,
|
||||
);
|
||||
83
crates/tunal/ui/app.slint
Normal file
83
crates/tunal/ui/app.slint
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
import "../../../assets/fonts/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].ttf";
|
||||
import { Theme } from "theme.slint";
|
||||
import { Motion, MotionPrefs } from "motion.slint";
|
||||
import { Icon, Icons } from "components/icon.slint";
|
||||
|
||||
export { Theme, MotionPrefs }
|
||||
|
||||
// Placeholder shell (sidebar + content) until the views land.
|
||||
export component MainWindow inherits Window {
|
||||
title: "Tunal";
|
||||
icon: @image-url("../../../assets/tunal.png");
|
||||
min-width: 720px;
|
||||
min-height: 480px;
|
||||
preferred-width: 960px;
|
||||
preferred-height: 640px;
|
||||
background: Theme.surface;
|
||||
animate background { duration: Motion.time(Motion.medium2); easing: Motion.standard; }
|
||||
|
||||
HorizontalLayout {
|
||||
sidebar := Rectangle {
|
||||
width: 240px;
|
||||
background: Theme.surface-container-low;
|
||||
animate background { duration: Motion.time(Motion.medium2); easing: Motion.standard; }
|
||||
|
||||
VerticalLayout {
|
||||
padding: Theme.space-3;
|
||||
spacing: Theme.space-1;
|
||||
alignment: start;
|
||||
|
||||
HorizontalLayout {
|
||||
padding-left: Theme.space-4;
|
||||
padding-right: Theme.space-4;
|
||||
height: 40px;
|
||||
spacing: Theme.space-3;
|
||||
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Icon { glyph: Icons.home; }
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "Home";
|
||||
color: Theme.on-surface;
|
||||
font-size: Theme.label-large.size;
|
||||
font-weight: Theme.label-large.weight;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
spacing: Theme.space-2;
|
||||
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
Icon {
|
||||
glyph: Icons.folder;
|
||||
size: 48px;
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "No folder open";
|
||||
color: Theme.on-surface;
|
||||
font-size: Theme.title-medium.size;
|
||||
font-weight: Theme.title-medium.weight;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "Folders you open appear here";
|
||||
color: Theme.on-surface-variant;
|
||||
font-size: Theme.body-medium.size;
|
||||
font-weight: Theme.body-medium.weight;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
26
crates/tunal/ui/components/icon.slint
Normal file
26
crates/tunal/ui/components/icon.slint
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { Theme } from "../theme.slint";
|
||||
|
||||
// A Material Symbols Rounded glyph. Slint 1.19 exposes no variation axes and font-weight
|
||||
// does not reach the font's wght axis, so every glyph is the default instance
|
||||
// (wght 400, FILL 0, GRAD 0, opsz 24).
|
||||
export component Icon inherits Text {
|
||||
// The glyph as a one-character string, e.g. "\u{e2c7}" (see Icons).
|
||||
in property <string> glyph;
|
||||
in property <length> size: 24px;
|
||||
|
||||
text: glyph;
|
||||
font-family: Theme.icon-font;
|
||||
font-size: size;
|
||||
color: Theme.on-surface-variant;
|
||||
width: size;
|
||||
height: size;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
accessible-role: none;
|
||||
}
|
||||
|
||||
// Codepoints of the glyphs in use.
|
||||
export global Icons {
|
||||
out property <string> folder: "\u{e2c7}";
|
||||
out property <string> home: "\u{e88a}";
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
export component MainWindow inherits Window {
|
||||
title: "Tunal";
|
||||
icon: @image-url("../../../assets/tunal.png");
|
||||
preferred-width: 960px;
|
||||
preferred-height: 640px;
|
||||
}
|
||||
37
crates/tunal/ui/motion.slint
Normal file
37
crates/tunal/ui/motion.slint
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// Motion tokens: Material 3 durations and easings. Wrap every duration in `Motion.time()`
|
||||
// so reduced motion makes it instant.
|
||||
|
||||
// The flag Rust sets (portal enable-animations, or TUNAL_REDUCED_MOTION=1). Kept apart from
|
||||
// Motion because easing properties can't be exported to Rust.
|
||||
export global MotionPrefs {
|
||||
in property <bool> reduced;
|
||||
}
|
||||
|
||||
export global Motion {
|
||||
out property <bool> reduced: MotionPrefs.reduced;
|
||||
|
||||
out property <duration> short1: 50ms;
|
||||
out property <duration> short2: 100ms;
|
||||
out property <duration> short3: 150ms;
|
||||
out property <duration> short4: 200ms;
|
||||
out property <duration> medium1: 250ms;
|
||||
out property <duration> medium2: 300ms;
|
||||
out property <duration> medium3: 350ms;
|
||||
out property <duration> medium4: 400ms;
|
||||
out property <duration> long1: 450ms;
|
||||
out property <duration> long2: 500ms;
|
||||
out property <duration> long3: 550ms;
|
||||
out property <duration> long4: 600ms;
|
||||
|
||||
// Emphasized is a two-segment path in M3; this is its usual single-bezier stand-in.
|
||||
out property <easing> emphasized: cubic-bezier(0.2, 0, 0, 1);
|
||||
out property <easing> emphasized-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1);
|
||||
out property <easing> emphasized-accelerate: cubic-bezier(0.3, 0, 0.8, 0.15);
|
||||
out property <easing> standard: cubic-bezier(0.2, 0, 0, 1);
|
||||
out property <easing> standard-decelerate: cubic-bezier(0, 0, 0, 1);
|
||||
out property <easing> standard-accelerate: cubic-bezier(0.3, 0, 1, 1);
|
||||
|
||||
public pure function time(d: duration) -> duration {
|
||||
reduced ? 0ms : d
|
||||
}
|
||||
}
|
||||
87
crates/tunal/ui/theme.slint
Normal file
87
crates/tunal/ui/theme.slint
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
// Design tokens. Colours are set from Rust (theme_bridge.rs); everything else is fixed.
|
||||
|
||||
export struct TypeStyle {
|
||||
size: length,
|
||||
weight: int,
|
||||
line-height: length,
|
||||
}
|
||||
|
||||
export global Theme {
|
||||
in-out property <bool> dark;
|
||||
|
||||
// Material 3 colour roles (tonal spot scheme from the portal accent).
|
||||
in-out property <color> primary;
|
||||
in-out property <color> on-primary;
|
||||
in-out property <color> primary-container;
|
||||
in-out property <color> on-primary-container;
|
||||
in-out property <color> inverse-primary;
|
||||
in-out property <color> secondary;
|
||||
in-out property <color> on-secondary;
|
||||
in-out property <color> secondary-container;
|
||||
in-out property <color> on-secondary-container;
|
||||
in-out property <color> tertiary;
|
||||
in-out property <color> on-tertiary;
|
||||
in-out property <color> tertiary-container;
|
||||
in-out property <color> on-tertiary-container;
|
||||
in-out property <color> error;
|
||||
in-out property <color> on-error;
|
||||
in-out property <color> error-container;
|
||||
in-out property <color> on-error-container;
|
||||
in-out property <color> surface;
|
||||
in-out property <color> surface-dim;
|
||||
in-out property <color> surface-bright;
|
||||
in-out property <color> surface-container-lowest;
|
||||
in-out property <color> surface-container-low;
|
||||
in-out property <color> surface-container;
|
||||
in-out property <color> surface-container-high;
|
||||
in-out property <color> surface-container-highest;
|
||||
in-out property <color> on-surface;
|
||||
in-out property <color> surface-variant;
|
||||
in-out property <color> on-surface-variant;
|
||||
in-out property <color> inverse-surface;
|
||||
in-out property <color> inverse-on-surface;
|
||||
in-out property <color> outline;
|
||||
in-out property <color> outline-variant;
|
||||
in-out property <color> shadow;
|
||||
in-out property <color> scrim;
|
||||
|
||||
// Shape: corner radii. Concentric nesting: inner = outer - padding.
|
||||
out property <length> corner-none: 0px;
|
||||
out property <length> corner-xs: 4px;
|
||||
out property <length> corner-sm: 8px;
|
||||
out property <length> corner-md: 12px;
|
||||
out property <length> corner-lg: 16px;
|
||||
out property <length> corner-xl: 28px;
|
||||
// Fully rounded ends for a shape of the given height.
|
||||
public pure function corner-full(height: length) -> length {
|
||||
height / 2
|
||||
}
|
||||
|
||||
// Spacing on a 4 px grid.
|
||||
out property <length> space-1: 4px;
|
||||
out property <length> space-2: 8px;
|
||||
out property <length> space-3: 12px;
|
||||
out property <length> space-4: 16px;
|
||||
out property <length> space-6: 24px;
|
||||
out property <length> space-8: 32px;
|
||||
|
||||
// Hairline borders.
|
||||
out property <length> hairline: 1px;
|
||||
|
||||
// Type: the system UI face plus the icon font; four sizes.
|
||||
out property <string> icon-font: "Material Symbols Rounded";
|
||||
out property <TypeStyle> title-large: { size: 22px, weight: 400, line-height: 28px };
|
||||
out property <TypeStyle> title-medium: { size: 16px, weight: 500, line-height: 24px };
|
||||
out property <TypeStyle> body-medium: { size: 14px, weight: 400, line-height: 20px };
|
||||
out property <TypeStyle> body-small: { size: 12px, weight: 400, line-height: 16px };
|
||||
out property <TypeStyle> label-large: { size: 14px, weight: 500, line-height: 20px };
|
||||
out property <TypeStyle> label-medium: { size: 12px, weight: 500, line-height: 16px };
|
||||
|
||||
// State-layer opacities: tint = role.with-alpha(state-*).
|
||||
out property <float> state-hover: 0.08;
|
||||
out property <float> state-focus: 0.10;
|
||||
out property <float> state-press: 0.10;
|
||||
out property <float> state-drag: 0.16;
|
||||
out property <float> disabled-content: 0.38;
|
||||
out property <float> disabled-container: 0.12;
|
||||
}
|
||||
|
|
@ -24,3 +24,4 @@ D-019 — 2026-11-18 — TLS and SSH crypto on rustls + ring (no aws-lc-rs, no O
|
|||
D-020 — 2026-11-18 — Accepted SSH host keys go to `$XDG_CONFIG_HOME/tunal/known_hosts`, read together with `~/.ssh/known_hosts`; Tunal never writes under ~/.ssh — plan-generate — S027–S029.
|
||||
D-021 — 2026-11-18 — Playlist sort: a sort option "Playlist sort" offered only in folders under XDG_MUSIC_DIR that contain a playlist file (.m3u, .m3u8, .pls, .xspf); listed files first in playlist order, unlisted entries after in natural name order; several playlists → one option each; desc reverses; re-sorts when the playlist changes; stored as the folder's sort in `.directory` like other sorts — user request (details chosen by orchestrator, user may revise) — S008, S015.
|
||||
D-022 — 2026-11-18 — Fallback theme seed `#3F6FB5` (muted blue) when the portal gives no accent; palettes are `material-colors` 0.5 `ThemeBuilder` defaults (tonal spot, spec 2021) exported as ARGB `Palette` structs; library warnings go to stderr as one `tunal-theme: …` line (no logging crate yet) — S002 — S002, S003.
|
||||
D-023 — 2026-11-18 — Window minimum size 720×480 px (preferred 960×640): fits a 240 px sidebar plus a usable content column; Slint 1.19 can't drive the icon font's variation axes (font-weight doesn't reach `wght`), so `Icon` has size only and draws the default instance (wght 400, FILL 0); easing tokens live in an internal `Motion` global and Rust sets the reduced flag through `MotionPrefs` (easing properties can't be exported) — S003 — S003 and every UI plan.
|
||||
|
|
|
|||
|
|
@ -14,5 +14,11 @@ One entry per session, newest last, ≤ 15 lines: done, verified how, not done,
|
|||
- Not done: nothing. Missing-setting warnings are `eprintln!` lines prefixed `tunal-theme:` (no logging crate).
|
||||
- Later: —
|
||||
|
||||
## S003 — Window, Theme and Motion globals, screenshot command
|
||||
- Done: `ui/theme.slint` `Theme` (34 M3 roles as `primary`, `on-primary`, … `scrim`; `dark`; `corner-none/xs/sm/md/lg/xl` 0/4/8/12/16/28 + `corner-full(h)`; `space-1/2/3/4/6/8`; `hairline`; `icon-font`; `TypeStyle` `title-large/title-medium/body-medium/body-small/label-large/label-medium`; `state-hover/focus/press/drag`, `disabled-content/container`). `ui/motion.slint` `Motion` (`short1…long4`, `emphasized(-decelerate/-accelerate)`, `standard(-decelerate/-accelerate)`, `time(d)` → 0 ms when reduced) fed by exported `MotionPrefs.reduced`. `Icon { glyph, size }` + `Icons.folder/home`. `src/theme_bridge.rs` (read at start, `watch` → `upgrade_in_event_loop`), env `TUNAL_SEED=#rrggbb`, `TUNAL_SCHEME=light|dark`, `TUNAL_REDUCED_MOTION=1`. `src/screenshot.rs`: `tunal --screenshot <png> [--dark] [--size WxH]`. Window min 720×480 (D-023); ui entry renamed `ui/app.slint`; `png` 0.18 dep.
|
||||
- Verified: build, clippy -D warnings, fmt --check; looked at light, dark, `TUNAL_SEED=#2e7d32 --dark --size 720x480`, and no-bus (fallback blue) PNGs; real window ran 4 s on a private bus and with invalid env values (one stderr line each), no panic.
|
||||
- Not done: live re-theme not observed end to end (no D-Bus Python bindings for a fake portal); the path is `watch` (verified in S002) → `apply` (verified by screenshots). Icon weight/fill: not settable in Slint 1.19 (D-023).
|
||||
- Later: icon weight/fill if Slint gains font variations; screenshot hover/press states need a controlled clock (phase 12).
|
||||
|
||||
## Later
|
||||
-
|
||||
|
|
|
|||
Loading…
Reference in a new issue