| Crates.io | slint-center-win |
| lib.rs | slint-center-win |
| version | 0.3.1 |
| created_at | 2024-02-02 14:01:11.009273+00 |
| updated_at | 2024-08-07 20:19:45.925918+00 |
| description | Center a Slint window running on a `winit` backend. |
| homepage | |
| repository | https://github.com/prof79/slint-center-win-crate |
| max_upload_size | |
| id | 1124371 |
| size | 5,921 |
Center a Slint window running on a winit backend.
use slint_center_win::center_window;
slint::include_modules!();
fn main() -> Result<(), slint::PlatformError> {
// See: https://slint.dev/releases/1.5.1/docs/rust/slint/docs/generated_code/struct.SampleComponent
let ui = AppWindow::new()?;
// Window must be shown first so sizes get calculated properly
// Don't know if there is a better way, slight redraw artifacting on move
ui.show()?;
center_window(ui.window());
// ...
ui.run()
}
Forgot the essential = and minor doc update.
Added pull request from the standalone example so this is also tested on macOS now 😊 Thanks go to @zxscn.
Also incorporated @ogoffart's advice to be explicit about i-slint-* internal crate versioning.
Updated/streamlined for Slint v1.5.*.
Initial release.
Neither do I claim this to be pretty nor working in all cases.
Please see external discussions #4376 and #3859.
-- prof79