pub struct WindowInner {
    pub border_size: usize,
    pub title_bar_height: usize,
    pub moving: WindowMovingStatus,
    /* private fields */
}
Expand description

The WindowInner struct is the internal system-facing representation of a window. Its members and functions describe the size, state, and events related to window handling, including elements like:

  • The underlying virtual framebuffer to which the window is rendered,
  • THe location and dimensions of the window in the final screen,
  • The window’s title bar, buttons, and borders,
  • Queues for events that have been received by this window, and more.

The window manager directly interacts with instances of WindowInner rather than Window, and the application tasks should not have direct access to this struct for correctness reasons. See the crate-level documentation for more details about how to use this and how it differs from Window.

Fields§

§border_size: usize

The width of the border in pixels. By default, there is a border on the left, right, and bottom edges of the window.

§title_bar_height: usize

The height of title bar in pixels. By default, there is one title bar at the top edge of the window.

§moving: WindowMovingStatus

Whether a window is moving or stationary.

TODO: FIXME (kevinaboos): this should be private, and window moving logic should be moved into this crate.

Implementations§

source§

impl WindowInner

source

pub fn new( coordinate: Coord, framebuffer: Framebuffer<AlphaPixel>, event_producer: Queue<Event> ) -> WindowInner

Creates a new WindowInner object backed by the given framebuffer and that will be rendered at the given coordinate relative to the screen.

source

pub fn contains(&self, coordinate: Coord) -> bool

Returns true if the given coordinate (relative to the top-left corner of this window) is within the bounds of this window.

source

pub fn get_size(&self) -> (usize, usize)

Gets the size of a window in pixels

source

pub fn get_position(&self) -> Coord

Gets the top-left position of the window relative to the top-left of the screen

source

pub fn set_position(&mut self, coordinate: Coord)

Sets the top-left position of the window relative to the top-left of the screen

source

pub fn framebuffer(&self) -> &Framebuffer<AlphaPixel>

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

source

pub fn framebuffer_mut(&mut self) -> &mut Framebuffer<AlphaPixel>

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

source

pub fn get_pixel(&self, coordinate: Coord) -> Option<AlphaPixel>

Returns the pixel value at the given coordinate, if the coordinate is within the window’s bounds.

source

pub fn get_border_size(&self) -> usize

Returns the size of the Window border in pixels. There is a border drawn on the left, right, and bottom edges.

source

pub fn get_title_bar_height(&self) -> usize

Returns the size of the Window title bar in pixels. There is a title bar drawn on the top edge of the Window.

source

pub fn content_area(&self) -> Rectangle

Returns the position and dimensions of the Window’s content region, i.e., the area within the window excluding the title bar and border.

The returned Rectangle is expressed relative to this Window’s position.

source

pub fn resize(&mut self, new_position: Rectangle) -> Result<(), &'static str>

Resizes and moves this window to fit the given Rectangle that describes its new position.

source

pub fn send_event(&self, event: Event) -> Result<(), Event>

Sends the given event to this window.

If the event queue was full, Err(event) is returned.

Auto Trait Implementations§

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.