slint/lib.rs
1// Copyright © SixtyFPS GmbH <[email protected]>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3
4// cSpell: ignore buildrs
5
6#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
7
8/*!
9# Slint
10
11This crate is the main entry point for embedding user interfaces designed with
12[Slint](https://slint.rs/) in Rust programs.
13*/
14#.")]
15/*! If you are already familiar with Slint, the following topics provide related information.
16
17## Topics
18
19*/
20#")]
21/*! - [Type mappings between .slint and Rust](docs::type_mappings)
22 - [Feature flags and backend selection](docs::cargo_features)
23 - [Slint on Microcontrollers](docs::mcu)
24
25## How to use this crate:
26
27Designs of user interfaces are described in the `.slint` design markup language. There are three ways
28of including them in Rust:
29
30 - The `.slint` code is [inline in a macro](#the-slint-code-in-a-macro).
31 - The `.slint` code in [external files compiled with `build.rs`](#the-slint-code-in-external-files-is-compiled-with-buildrs)
32*/
33#.")]
34/*!
35
36With the first two methods, the markup code is translated to Rust code and each component is turned into a Rust
37struct with functions. Use these functions to instantiate and show the component, and
38to access declared properties. Check out our [sample component](docs::generated_code::SampleComponent) for more
39information about the generation functions and how to use them.
40
41### The .slint code in a macro
42
43This method combines your Rust code with the `.slint` design markup in one file, using a macro:
44
45```rust,no_run
46slint::slint!{
47 export component HelloWorld inherits Window {
48 Text {
49 text: "hello world";
50 color: green;
51 }
52 }
53}
54fn main() {
55 HelloWorld::new().unwrap().run().unwrap();
56}
57```
58
59### The .slint code in external files is compiled with `build.rs`
60
61When your design becomes bigger in terms of markup code, you may want move it to a dedicated
62`.slint` file. */
63#.")]
64/*!Use a [build script](https://doc.rust-lang.org/cargo/reference/build-scripts.html) to compile
65your main `.slint` file:
66
67*/
68# crate in `build-dependencies`:")]
69/*!
70
71```toml
72[package]
73...
74build = "build.rs"
75edition = "2021"
76
77[dependencies]
78slint = "1.12"
79...
80
81[build-dependencies]
82slint-build = "1.12"
83```
84
85Use the API of the slint-build crate in the `build.rs` file:
86
87```rust,no_run
88fn main() {
89 slint_build::compile("ui/hello.slint").unwrap();
90}
91```
92
93Finally, use the [`include_modules!`] macro in your `main.rs`:
94
95```ignore
96slint::include_modules!();
97fn main() {
98 HelloWorld::new().unwrap().run().unwrap();
99}
100```
101
102Use our [Template Repository](https://github.com/slint-ui/slint-rust-template) to create a skeleton file
103hierarchy that uses this method:
104
1051. Download and extract the [ZIP archive of the Rust Template](https://github.com/slint-ui/slint-rust-template/archive/refs/heads/main.zip).
1062. Rename the extracted directory and change into it:
107
108```bash
109mv slint-rust-template-main my-project
110cd my-project
111```
112
113## Generated components
114
115Exported component from the macro or the main file that inherit `Window` or `Dialog` is mapped to a Rust structure.
116
117The components are generated and re-exported to the location of the [`include_modules!`] or [`slint!`] macro.
118It is represented as a struct with the same name as the component.
119
120For example, if you have
121
122```slint,no-preview
123export component MyComponent inherits Window { /*...*/ }
124```
125
126in the .slint file, it will create a
127```rust
128struct MyComponent { /*...*/ }
129```
130
131See also our [sample component](docs::generated_code::SampleComponent) for more information about the API of the generated struct.
132
133A component is instantiated using the [`fn new() -> Self`](docs::generated_code::SampleComponent::new) function. The following
134convenience functions are available through the [`ComponentHandle`] implementation:
135
136 - [`fn clone_strong(&self) -> Self`](docs::generated_code::SampleComponent::clone_strong): creates a strongly referenced clone of the component instance.
137 - [`fn as_weak(&self) -> Weak`](docs::generated_code::SampleComponent::as_weak): to create a [weak](Weak) reference to the component instance.
138 - [`fn show(&self)`](docs::generated_code::SampleComponent::show): to show the window of the component.
139 - [`fn hide(&self)`](docs::generated_code::SampleComponent::hide): to hide the window of the component.
140 - [`fn run(&self)`](docs::generated_code::SampleComponent::run): a convenience function that first calls `show()`,
141 followed by spinning the event loop, and `hide()` when returning from the event loop.
142 - [`fn global<T: Global<Self>>(&self) -> T`](docs::generated_code::SampleComponent::global): an accessor to the global singletons,
143
144For each top-level property
145 - A setter [`fn set_<property_name>(&self, value: <PropertyType>)`](docs::generated_code::SampleComponent::set_counter)
146 - A getter [`fn get_<property_name>(&self) -> <PropertyType>`](docs::generated_code::SampleComponent::get_counter)
147
148For each top-level callback
149 - [`fn invoke_<callback_name>(&self)`](docs::generated_code::SampleComponent::invoke_hello): to invoke the callback
150 - [`fn on_<callback_name>(&self, callback: impl Fn(<CallbackArgs>) + 'static)`](docs::generated_code::SampleComponent::on_hello): to set the callback handler.
151
152Note: All dashes (`-`) are replaced by underscores (`_`) in names of types or functions.
153
154After instantiating the component, call [`ComponentHandle::run()`] on show it on the screen and spin the event loop to
155react to input events. To show multiple components simultaneously, call [`ComponentHandle::show()`] on each instance.
156Call [`run_event_loop()`] when you're ready to enter the event loop.
157
158The generated component struct acts as a handle holding a strong reference (similar to an `Rc`). The `Clone` trait is
159not implemented. Instead you need to make explicit [`ComponentHandle::clone_strong`] and [`ComponentHandle::as_weak`]
160calls. A strong reference should not be captured by the closures given to a callback, as this would produce a reference
161loop and leak the component. Instead, the callback function should capture a weak component.
162
163## Threading and Event-loop
164
165For platform-specific reasons, the event loop must run in the main thread, in most backends, and all the components
166must be created in the same thread as the thread the event loop is running or is going to run.
167
168You should perform the minimum amount of work in the main thread and delegate the actual logic to another
169thread to avoid blocking animations. Use the [`invoke_from_event_loop`] function to communicate from your worker thread to the UI thread.
170
171To run a function with a delay or with an interval use a [`Timer`].
172
173To run an async function or a future, use [`spawn_local()`].
174
175## Exported Global singletons
176
177*/
178# from the main file,")]
179/*! it is also generated with the exported name. Like the main component, the generated struct have
180inherent method to access the properties and callback:
181
182For each property
183 - A setter: `fn set_<property_name>(&self, value: <PropertyType>)`
184 - A getter: `fn get_<property_name>(&self) -> <PropertyType>`
185
186For each callback
187 - `fn invoke_<callback_name>(&self, <CallbackArgs>) -> <ReturnValue>` to invoke the callback
188 - `fn on_<callback_name>(&self, callback: impl Fn(<CallbackArgs>) + 'static)` to set the callback handler.
189
190The global can be accessed with the [`ComponentHandle::global()`] function, or with [`Global::get()`]
191
192See the [documentation of the `Global` trait](Global) for an example.
193
194**Note**: Global singletons are instantiated once per component. When declaring multiple components for `export` to Rust,
195each instance will have their own instance of associated globals singletons.
196*/
197
198#![warn(missing_docs)]
199#![deny(unsafe_code)]
200#![doc(html_logo_url = "https://slint.dev/logo/slint-logo-square-light.svg")]
201#![cfg_attr(not(feature = "std"), no_std)]
202#![allow(clippy::needless_doctest_main)] // We document how to write a main function
203
204#[cfg(target_env = "musl")]
205compile_error!("Compiling with MUSL is not supported by this crate.");
206
207extern crate alloc;
208
209#[cfg(not(feature = "compat-1-2"))]
210compile_error!(
211 "The feature `compat-1-2` must be enabled to ensure \
212 forward compatibility with future version of this crate"
213);
214
215pub use slint_macros::slint;
216
217pub use i_slint_core::api::*;
218#[doc(hidden)]
219#[deprecated(note = "Experimental type was made public by mistake")]
220pub use i_slint_core::component_factory::ComponentFactory;
221#[cfg(not(target_arch = "wasm32"))]
222pub use i_slint_core::graphics::{BorrowedOpenGLTextureBuilder, BorrowedOpenGLTextureOrigin};
223// keep in sync with internal/interpreter/api.rs
224pub use i_slint_core::graphics::{
225 Brush, Color, Image, LoadImageError, Rgb8Pixel, Rgba8Pixel, RgbaColor, SharedPixelBuffer,
226};
227pub use i_slint_core::model::{
228 FilterModel, MapModel, Model, ModelExt, ModelNotify, ModelPeer, ModelRc, ModelTracker,
229 ReverseModel, SortModel, StandardListViewItem, TableColumn, VecModel,
230};
231pub use i_slint_core::sharedvector::SharedVector;
232pub use i_slint_core::timers::{Timer, TimerMode};
233pub use i_slint_core::translations::{select_bundled_translation, SelectBundledTranslationError};
234pub use i_slint_core::{
235 format,
236 string::{SharedString, ToSharedString},
237};
238
239pub mod private_unstable_api;
240
241/// Enters the main event loop. This is necessary in order to receive
242/// events from the windowing system for rendering to the screen
243/// and reacting to user input.
244/// This function will run until the last window is closed or until
245/// [`quit_event_loop()`] is called.
246///
247/// See also [`run_event_loop_until_quit()`] to keep the event loop running until
248/// [`quit_event_loop()`] is called, even if all windows are closed.
249pub fn run_event_loop() -> Result<(), PlatformError> {
250 i_slint_backend_selector::with_platform(|b| b.run_event_loop())
251}
252
253/// Similar to [`run_event_loop()`], but this function enters the main event loop
254/// and continues to run even when the last window is closed, until
255/// [`quit_event_loop()`] is called.
256///
257/// This is useful for system tray applications where the application needs to stay alive
258/// even if no windows are visible.
259pub fn run_event_loop_until_quit() -> Result<(), PlatformError> {
260 i_slint_backend_selector::with_platform(|b| {
261 #[allow(deprecated)]
262 b.set_event_loop_quit_on_last_window_closed(false);
263 b.run_event_loop()
264 })
265}
266
267/// Spawns a [`Future`](core::future::Future) to execute in the Slint event loop.
268///
269/// This function is intended to be invoked only from the main Slint thread that runs the event loop.
270///
271/// For spawning a `Send` future from a different thread, this function should be called from a closure
272/// passed to [`invoke_from_event_loop()`].
273///
274/// This function is typically called from a UI callback.
275///
276/// # Example
277///
278/// ```rust,no_run
279/// slint::spawn_local(async move {
280/// // your async code goes here
281/// }).unwrap();
282/// ```
283///
284/// # Compatibility with Tokio and other runtimes
285///
286/// The runtime used to execute the future on the main thread is platform-dependent,
287/// for instance, it could be the winit event loop. Therefore, futures that assume a specific runtime
288/// may not work. This may be an issue if you call `.await` on a future created by another
289/// runtime, or pass the future directly to `spawn_local`.
290///
291/// Futures from the [smol](https://docs.rs/smol/latest/smol/) runtime always hand off their work to
292/// separate I/O threads that run in parallel to the Slint event loop.
293///
294/// The [Tokio](https://docs.rs/tokio/latest/tokio/index.html) runtime is subject to the following constraints:
295///
296/// * Tokio futures require entering the context of a global Tokio runtime.
297/// * Tokio futures aren't guaranteed to hand off their work to separate threads and may therefore not complete, because
298/// the Slint runtime can't drive the Tokio runtime.
299/// * Tokio futures require regular yielding to the Tokio runtime for fairness, a constraint that also can't be met by Slint.
300/// * Tokio's [current-thread schedule](https://docs.rs/tokio/latest/tokio/runtime/index.html#current-thread-scheduler)
301/// cannot be used in Slint main thread, because Slint cannot yield to it.
302///
303/// To address these constraints, use [async_compat](https://docs.rs/async-compat/latest/async_compat/index.html)'s [Compat::new()](https://docs.rs/async-compat/latest/async_compat/struct.Compat.html#method.new)
304/// to implicitly allocate a shared, multi-threaded Tokio runtime that will be used for Tokio futures.
305///
306/// The following little example demonstrates the use of Tokio's [`TcpStream`](https://docs.rs/tokio/latest/tokio/net/struct.TcpStream.html) to
307/// read from a network socket. The entire future passed to `spawn_local()` is wrapped in `Compat::new()` to make it run:
308///
309/// ```rust,no_run
310/// // A dummy TCP server that once reports "Hello World"
311/// # i_slint_backend_testing::init_integration_test_with_mock_time();
312/// use std::io::Write;
313///
314/// let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
315/// let local_addr = listener.local_addr().unwrap();
316/// let server = std::thread::spawn(move || {
317/// let mut stream = listener.incoming().next().unwrap().unwrap();
318/// stream.write("Hello World".as_bytes()).unwrap();
319/// });
320///
321/// let slint_future = async move {
322/// use tokio::io::AsyncReadExt;
323/// let mut stream = tokio::net::TcpStream::connect(local_addr).await.unwrap();
324/// let mut data = Vec::new();
325/// stream.read_to_end(&mut data).await.unwrap();
326/// assert_eq!(data, "Hello World".as_bytes());
327/// slint::quit_event_loop().unwrap();
328/// };
329///
330/// // Wrap the future that includes Tokio futures in async_compat's `Compat` to ensure
331/// // presence of a Tokio run-time.
332/// slint::spawn_local(async_compat::Compat::new(slint_future)).unwrap();
333///
334/// slint::run_event_loop_until_quit().unwrap();
335///
336/// server.join().unwrap();
337/// ```
338///
339/// The use of `#[tokio::main]` is **not recommended**. If it's necessary to use though, wrap the call to enter the Slint
340/// event loop in a call to [`tokio::task::block_in_place`](https://docs.rs/tokio/latest/tokio/task/fn.block_in_place.html):
341///
342/// ```rust, no_run
343/// // Wrap the call to run_event_loop to ensure presence of a Tokio run-time.
344/// tokio::task::block_in_place(slint::run_event_loop).unwrap();
345/// ```
346#[cfg(target_has_atomic = "ptr")]
347pub fn spawn_local<F: core::future::Future + 'static>(
348 fut: F,
349) -> Result<JoinHandle<F::Output>, EventLoopError> {
350 i_slint_backend_selector::with_global_context(|ctx| ctx.spawn_local(fut))
351 .map_err(|_| EventLoopError::NoEventLoopProvider)?
352}
353
354#[i_slint_core_macros::slint_doc]
355/// Include the code generated with the slint-build crate from the build script. After calling `slint_build::compile`
356/// in your `build.rs` build script, the use of this macro includes the generated Rust code and makes the exported types
357/// available for you to instantiate.
358///
359/// Check the documentation of the [`slint-build`](slint:rust:slint_build) crate for more information.
360#[macro_export]
361macro_rules! include_modules {
362 () => {
363 include!(env!("SLINT_INCLUDE_GENERATED"));
364 };
365}
366
367#[i_slint_core_macros::slint_doc]
368/// Initialize translations when using the `gettext` feature.
369///
370/// Call this in your main function with the path where translations are located.
371/// This macro internally calls the [`bindtextdomain`](https://man7.org/linux/man-pages/man3/bindtextdomain.3.html) function from gettext.
372///
373/// The first argument of the macro must be an expression that implements `Into<std::path::PathBuf>`.
374/// It specifies the directory in which gettext should search for translations.
375///
376/// Translations are expected to be found at `<dirname>/<locale>/LC_MESSAGES/<crate>.mo`,
377/// where `dirname` is the directory passed as an argument to this macro,
378/// `locale` is a locale name (e.g., `en`, `en_GB`, `fr`), and
379/// `crate` is the package name obtained from the `CARGO_PKG_NAME` environment variable.
380///
381/// See also the [Translation documentation](slint:translations).
382///
383/// ### Example
384/// ```rust
385/// fn main() {
386/// slint::init_translations!(concat!(env!("CARGO_MANIFEST_DIR"), "/translations/"));
387/// // ...
388/// }
389/// ```
390///
391/// For example, assuming this is in a crate called `example` and the default locale
392/// is configured to be French, it will load translations at runtime from
393/// `/path/to/example/translations/fr/LC_MESSAGES/example.mo`.
394///
395/// Another example of loading translations relative to the executable:
396/// ```rust
397/// slint::init_translations!(std::env::current_exe().unwrap().parent().unwrap().join("translations"));
398/// ```
399#[cfg(feature = "gettext")]
400#[macro_export]
401macro_rules! init_translations {
402 ($dirname:expr) => {
403 $crate::private_unstable_api::init_translations(env!("CARGO_PKG_NAME"), $dirname);
404 };
405}
406
407/// This module contains items that you need to use or implement if you want use Slint in an environment without
408/// one of the supplied platform backends such as qt or winit.
409///
410/// The primary interface is the [`platform::Platform`] trait. Pass your implementation of it to Slint by calling
411/// [`platform::set_platform()`] early on in your application, before creating any Slint components.
412///
413/// The [Slint on Microcontrollers](crate::docs::mcu) documentation has additional examples.
414pub mod platform {
415 pub use i_slint_core::platform::*;
416
417 /// This module contains the [`femtovg_renderer::FemtoVGRenderer`] and related types.
418 ///
419 /// It is only enabled when the `renderer-femtovg` Slint feature is enabled.
420 #[cfg(all(feature = "renderer-femtovg", not(target_os = "android")))]
421 pub mod femtovg_renderer {
422 pub use i_slint_renderer_femtovg::opengl::OpenGLInterface;
423 pub use i_slint_renderer_femtovg::FemtoVGOpenGLRenderer as FemtoVGRenderer;
424 }
425}
426
427#[cfg(any(
428 doc,
429 all(
430 target_os = "android",
431 any(feature = "backend-android-activity-05", feature = "backend-android-activity-06")
432 )
433))]
434pub mod android;
435
436pub use i_slint_backend_selector::api::*;
437
438/// Helper type that helps checking that the generated code is generated for the right version
439#[doc(hidden)]
440#[allow(non_camel_case_types)]
441pub struct VersionCheck_1_12_1;
442
443#[cfg(doctest)]
444mod compile_fail_tests;
445
446#[cfg(doc)]
447pub mod docs;
448
449#[cfg(feature = "unstable-wgpu-24")]
450pub mod wgpu_24 {
451 //! WGPU 24.x specific types and re-exports.
452 //!
453 //! *Note*: This module is behind a feature flag and may be removed or changed in future minor releases,
454 //! as new major WGPU releases become available.
455 //!
456 //! Use the types in this module in combination with other APIs to integrate external, WGPU-based rendering engines
457 //! into a UI with Slint.
458 //!
459 //! First, ensure that WGPU is used for rendering with Slint by using [`slint::BackendSelector::require_wgpu_24()`](i_slint_backend_selector::api::BackendSelector::require_wgpu_24()).
460 //! This function accepts a pre-configured WGPU setup or configuration hints such as required features or memory limits.
461 //!
462 //! For rendering, it's crucial that you're using the same [`wgpu::Device`] and [`wgpu::Queue`] for allocating textures or submitting commands as Slint. Obtain the same queue
463 //! by either using [`WGPUConfiguration::Manual`] to make Slint use an existing WGPU configuration, or use [`slint::Window::set_rendering_notifier()`](i_slint_core::api::Window::set_rendering_notifier())
464 //! to let Slint invoke a callback that provides access device, queue, etc. in [`slint::GraphicsAPI::WGPU24`](i_slint_core::api::GraphicsAPI::WGPU24).
465 //!
466 //! To integrate rendering content into a scene shared with a Slint UI, use either [`slint::Window::set_rendering_notifier()`](i_slint_core::api::Window::set_rendering_notifier()) to render an underlay
467 //! or overlay, or integrate externally produced [`wgpu::Texture`]s using [`slint::Image::try_from<wgpu::Texture>()`](i_slint_core::graphics::Image::try_from).
468 //!
469 //! The following example allocates a [`wgpu::Texture`] and, for the sake of simplicity in this documentation, fills with green as color, and then proceeds to set it as a `slint::Image` in the scene.
470 //!
471 //! `Cargo.toml`:
472 //! ```toml
473 //! slint = { version = "~1.12", features = ["unstable-wgpu-24"] }
474 //! ```
475 //!
476 //! `main.rs`:
477 //!```rust,no_run
478 //!
479 //! use slint::wgpu_24::wgpu;
480 //! use wgpu::util::DeviceExt;
481 //!
482 //!slint::slint!{
483 //! export component HelloWorld inherits Window {
484 //! preferred-width: 320px;
485 //! preferred-height: 300px;
486 //! in-out property <image> app-texture;
487 //! VerticalLayout {
488 //! Text {
489 //! text: "hello world";
490 //! color: green;
491 //! }
492 //! Image { source: root.app-texture; }
493 //! }
494 //! }
495 //!}
496 //!fn main() -> Result<(), Box<dyn std::error::Error>> {
497 //! slint::BackendSelector::new()
498 //! .require_wgpu_24(slint::wgpu_24::WGPUConfiguration::default())
499 //! .select()?;
500 //! let app = HelloWorld::new()?;
501 //!
502 //! let app_weak = app.as_weak();
503 //!
504 //! app.window().set_rendering_notifier(move |state, graphics_api| {
505 //! let (Some(app), slint::RenderingState::RenderingSetup, slint::GraphicsAPI::WGPU24{ device, queue, ..}) = (app_weak.upgrade(), state, graphics_api) else {
506 //! return;
507 //! };
508 //!
509 //! let mut pixels = slint::SharedPixelBuffer::<slint::Rgba8Pixel>::new(320, 200);
510 //! pixels.make_mut_slice().fill(slint::Rgba8Pixel {
511 //! r: 0,
512 //! g: 255,
513 //! b :0,
514 //! a: 255,
515 //! });
516 //!
517 //! let texture = device.create_texture_with_data(queue,
518 //! &wgpu::TextureDescriptor {
519 //! label: None,
520 //! size: wgpu::Extent3d { width: 320, height: 200, depth_or_array_layers: 1 },
521 //! mip_level_count: 1,
522 //! sample_count: 1,
523 //! dimension: wgpu::TextureDimension::D2,
524 //! format: wgpu::TextureFormat::Rgba8Unorm,
525 //! usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::TEXTURE_BINDING,
526 //! view_formats: &[],
527 //! },
528 //! wgpu::util::TextureDataOrder::default(),
529 //! pixels.as_bytes(),
530 //! );
531 //!
532 //! let imported_image = slint::Image::try_from(texture).unwrap();
533 //!
534 //! app.set_app_texture(imported_image);
535 //! })?;
536 //!
537 //! app.run()?;
538 //!
539 //! Ok(())
540 //!}
541 //!```
542 //!
543 pub use i_slint_core::graphics::wgpu_24::*;
544}
545
546#[cfg(feature = "unstable-winit-030")]
547pub mod winit_030 {
548 //! Winit 0.30.x specific types and re-exports.
549 //!
550 //! *Note*: This module is behind a feature flag and may be removed or changed in future minor releases,
551 //! as new major Winit releases become available.
552 //!
553 //! Use the types and traits in this module in combination with other APIs to access additional window properties,
554 //! create custom windows, or hook into the winit event loop.
555 //!
556 //! For example, use the [`WinitWindowAccessor`] to obtain access to the underling [`winit::window::Window`]:
557 //!
558 //! `Cargo.toml`:
559 //! ```toml
560 //! slint = { version = "~1.12", features = ["unstable-winit-030"] }
561 //! ```
562 //!
563 //! `main.rs`:
564 //! ```rust,no_run
565 //! // Bring winit and accessor traits into scope.
566 //! use slint::winit_030::{WinitWindowAccessor, winit};
567 //!
568 //! slint::slint!{
569 //! import { VerticalBox, Button } from "std-widgets.slint";
570 //! export component HelloWorld inherits Window {
571 //! callback clicked;
572 //! VerticalBox {
573 //! Text {
574 //! text: "hello world";
575 //! color: green;
576 //! }
577 //! Button {
578 //! text: "Click me";
579 //! clicked => { root.clicked(); }
580 //! }
581 //! }
582 //! }
583 //! }
584 //! fn main() -> Result<(), Box<dyn std::error::Error>> {
585 //! // Make sure the winit backed is selected:
586 //! slint::BackendSelector::new()
587 //! .backend_name("winit".into())
588 //! .select()?;
589 //!
590 //! let app = HelloWorld::new()?;
591 //! let app_weak = app.as_weak();
592 //! app.on_clicked(move || {
593 //! // access the winit window
594 //! let app = app_weak.unwrap();
595 //! app.window().with_winit_window(|winit_window: &winit::window::Window| {
596 //! eprintln!("window id = {:#?}", winit_window.id());
597 //! });
598 //! });
599 //! app.run()?;
600 //! Ok(())
601 //! }
602 //! ```
603 //! See also [`BackendSelector::with_winit_event_loop_builder()`](crate::BackendSelector::with_winit_event_loop_builder())
604 //! and [`BackendSelector::with_winit_window_attributes_hook()`](crate::BackendSelector::with_winit_window_attributes_hook()).
605
606 pub use i_slint_backend_winit::{
607 winit, EventLoopBuilder, SlintEvent, WinitWindowAccessor, WinitWindowEventResult,
608 };
609}