Files
Unlucky-Launcher/crates/app/ui/components/glass.slint
T
AskaEth a5d1dec495
CI / fmt (rustfmt --check) (push) Waiting to run
CI / clippy (ubuntu-latest) (push) Waiting to run
CI / clippy (windows-latest) (push) Waiting to run
CI / test (ubuntu-latest) (push) Waiting to run
CI / test (windows-latest) (push) Waiting to run
CI / build release (ubuntu-latest) (push) Waiting to run
CI / build release (windows-latest) (push) Waiting to run
CI / runtime smoke (ubuntu x64, xvfb) (push) Waiting to run
CI / runtime smoke (macos arm64, probe) (push) Skipped
CI / update-e2e (windows x64) (push) Waiting to run
GPU evidence / GPU 判据自测(不需 GPU;跳过 ≠ 已验证) (push) Waiting to run
GPU evidence / GPU 证据 — 探测可用产物与硬件适配器 (push) Waiting to run
Guards / core 零 UI 守门 (push) Waiting to run
Guards / presenter 零 UI 守门 (push) Waiting to run
Guards / design 零第三方依赖守门 (push) Waiting to run
Guards / unsafe 落点守门(集合必须恰好等于期望) (push) Waiting to run
Guards / 文件行数 ≤400 守门 (push) Waiting to run
Guards / 依赖许可与来源(cargo-deny) (push) Waiting to run
Release guard / 发布标记语义守门(push tag → 稳定版) (push) Waiting to run
Signing status(播报,不是门禁) / 判据自测(三行/退出码/变异重放/接线) (push) Waiting to run
Signing status(播报,不是门禁) / 签名就绪度(播报) (push) Waiting to run
Release / 选槽位(默认四个:Windows 两档 + Linux 两档) (push) Waiting to run
release: v0.2.4 里程碑快照(孤儿提交,无父;树 = dev 68362e5)
本批内容见 CHANGELOG.md 的 0.2.4 段。按 D41 用孤儿快照推 main,保留「公开史只有里程碑」的模型。
2026-11-11 21:41:38 +08:00

60 lines
2.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 玻璃拟态卡片的公共底座(09 §103:Slint 没有 backdrop-filter,用「预生成模糊背景层」替代)。
//
// 手法:Rust 侧把背景图降采样成一张极小的图(`Theme.bg-blur`),渲染时被平滑放大 → 天然模糊。
// 卡片里把它按 `absolute-position` **反向偏移**画出来,于是卡片显示的是「自己这一块屏幕区域的
// 模糊影像」,视觉上就是毛玻璃;再叠一层半透明面板色保证文字可读(对比度优先)。
//
// 关闭态(`Theme.glass == false` 或无背景图)不画任何东西:卡片保持 Metro 纯色观感。
import { Theme } from "../theme/tokens.slint";
import { Metrics } from "../theme/metrics.slint";
export component GlassBase inherits Rectangle {
/// 卡片圆角(跟随宿主卡片)
in property <length> card-radius: Metrics.radius-md;
/// 叠在模糊层上的半透明面板色(保证前景对比度)
in property <color> tint: Theme.surface-solid;
out property <bool> active: Theme.glass && Theme.bg-blur.width > 0 && Theme.bg-image.width > 0;
x: 0;
y: 0;
width: 100%;
height: 100%;
border-radius: root.card-radius;
clip: true;
background: transparent;
if root.active : Image {
// 整窗模糊层 + 反向偏移 = 只露出「卡片所在那一块」。
// 必须用 `parent`(本组件自身)的绝对位置:用 `self` 会与自身 x 形成绑定环
// (absolute-position 依赖 x,x 又依赖 absolute-position)。
source: Theme.bg-blur;
x: -parent.absolute-position.x;
y: -parent.absolute-position.y;
width: Theme.window-width;
height: Theme.window-height;
image-fit: cover;
}
if root.active : Rectangle {
// 暗化层要**重画一次**:模糊层在卡片内部、盖在窗口的暗化层之上,
// 不补这一层的话玻璃卡片会比周围亮一大截(05 截图验收时的真实问题)。
background: rgba(0, 0, 0, Theme.bg-dim);
border-radius: root.card-radius;
}
if root.active : Rectangle {
// 玻璃染色:面板底色 55% 不透明,字压得住背景(对比度优先于「更透」)
background: root.tint.with-alpha(0.55);
border-radius: root.card-radius;
}
if root.active : Rectangle {
// 上缘一道细高光,玻璃的「厚度感」
y: 0;
height: 1px;
width: root.width;
background: Theme.stroke.with-alpha(0.35);
}
}