Struct window::Window

source ·
pub struct Window { /* private fields */ }
Expand description

This struct is the application-facing representation of a window.

Implementations§

source§

impl Window

source

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.
source

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.

source

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.

source

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.

source

pub fn framebuffer(&self) -> FramebufferRef<'_>

Returns an immutable reference to this window’s virtual Framebuffer.

source

pub fn framebuffer_mut(&mut self) -> FramebufferRefMut<'_>

Returns a mutable reference to this window’s virtual Framebuffer.

source

pub fn is_active(&self) -> bool

Returns true if this window is the currently active window.

Obtains the lock on the window manager instance.

Trait Implementations§

source§

impl Drop for Window

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Window

§

impl Send for Window

§

impl Sync for Window

§

impl Unpin for Window

§

impl !UnwindSafe for Window

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.