|
|
||
|---|---|---|
| examples/counter | Address review: keymap module, mouse enter/leave, open_blocking, example | |
| src | Clear the current-adapter slot after component construction | |
| .gitignore | Address review: keymap module, mouse enter/leave, open_blocking, example | |
| build.rs | Address review: keymap module, mouse enter/leave, open_blocking, example | |
| Cargo.toml | Update Cargo.toml | |
| README.md | Address review: keymap module, mouse enter/leave, open_blocking, example | |
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) andupdate(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-handleversions. Slint uses rwh 0.6 internally, but baseview 0.1.x'sopen_parentedtakes rwh 0.5'sHasRawWindowHandle.open_parented'sparentis bound by the 0.5 trait (re-exported asslint_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 whatnice-plug-slintdoes). keyboard-typesis pinned to 0.6 to match what baseview'sKeyboardEventuses; bumping it independently produces type mismatches.- Slint is pinned to
=1.16.1with therenderer-femtovg,raw-window-handle-06, andcompat-1-2features.
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.