Trait MainWindowRef

Source
pub trait MainWindowRef {
    // Required method
    fn window(&self) -> &Window;

    // Provided methods
    fn pre_render(&mut self) { ... }
    fn post_render(&mut self) { ... }
    fn ping_user_input(&mut self) { ... }
    fn about_to_wait(&mut self, _pinged: bool) { ... }
    fn transform_position(&self, pos: Vector2) -> Vector2 { ... }
    fn scale_factor(&self) -> f32 { ... }
    fn set_scale_factor(&self, scale: f32) -> f32 { ... }
    fn resize(&mut self, size: PhysicalSize<u32>) -> LogicalSize<f32> { ... }
    fn set_cursor(&mut self, cursor: Option<CursorIcon>) { ... }
}
Expand description

This traits grants access to a Window.

Usually you will have a MainWindow, but if you create the Window with an external crate, maybe you don’t own it.

Required Methods§

Source

fn window(&self) -> &Window

Gets the Window.

Provided Methods§

Source

fn pre_render(&mut self)

This runs just before rendering.

The intended use is to make the GL context current, if needed. Clearing the background is usually done in easy_imgui::UiBuilder::pre_render, or by the renderer if it has a background color.

Source

fn post_render(&mut self)

This runs just after rendering.

The intended use is to present the screen buffer.

Source

fn ping_user_input(&mut self)

Notifies of a user interaction, for idling purposes.

Source

fn about_to_wait(&mut self, _pinged: bool)

There are no more messages, going to idle.

Source

fn transform_position(&self, pos: Vector2) -> Vector2

Transform the given pos by using the current scale factor.

Source

fn scale_factor(&self) -> f32

Gets the scale factor of the window, (HiDPI).

Source

fn set_scale_factor(&self, scale: f32) -> f32

Changes the scale factor.

Normally there is nothing to be done here, unless you are doing something fancy with HiDPI.

It returns the real applied scale factor, as it would returned by self.scale_factor() after this change has been applied.

Source

fn resize(&mut self, size: PhysicalSize<u32>) -> LogicalSize<f32>

The window has been resized.

Takes the new physical size. It should return the new logical size.

Source

fn set_cursor(&mut self, cursor: Option<CursorIcon>)

Changes the mouse cursor.

Implementations on Foreign Types§

Source§

impl MainWindowRef for &Window

Simple implementation if you only have a window, no pre/post render, no resize.

Source§

fn window(&self) -> &Window

Implementors§

Source§

impl MainWindowRef for MainWindow

Main implementation of the MainWindowRef trait for an owned MainWindow.

Source§

impl MainWindowRef for MainWindowPieces<'_>

Default implementation if you have all the pieces.

Source§

impl MainWindowRef for NoScale<'_>