Struct window_inner::WindowInner
source · 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
impl WindowInner
sourcepub fn new(
coordinate: Coord,
framebuffer: Framebuffer<AlphaPixel>,
event_producer: Queue<Event>
) -> WindowInner
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.
sourcepub fn contains(&self, coordinate: Coord) -> bool
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.
sourcepub fn get_position(&self) -> Coord
pub fn get_position(&self) -> Coord
Gets the top-left position of the window relative to the top-left of the screen
sourcepub fn set_position(&mut self, coordinate: Coord)
pub fn set_position(&mut self, coordinate: Coord)
Sets the top-left position of the window relative to the top-left of the screen
sourcepub fn framebuffer(&self) -> &Framebuffer<AlphaPixel>
pub fn framebuffer(&self) -> &Framebuffer<AlphaPixel>
Returns an immutable reference to this window’s virtual Framebuffer.
sourcepub fn framebuffer_mut(&mut self) -> &mut Framebuffer<AlphaPixel>
pub fn framebuffer_mut(&mut self) -> &mut Framebuffer<AlphaPixel>
Returns a mutable reference to this window’s virtual Framebuffer.
sourcepub fn get_pixel(&self, coordinate: Coord) -> Option<AlphaPixel>
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.
sourcepub fn get_border_size(&self) -> usize
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.
sourcepub fn get_title_bar_height(&self) -> usize
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.
sourcepub fn content_area(&self) -> Rectangle
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.
sourcepub fn resize(&mut self, new_position: Rectangle) -> Result<(), &'static str>
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.
sourcepub fn send_event(&self, event: Event) -> Result<(), Event>
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.