Trait window::Window [] [src]

pub trait Window {
    type Event;
    fn set_should_close(&mut self, value: bool);
    fn should_close(&self) -> bool;
    fn size(&self) -> Size;
    fn swap_buffers(&mut self);
    fn poll_event(&mut self) -> Option<Self::Event>;
    fn draw_size(&self) -> Size;
}

Trait representing the minimum requirements for defining a window.

This trait defines all the behavior needed for making an event loop.

An example of a working event loop can be found in the Piston-Tutorials repository under getting-started, or in the event loop examples.

Associated Types

type Event

The event type the window uses for incoming input.

Usually, this will be event_loop::Input, but may vary between implementations if more or less information is available.

For example, if a backend does not support mouse input because it is designed to be sent over a network, then it might use a different event type.

Required Methods

fn set_should_close(&mut self, value: bool)

Tells the window to close or stay open.

fn should_close(&self) -> bool

Returns true if the window should close.

fn size(&self) -> Size

Gets the size of the window.

fn swap_buffers(&mut self)

Swaps render buffers.

When this is set to false, this method must be called manually or through the window backend. By default it is set to true, so usually it is not needed in application code.

fn poll_event(&mut self) -> Option<Self::Event>

Polls an event from the window.

To read events in application code, look at the Events trait instead.

fn draw_size(&self) -> Size

Gets the draw size of the window.

This is equal to the size of the frame buffer of the inner window, excluding the title bar and borders.

This information is given to the client code through the Render event.

Implementors