Skip to content

Build beautiful, native applications with Ring and Slint.

License

Notifications You must be signed in to change notification settings

ysdragon/ring-slint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

60 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Ring Slint

Build beautiful, native applications with Ring and Slint.

Ring Slint is a powerful Ring library that brings the Slint declarative UI toolkit to the Ring programming language. Create stunning, high-performance native applications for desktop and mobile with a clean separation between UI design and application logic.

✨ Features

  • High Performance: .slint files are interpreted at runtime with GPU-accelerated rendering via Skia (FemtoVG on FreeBSD).
  • Cross-Platform: Build applications for Windows, macOS, Linux, FreeBSD, Android, and iOS from a single codebase.
  • Declarative UI: Design your interface using Slint's intuitive .slint markup language.
  • Two-Way Binding: Seamlessly connect Ring callbacks to Slint events and update properties dynamically.
  • Rich Widget Set: Access Slint's built-in widgets with multiple themes (Fluent, Material, Cupertino, Native).
  • Desktop Integration: File dialogs, message boxes, notifications, clipboard, global hotkeys, and system tray support.

πŸ“Έ Screenshots

πŸš€ Getting Started

Prerequisites

  • Ring: Version 1.25 or higher.

Installation

Click here for instructions on Android

Android builds use GPU-accelerated rendering via Skia (OpenGL ES or Vulkan). Desktop-only features (file dialogs, notifications, hotkeys, system tray) are not available on Android.

Build requirements:

  • Android NDK (r25 or later recommended)
  • Rust with Android targets: rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android
  • cargo-apk: cargo install cargo-apk

Build for Android:

cd src/rust_src
cargo apk build --release

The library is configured for min SDK 21 (Android 5.0) and targets SDK 35.

Release signing: For release builds, configure your keystore in src/rust_src/Cargo.toml under [package.metadata.android.signing.release]:

[package.metadata.android.signing.release]
path = "/path/to/your/keystore.jks"
keystore_password = "your_password"
key_alias = "your_alias"
key_password = "your_key_password"
Click here for instructions on FreeBSD
  • FreeBSD: sudo pkg install fontconfig
Click here for instructions on iOS

iOS builds use GPU-accelerated rendering via Skia (Metal). Desktop-only features (file dialogs, notifications, clipboard, hotkeys, system tray) are not available on iOS.

Build requirements:

  • macOS with Xcode installed
  • Rust with iOS targets: rustup target add aarch64-apple-ios aarch64-apple-ios-sim
  • Optional: xcodegen (brew install xcodegen) and ios-deploy (brew install ios-deploy)

Build for iOS:

cd ios/

# Simulator
./build.sh --simulator

# Device
./build.sh

# Build, install, and run on device
./build.sh --run

For more details, see the iOS Guide.

Click here for instructions on Linux

The library uses Skia for rendering and requires fontconfig.

  • Debian/Ubuntu: sudo apt install libfontconfig1
  • Arch Linux: sudo pacman -S fontconfig
  • Fedora: sudo dnf install fontconfig
  • Alpine Linux: sudo apk add fontconfig
Click here for instructions on macOS

No additional dependencies required. Uses system frameworks.

Click here for instructions on Windows

No additional dependencies required. The library is self-contained.

Install the library using RingPM:

ringpm install ring-slint from ysdragon

πŸ’» Usage

Creating a Slint application involves two files: a .slint file for the UI and a .ring file for the logic.

counter.slint - Define your UI:

import { Button } from "std-widgets.slint";

export component App inherits Window {
    title: "Counter";
    width: 300px;
    height: 200px;

    callback increment();
    callback decrement();

    in-out property <int> counter: 0;

    VerticalLayout {
        alignment: center;
        spacing: 20px;

        Text {
            text: counter;
            font-size: 48px;
            horizontal-alignment: center;
        }

        HorizontalLayout {
            alignment: center;
            spacing: 10px;

            Button { text: "-"; clicked => { decrement(); } }
            Button { text: "+"; clicked => { increment(); } }
        }
    }
}

counter.ring - Add your logic:

load "slint.ring"

nCount = 0

oApp = new SlintApp {
    loadUI("counter.slint")
    setCallback("increment", :onIncrement)
    setCallback("decrement", :onDecrement)
    show()
    run()
}

func onIncrement
    nCount++
    oApp.set("counter", nCount)

func onDecrement
    nCount--
    oApp.set("counter", nCount)

For more examples, see the examples/ directory.

πŸ“š Documentation

Document Description
API Reference Complete reference for all 99 SlintApp methods
Android Guide Building and deploying on Android
iOS Guide Building and deploying on iOS

Quick Reference

Category Methods
Core loadUI(), loadUIString(), create(), show(), hide(), run(), quit(), window(), definition()
Properties set(), setBool(), setString(), setNumber(), setColor(), setEnum(), setImage(), getProperty()
Callbacks setCallback(), invoke(), callbackArg(), callbackArgsCount()
Timers timerStart(), timerStartOnce(), timerStop(), timerRestart(), timerRunning(), timerSetInterval()
Models modelCreate(), modelPush(), modelInsert(), modelSet(), modelGet(), modelRemove(), modelClear(), modelCount(), modelDestroy()
Globals globalGet(), globalSet(), globalSetCallback(), globalInvoke()
Window windowSetPosition(), windowGetPosition(), windowSetSize(), windowGetSize(), windowSetMinimized(), windowSetMaximized(), windowSetFullscreen(), windowIsMinimized(), windowIsMaximized(), windowIsFullscreen(), windowIsVisible(), windowDrag(), windowSetAlwaysOnTop(), windowSetIcon(), windowRequestRedraw(), windowScaleFactor()
Style setStyle(), getStyle(), addLibraryPath(), removeLibraryPath(), clearLibraryPaths()
Introspection definitionName(), definitionProperties(), definitionCallbacks(), definitionFunctions(), definitionGlobals()

Desktop-Only Features

These features are not available on Android:

Category Methods
File Dialogs fileOpen(), fileOpenWithFilters(), fileOpenMultiple(), fileOpenMultipleWithFilters(), fileSave(), fileSaveWithName(), fileSaveWithFilters(), folderOpen(), folderOpenMultiple()
Message Boxes msgbox(), msgboxWarning(), msgboxError(), confirm(), yesno()
Notifications notify(), notifyWithTimeout(), notifyWithIcon(), notifyFull()
Clipboard clipboardGet(), clipboardSet(), clipboardClear()
Hotkeys hotkeyRegister(), hotkeyUnregister(), hotkeyUnregisterAll(), hotkeyPoll()
System Tray trayCreate(), trayCreateWithIcon(), traySetIcon(), traySetTooltip(), trayAddItem(), trayAddSeparator(), trayDestroy(), trayPoll()

πŸ› οΈ Development

Prerequisites

  • Rust: Latest stable version with Cargo.
  • Ring: Fully built Ring installation (required by ring-lang-rs for linking).

Build Steps

  1. Clone the Repository:

    git clone https://github.com/ysdragon/ring-slint.git
    cd ring-slint
  2. Set the RING Environment Variable:

    # Unix
    export RING=/path/to/ring
    
    # Windows (PowerShell)
    $env:RING = "X:\path\to\ring"
  3. Build the Rust Library:

    cd src/rust_src
    cargo build --release

The compiled library will be in src/rust_src/target/release/.

πŸ”— Resources

🀝 Contributing

Contributions are welcome! If you have ideas for improvements or have found a bug, please open an issue or submit a pull request.

πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.