Slint 1.17 发布
摘要
Slint 1.17 引入了拖放、系统托盘图标、工具提示以及模型行上的双向绑定,进一步推动其成为桌面级 UI 工具包的目标。
<p><a href="https://lobste.rs/s/hygtig/slint_1_17_released">评论</a></p>
查看缓存全文
缓存时间: 2026/06/24 15:59
# Slint 1.17 发布
来源:https://slint.dev/blog/slint-1.17-released
## 2026年6月24日 by Slint Developers
---
我们很高兴地宣布 Slint 1.17 发布,这是 Slint 迈向桌面就绪的又一大步。此版本带来了拖放、系统托盘图标、工具提示以及模型行上的双向绑定。
Slint 是一个用 Rust 编写的工具包,提供 Rust、C++、JavaScript 和 Python 的 API,用于构建桌面、嵌入式设备和移动应用程序的原生用户界面。
## 让 Slint 桌面就绪
去年十一月,我们制定了一项计划,旨在使 Slint 桌面就绪(https://slint.dev/blog/making-slint-desktop-ready)。在 1.17 版本中,我们从该列表中又勾掉了四个项目:
- 单窗口拖放
- 系统托盘图标
- 作为内置小部件的工具提示
- 模型行上的双向绑定
拖放、系统托盘图标和工具提示的工作由 NLnet(https://nlnet.nl/project/Slintify-LibrePCB/)资助,作为 Slintify LibrePCB 项目的一部分。我们非常感激他们的支持。
### 拖放
您现在可以将拖放交互添加到您的 Slint 应用中。
*在浏览器中在线尝试看板演示。(https://releases.slint.dev/1.17.0/demos/dnd-kanban/)*
`DragArea`(https://releases.slint.dev/1.17.0/docs/slint/reference/drag-and-drop/dragarea/)标记拖动的源,`DropArea`(https://releases.slint.dev/1.17.0/docs/slint/reference/drag-and-drop/droparea/)标记目标,载荷是一个不透明的 `data-transfer` 值,您可以在宿主语言中构建和读取它。
```
export global Api {
pure callback make-transfer(string) -> data-transfer;
pure callback read-transfer(data-transfer) -> string;
}
export component Example inherits Window {
DragArea {
data: Api.make-transfer("Hello World");
allow-copy: true;
Rectangle { background: #f0c000; width: 100px; height: 100px; }
}
drop := DropArea {
x: 150px;
can-drop(event) => DragAction.copy;
dropped(event) => {
debug("Got: ", Api.read-transfer(event.data));
return event.proposed-action;
}
Rectangle {
background: drop.contains-drag ? #80e080 : #a0a0a0;
width: 100px;
height: 100px;
}
}
}
```
`can-drop` 在拖动悬停时运行,并返回一个 `DragAction`,用于控制光标和任何视觉反馈;`dropped` 在释放时运行并确认操作。`DragArea` 声明其允许哪些操作,并通过 `drag-finished` 对结果做出反应。详细内容请参阅拖放指南(https://releases.slint.dev/1.17.0/docs/slint/guide/development/drag-and-drop/)。
在此版本中,拖放仅在应用程序内有效。拖放到其他应用程序和从其他应用程序接收拖放的功能正在 winit(https://github.com/rust-windowing/winit/pull/4571)的上游开发中。
### 系统托盘图标
使用新的 `SystemTrayIcon`(https://releases.slint.dev/1.17.0/docs/slint/reference/window/systemtrayicon/)元素,可以运行一个静默的后台应用程序,显示状态更新,或从系统托盘显示快速操作菜单:
```
export component MyTray inherits SystemTrayIcon {
icon: @image-url("tray.png");
tooltip: "My App";
callback show-window();
callback hide-window();
Menu {
MenuItem {
title: "Show";
activated => { show-window(); }
}
MenuItem {
title: "Hide";
activated => { hide-window(); }
}
}
}
```
相同的 `SystemTrayIcon` 适用于 macOS、Windows 和 Linux。上面的剪辑显示了它在 Windows 上的效果。
### 工具提示和单选组
两个新的小部件,它们出现在真正的桌面应用程序的各个地方。
使用新的 `Tooltip`(https://releases.slint.dev/1.17.0/docs/slint/reference/window/tooltip/)元素向任何元素添加工具提示:
```
Button {
text: "Save";
Tooltip { text: @markdown("Save the current document (Ctrl+S)"); }
}
```
并使用 `RadioGroup`(https://releases.slint.dev/1.17.0/docs/slint/reference/std-widgets/basic-widgets/radiogroup/)将一组单选按钮捆绑在一起,它为您管理选择和键盘导航:
```
RadioGroup {
RadioButton { text: "Small"; }
RadioButton { text: "Medium"; checked: true; }
RadioButton { text: "Large"; }
}
```
## 其他更改
其他值得强调的项目:
- **用于 AI 助手的 MCP 服务器:** Slint 应用程序现在可以嵌入一个模型上下文协议(https://modelcontextprotocol.io/)服务器。连接后,助手可以通过辅助功能树检查正在运行的应用程序,通过注入鼠标、触摸和键盘输入来驱动 UI,并截取截图以推理结果。我们还提供了技能和插件(https://github.com/slint-ui/ai-plugins),教 AI 编码助手如何编写 Slint 代码;请参阅 AI 编码助手指南(https://releases.slint.dev/1.17.0/docs/slint/guide/tooling/ai-coding-assistants/)进行设置。
- **远程 Slint 查看器:** 新的 `--remote` 标志将 `slint-viewer` 连接到另一台机器上运行的 Slint LSP,并在本地渲染设计,这样您可以在桌面上编辑 `.slint` 文件,并在您打字时在手机或平板上查看结果。查看器在 Android 上处于测试阶段,可通过 Google Play(https://play.google.com/store/apps/details?id=dev.slint.viewer)或 APK(https://github.com/slint-ui/slint/releases/download/v1.17.0/slint-viewer.apk)获取;iOS 版本通过 TestFlight(https://testflight.apple.com/join/pvsBXsb3)提供,同时等待 App Store 审核。
- **模型行上的双向绑定:** 继 Slint 1.15 中 struct 字段的双向绑定之后,您现在可以像 `text <=> item.name` 这样直接绑定到模型行数据,直接编辑行,而无需通过回调来回写更改。
- **布局上的交叉轴对齐:** 使用 `VerticalLayout` 和 `HorizontalLayout` 上的新 `cross-axis-alignment`(https://releases.slint.dev/1.17.0/docs/slint/reference/layouts/horizontallayout/#cross-axis-alignment)属性沿交叉轴对齐子元素(#2587(https://github.com/slint-ui/slint/issues/2587))。
- **更快的 Node.js 端口:** 在 Linux 和 macOS 上,Slint 现在将其事件循环绑定到 Node 已经轮询的 libuv 文件描述符,因此 UI 不再按定时器唤醒,空闲 CPU 使用率降至接近零(Windows 仍在处理中)。关于这些更改的专门博客文章即将发布。
- **Android 上的 C++:** 您现在可以从 C++ 代码库为 Android 构建 Slint 应用程序。请参阅 Android 指南(https://releases.slint.dev/1.17.0/docs/slint/guide/platforms/mobile/android/)开始使用。
- **原生代码中的 Markdown 解析:** Rust(https://releases.slint.dev/1.17.0/docs/rust/slint/struct.StyledText.html)、C++(https://releases.slint.dev/1.17.0/docs/cpp/api/slint/styledtext/)、JavaScript(https://releases.slint.dev/1.17.0/docs/node/api/classes/styledtext/)和 Python(https://releases.slint.dev/1.17.0/docs/python/api/variables/styledtext/)中的 `StyledText` API 现在在运行时解析 markdown,因此您可以从应用程序在运行时加载的数据构建样式化文本,而不仅仅是从 `.slint` 字面量。
- **投影改进:** 我们为 `Rectangle` 添加了 `drop-shadow-spread` 和全套 `inner-shadow-*` 属性(仅限 Skia)。
完整详情请参阅变更日志(https://github.com/slint-ui/slint/blob/master/CHANGELOG.md#1170)。
## 开始使用 Slint 1.17
- Slint 新手?从这里开始:开始使用(https://slint.dev/get-started)
- 升级中?请按照我们的 GitHub 发布页面(https://github.com/slint-ui/slint/releases)上的步骤操作。
- 浏览最新文档:https://docs.slint.dev/
别忘了在 GitHub(https://github.com/slint-ui/slint)上为我们加星,加入我们的 Mattermost 聊天(https://chat.slint.dev/),并分享您的项目(https://madewithslint.com/)。
## 感谢
非常感谢每一位贡献代码、修复或反馈的人。你们帮助我们在每个版本中都让 Slint 变得更好。
@0x6e(https://github.com/0x6e)@1mrnewton(https://github.com/1mrnewton)@agent10(https://github.com/agent10)@amirHdev(https://github.com/amirHdev)@bennysj(https://github.com/bennysj)@bowenxuuu(https://github.com/bowenxuuu)@DataTriny(https://github.com/DataTriny)@dfaure-kdab(https://github.com/dfaure-kdab)@eira-fransham(https://github.com/eira-fransham)@Eyalm321(https://github.com/Eyalm321)@farmaazon(https://github.com/farmaazon)@fieran100(https://github.com/fieran100)@flukejones(https://github.com/flukejones)@GrandAdmiralBee(https://github.com/GrandAdmiralBee)@ImFeH2(https://github.com/ImFeH2)@lainon1(https://github.com/lainon1)@manushT(https://github.com/manushT)@megabyte6(https://github.com/megabyte6)@npwoods(https://github.com/npwoods)@pepin82(https://github.com/pepin82)@qarmin(https://github.com/qarmin)@redstrate(https://github.com/redstrate)@ruffsl(https://github.com/ruffsl)@stevekwon211(https://github.com/stevekwon211)@task-jp(https://github.com/task-jp)@tilladam(https://github.com/tilladam)@ubruhin(https://github.com/ubruhin)@wyhaya(https://github.com/wyhaya)
---
评论(https://github.com/slint-ui/slint/discussions/12219)
Slint 是一个基于 Rust 的工具包,用于创建响应式和流畅的用户界面,覆盖从资源有限的嵌入式设备到强大的移动设备和桌面机等多种目标。支持 Android、Windows、Mac、Linux 和裸机系统,Slint 具有易于学习的领域特定语言(DSL),可编译为原生代码,并针对目标设备的能力进行优化。它促进了设计师和开发者在共享项目上的协作,并支持使用 Rust、C++、JavaScript 或 Python 进行业务逻辑开发。
相似文章
Slint 与 Node.js 事件循环
Slint 与 Node.js 集成之前会导致 16 毫秒的时钟周期,浪费 CPU 并延迟事件;1.17 版本在 Linux 和 macOS 上修复了此问题,允许 Rust UI 循环与 libuv 协作而无需轮询,提高了效率和响应能力。
Casilda 1.6 发布
Casilda 1.6 已发布,为 Gtk 4 应用程序中使用的 Wayland 合成器组件增加了拖放和剪贴板支持。
Solid 2.0 RC:重磅 <Reveal>
Solid 2.0 发布候选版已发布,展示了这个响应式 UI 库新功能的重磅亮相。
Vellium v1.0.0 发布:安全增强、壁纸主题、JSON 聊天导出及桌面稳定性大幅提升
Vellium v1.0.0 已发布,包括安全增强、壁纸主题、JSON 聊天导出以及桌面稳定性重大改进。
@herdrdev: herdr 0.8.2 发布了!更可自定义的标签栏、Windows版本正式发布、窗口标题同步、Qwen代码支持以及约60个其他…
Herdr 0.8.2版本发布,具有更可自定义的标签栏、Windows版本正式发布、窗口标题同步、Qwen代码支持以及超过60个其他修复和改进。