





















We're happy to announce Slint 1.17, another big step toward making Slint desktop-ready. This release brings drag and drop, system tray icons, tooltips, and two-way bindings on model rows.
Slint is a toolkit written in Rust, with APIs for Rust, C++, JavaScript, and Python, for building native user interfaces for desktop, embedded, and mobile applications.
Back in November we laid out a plan to make Slint desktop-ready. With 1.17 we're checking off four more boxes from that list:
Work on drag and drop, system tray icons, and tooltips was funded by NLnet as part of the Slintify LibrePCB project. We're very grateful for their support.
You can now add drag and drop interactions to your Slint apps.
Try the kanban demo live in your browser.
A DragArea marks the source of a drag,
a DropArea marks the target,
and the payload is an opaque data-transfer value that you construct and read in your host language.
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 runs while the drag hovers and returns a DragAction
that drives the cursor and any visual feedback;
dropped runs on release and confirms the action.
A DragArea declares which actions it allows and reacts to the result through drag-finished.
See the drag and drop guide for the full picture.
In this release, drag and drop works within the application. Dragging to other applications and receiving drops from them is in development upstream in winit.
Run a quiet background app, display status updates, or expose a quick-action menu from the system tray
with the new SystemTrayIcon element:
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(); }
}
}
}
The same SystemTrayIcon works on macOS, Windows, and Linux.
The clip above shows it on Windows.
Two new widgets that show up everywhere in a real desktop app.
Add a tooltip to any element with the new Tooltip element:
Button {
text: "Save";
Tooltip { text: @markdown("Save the current document (Ctrl+S)"); }
}
And bundle a set of radio buttons with RadioGroup,
which manages selection and keyboard navigation for you:
RadioGroup {
RadioButton { text: "Small"; }
RadioButton { text: "Medium"; checked: true; }
RadioButton { text: "Large"; }
}
Additional items worth highlighting:
--remote flag connects slint-viewer to a Slint LSP running on another machine and renders the design locally, so you can edit a .slint file on your desktop and watch the result on a phone or tablet as you type. The viewer is in beta for Android on Google Play (or grab the APK), and for iOS through TestFlight while the App Store review is underway.text <=> item.name, editing a row in place without bouncing through a callback to write the change back.cross-axis-alignment property on VerticalLayout and HorizontalLayout (#2587).StyledText API in Rust, C++, JavaScript, and Python now parses markdown at runtime, so you can construct styled text from data your app loads at runtime, not just from .slint literals.drop-shadow-spread and a full set of inner-shadow-* properties to Rectangle (Skia only).For the full picture, see the ChangeLog.
Don't forget to star us on GitHub, join our Mattermost chat, and share your projects.
Big thanks to everyone who contributed code, fixes, or feedback. You help us make Slint better with every release.
@0x6e @1mrnewton @agent10 @amirHdev @bennysj @bowenxuuu @DataTriny @dfaure-kdab @eira-fransham @Eyalm321 @farmaazon @fieran100 @flukejones @GrandAdmiralBee @ImFeH2 @lainon1 @manushT @megabyte6 @npwoods @pepin82 @qarmin @redstrate @ruffsl @stevekwon211 @task-jp @tilladam @ubruhin @wyhaya
Slint is a Rust-based toolkit for creating reactive and fluent user interfaces across a range of targets, from embedded devices with limited resources to powerful mobile devices and desktop machines. Supporting Android, Windows, Mac, Linux, and bare-metal systems, Slint features an easy-to-learn domain-specific language (DSL) that compiles into native code, optimizing for the target device's capabilities. It facilitates collaboration between designers and developers on shared projects and supports business logic development in Rust, C++, JavaScript, or Python.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。