pub struct WindowBuilder<'a> { /* private fields */ }
Expand description

Opens a new window by providing several window configuration functions.

In addition to the primary window created for you when calling PixEngine::run, you can open additional windows with various configurations and render to them using the PixState::with_window method.

Example

fn on_key_pressed(&mut self, s: &mut PixState, event: KeyEvent) -> PixResult<bool> {
    if let Key::O = event.key {
        let window_id = s.window()
            .with_title("New Window")
            .with_dimensions(800, 600)
            .position(10, 10)
            .resizable()
            .borderless()
            .build()?;
        self.windows.push(window_id);
        return Ok(true);
    }
    Ok(false)
}

Implementations

Set window dimensions.

Set a window title.

Position the window at the given (x, y) coordinates of the display.

Position the window in the center of the display.

Start window in fullscreen mode.

Allow window resizing.

Removes the window decoration.

Set a window icon.

Create a new window from the WindowBuilder and return its id.

Errors

If the renderer fails to create a new window, then an error is returned.

Possible errors include the title containing a nul character, the position or dimensions being invalid values or overlowing and an internal renderer error such as running out of memory or a software driver issue.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.