March 14, 2024 by Slint Team

Slint 1.5: Embracing Android, Improving Live-Preview, and introducing Pythonic Slint

We're excited to announce the release of Slint 1.5, featuring Android deployment and an improved Live-Preview, while maintaining full backwards compatibility.


Build Android Apps with Rust

The Energy Monitor demo on an Android mobile phone

Exciting news for mobile developers! You can now develop apps for Android with Slint, the only Rust GUI toolkit to officially support Android. For the Rust community, this release allows building a pure Rust app and deploying it on Android.

For embedded developers, who prefer using an Android BSP instead of an embedded Linux distribution, the Slint on Android port allows development and deployment of Slint applications on embedded Android.

Get Started with Slint on Android

Enable the backend-android-activity-05 feature of Slint to seamlessly develop applications for Android devices. Under the hood, this feature uses the android-activity crate to bind to the Android NDK.

Switch from main.rs to lib.rs and change your entry point like so:

#[no_mangle]
fn android_main(app: slint::android::AndroidApp) {
    slint::android::init(app).unwrap();
    slint::slint!{
        export component MainWindow inherits Window {
            Text { text: "Hello World"; }
        }
    }
    MainWindow::new().unwrap().run().unwrap();
}

Set up your Android SDK and NDK, install cargo-apk, and run your application:

cargo apk run --target aarch64-linux-android --lib

For more details, refer to the Slint Android Documentation.

Drag and Drop on Live-Preview

We're gradually enhancing Live-Preview for quicker iteration. Click the new design mode button to drag and drop new widgets directly onto the preview. This is implemented in our VS Code extension, as well as any other editor supporting the Language Server Protocol (LSP), and of course on SlintPad, our online code editor.

Beginnings of Python Support

Python consistently ranks as one of the most popular programming languages, thanks to its design philosophy that emphasizes code readability. We're excited to announce that we're bringing Slint to all Pythonistas out there. 🐍 Here's a sneak peek at how we've begun designing the API:

import slint
# This will open an "appwindow.slint" file
import appwindow_slint

class App(appwindow_slint.AppWindow):
    def __init__(self):
        super().__init__()
        self.some_string_property = "Hello World"

    # Subclasses can decorate methods to automatically associate them with Slint callbacks
    @slint.callback
    def request_increase_value(self):
        self.counter = self.counter + 1

app = App()
app.run()

Currently, the API to Python is in alpha stage: We invite you to experiment with it, we'd love to get your feedback to make it as pythonic and elegant as possible. For details how to try it out, check out our README.

This work is being funded by NLNet. We're very grateful for their support.

Bug Fixes and Enhancements

Thanks to numerous contributions, this release also features many new APIs and fixes several bugs.

  • Customize individual rectangle borders with the new border-*-radius properties. (Thanks to @jpnurmi)
  • The Image element now supports tiling and 9-slice scaling.
  • Added functions to minimize or maximize windows (Thanks to Ralph Minderhoud)
  • React to changes in a Flickable element with a new "flicked" callback (Thanks to @pfzetto)
  • Added option to place generated C++ code into a namespace (Thanks to @WilstonOreo)
  • TextInput supports undo/redo keyboard shortcuts (Thanks to Waqar Ahmed)
  • Access color channels in Slint with the new red/green/blue/alpha properties on colors (Thanks to Luke Jones)
  • The Slint Language Server now supports document formatting requests.

For a complete list of changes, check out the ChangeLog.

Upgrading to Slint v1.5

To use the latest version, follow the instructions below for the programming language of your choice:

  • Rust developers: Run cargo update to bring your application up-to-date.
  • C++ developers: If you're using FetchContent with CMake, update the GIT_TAG entry in CMakeLists.txt to v1.5.0 or release/1.5 for automatic tracking of 1.5.x releases.
  • Node.js developers: Run npm update slint-ui to bring your package.json up-to-date.

Conclusion

Thanks to everyone who contributed, especially the external contributors. Slint 1.5 continues our series of incremental updates that add new features while maintaining backwards compatibility. We're excited to stabilize the first parts of our Android support, improve the live-preview, and kick off the Python APIs.

If you're new to Slint, check out our Get Started section.

As always, we welcome your feedback, bug reports, and questions on our bug tracker, forum, and chat. Your input drives our continual improvement and innovation.

Comments


Slint is a declarative GUI toolkit to build native user interfaces for desktop and embedded applications written in Rust, C++, or JavaScript. Find more information at https://slint.dev/ or check out the source code at https://github.com/slint-ui/slint