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§
Provided Methods§
Sourcefn pre_render(&mut self)
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.
Sourcefn post_render(&mut self)
fn post_render(&mut self)
This runs just after rendering.
The intended use is to present the screen buffer.
Sourcefn ping_user_input(&mut self)
fn ping_user_input(&mut self)
Notifies of a user interaction, for idling purposes.
Sourcefn about_to_wait(&mut self, _pinged: bool)
fn about_to_wait(&mut self, _pinged: bool)
There are no more messages, going to idle.
Sourcefn transform_position(&self, pos: Vector2) -> Vector2
fn transform_position(&self, pos: Vector2) -> Vector2
Transform the given pos
by using the current scale factor.
Sourcefn scale_factor(&self) -> f32
fn scale_factor(&self) -> f32
Gets the scale factor of the window, (HiDPI).
Sourcefn set_scale_factor(&self, scale: f32) -> f32
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.
Sourcefn resize(&mut self, size: PhysicalSize<u32>) -> LogicalSize<f32>
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.
Sourcefn set_cursor(&mut self, cursor: Option<CursorIcon>)
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.
impl MainWindowRef for &Window
Simple implementation if you only have a window, no pre/post render, no resize.
Implementors§
impl MainWindowRef for MainWindow
Main implementation of the MainWindowRef
trait for an owned MainWindow
.
impl MainWindowRef for MainWindowPieces<'_>
Default implementation if you have all the pieces.