#winit #window #slint #center #back-end #running #win

slint-center-win

Center a Slint window running on a winit backend

2 unstable releases

0.2.0 Apr 30, 2024
0.1.2 Feb 2, 2024

#720 in GUI

Download history 7/week @ 2024-02-15 14/week @ 2024-02-22 6/week @ 2024-02-29 5/week @ 2024-03-07 23/week @ 2024-03-14 9/week @ 2024-03-28 3/week @ 2024-04-04 125/week @ 2024-04-25 23/week @ 2024-05-02

148 downloads per month

Custom license and GPL-3.0-only…

5KB

slint-center-win 0.2.0

Center a Slint window running on a winit backend.

Usage

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()
}

Releases

v0.2.0

Updated/streamlined for Slint v1.5.*.

v0.1.2

Initial release.

Disclaimer

Neither do I claim this to be pretty nor working in all cases.

Please see external discussions #4376 and #3859.

-- prof79

Dependencies

~22–60MB
~1M SLoC