Menu

Struct

WindowOptions

kurogane::WindowOptionsSource
pub struct WindowOptions { /* private fields */ }

How an application window opens. It holds the name the application knows it by, its title, size and place, the size it cannot be made smaller than and its state.

Sizes and places are in density-independent pixels (DIP) which the display’s scale turns into pixels. A size of 800 by 600 is 1200 by 900 pixels on a display at 150%. A place is on the screen, from the top-left corner of the primary display.

A size and a place are the window’s content, the area its page shows in, without the frame the system draws around it. Centring a window and keeping it on a display take the whole window, frame included, on Windows and macOS. Under X11 the window manager adds the frame once the window shows. There the content is centred and kept on the display.

App::new("dist")
    .window(WindowOptions::new().title("Notes").size(1100, 720).min_size(640, 480))
    .run_or_exit();

Methods

#pub fn new() -> Self

A window titled after its page, 800 by 600 centred on the primary display, shown normally.

#pub fn name(self, name: impl Into<String>) -> Self

The application’s name for the window, never shown. WindowClosing::name gives it back as the window closes to keep its placement under. AppHandle::find_window_by_name finds the window by it. One open window has a name at a time. AppInstance::create_window is refused a name an open window has until that window’s close is reported.

#pub fn title(self, title: impl Into<String>) -> Self

The window’s title, kept whatever title the page gives itself. Without one the window takes its page’s title as a browser tab does. A page the window shows then names it in the taskbar and the window switcher.

#pub fn size(self, width: u32, height: u32) -> Self

The size of the window’s content, the window centred on the primary display and made to fit its work area. placement, when given, decides the size instead.

#pub fn placement(self, placement: WindowPlacement) -> Self

Opens the window as placement says. That is where it was the last time (WindowClosing::placement), at its size and in its state. It decides the size over size and sets the state as state does. Of the two the later call holds. A place no display shows any more is moved onto the nearest one. A window larger than that display’s work area is made to fit it. Wayland lets no application place its windows; there only the size applies.

#pub fn min_size(self, width: u32, height: u32) -> Self

The size of content the user cannot make the window smaller than. A side of 0 leaves that side free.

#pub fn state(self, state: WindowState) -> Self

How the window first shows. Opened maximized, minimized or fullscreen, it restores to its size and place. Sets the state placement sets. Of the two the later call holds.

Trait implementations