3
0
Fork
You've already forked slint-baseview
2
A baseview backend for Slint
  • Rust 100%
aidan729 9e86cbc842 Update Cargo.toml
Adding author to the cargo.toml
2026年06月16日 23:56:55 +02:00
examples/counter Address review: keymap module, mouse enter/leave, open_blocking, example 2026年06月12日 21:17:47 -04:00
src Clear the current-adapter slot after component construction 2026年06月15日 20:39:03 -04:00
.gitignore Address review: keymap module, mouse enter/leave, open_blocking, example 2026年06月12日 21:17:47 -04:00
build.rs Address review: keymap module, mouse enter/leave, open_blocking, example 2026年06月12日 21:17:47 -04:00
Cargo.toml Update Cargo.toml 2026年06月16日 23:56:55 +02:00
README.md Address review: keymap module, mouse enter/leave, open_blocking, example 2026年06月12日 21:17:47 -04:00

slint-baseview

A baseview backend for Slint - run a Slint UI inside a baseview window.

This is most useful for audio plugin editors, where the GUI has to live inside a window the host provides. It's the Slint counterpart to egui-baseview and iced_baseview: a generic windowing/rendering layer with no plugin-framework dependency. Framework integrations (e.g. nice-plug-slint) build on top of it.

What it does

  • Owns a baseview window and its render loop.
  • Sets up an OpenGL + FemtoVG renderer and a custom Slint Platform/WindowAdapter.
  • Translates baseview mouse, keyboard, and resize events into Slint events.
  • Drives your component each frame via a setup (once) and update (per-frame) closure.

Usage

useslint_baseview::{SlintWindow,WindowOpenOptions,WindowScalePolicy,Size,default_gl_config};letoptions=WindowOpenOptions{title: "My Plugin".into(),size: Size::new(400.0,300.0),scale: WindowScalePolicy::SystemScaleFactor,gl_config: Some(default_gl_config()),// FemtoVG needs an OpenGL context
};let_handle=SlintWindow::open_parented(&parent,// anything implementing raw-window-handle 0.5's HasRawWindowHandle
options,||MyComponent::new(),// component factory
|_handler,_window|{// setup: runs once after the component is shown
// register Slint callbacks here
},|handler,_window|{// update: runs every frame
handler.component().set_value(42.0);},|_w,_h|{},// on_resize: notified when the window size changes
);

For a standalone window (no plugin host) — handy for examples and testing — use SlintWindow::open_blocking(options, factory, setup, update, on_resize), which opens a top-level window and blocks until it closes. See the runnable example:

cargo run --example counter

Inside the closures, the SlintWindowHandler gives you component(), window() (the Slint window), scale_factor(), and resize control (resize, queue_resize for use from Slint callbacks).

A couple of things worth knowing

  • Two raw-window-handle versions. Slint uses rwh 0.6 internally, but baseview 0.1.x's open_parented takes rwh 0.5's HasRawWindowHandle. open_parented's parent is bound by the 0.5 trait (re-exported as slint_baseview::HasRawWindowHandle). If your parent handle comes from a framework using a different rwh version, wrap it in a small adapter type that implements the 0.5 trait (this is what nice-plug-slint does).
  • keyboard-types is pinned to 0.6 to match what baseview's KeyboardEvent uses; bumping it independently produces type mismatches.
  • Slint is pinned to =1.16.1 with the renderer-femtovg, raw-window-handle-06, and compat-1-2 features.

Status

Extracted from the nice-plug-slint adapter and generalized. Works on Windows (developed there); macOS/Linux use the same baseview paths but want testing.

License

ISC.