pub struct Window { /* private fields */ }
Expand description
This struct is the application-facing representation of a window.
Implementations§
source§impl Window
impl Window
sourcepub fn new(
coordinate: Coord,
width: usize,
height: usize,
initial_background: Color
) -> Result<Window, &'static str>
pub fn new( coordinate: Coord, width: usize, height: usize, initial_background: Color ) -> Result<Window, &'static str>
Creates a new window to be displayed on screen.
The given framebuffer
will be filled with the initial_background
color.
The newly-created Window
will be set as the “active” window that has current focus.
Arguments:
coordinate
: the position of the window relative to the top-left corner of the screen.width
,height
: the dimensions of the window in pixels.initial_background
: the default color of the window.
sourcepub fn handle_event(&mut self) -> Result<Option<Event>, &'static str>
pub fn handle_event(&mut self) -> Result<Option<Event>, &'static str>
Tries to receive an Event
that has been sent to this Window
.
If no events exist on the queue, it returns Ok(None)
.
“Internal” events will be automatically handled rather than returned. If an error occurs while obtaining the event (or when handling internal events),
Otherwise, the event at the front of this window’s event queue will be popped off and returned.
sourcepub fn render(
&mut self,
bounding_box: Option<Rectangle>
) -> Result<(), &'static str>
pub fn render( &mut self, bounding_box: Option<Rectangle> ) -> Result<(), &'static str>
Renders the area of this Window
specified by the given bounding_box
,
which is relative to the top-left coordinate of this Window
.
Refreshes the whole window if bounding_box
is None
.
This method should be invoked after updating the window’s contents in order to see its new content.
sourcepub fn area(&self) -> Rectangle
pub fn area(&self) -> Rectangle
Returns a Rectangle
describing the position and dimensions of this Window’s content region,
i.e., the area within the window excluding the title bar and border
that is available for rendering application content.
The returned Rectangle
is expressed relative to this Window’s position.
sourcepub fn framebuffer(&self) -> FramebufferRef<'_>
pub fn framebuffer(&self) -> FramebufferRef<'_>
Returns an immutable reference to this window’s virtual Framebuffer
.
sourcepub fn framebuffer_mut(&mut self) -> FramebufferRefMut<'_>
pub fn framebuffer_mut(&mut self) -> FramebufferRefMut<'_>
Returns a mutable reference to this window’s virtual Framebuffer
.