Skip to main content

Compositor

Struct Compositor 

Source
pub struct Compositor { /* private fields */ }
Expand description

The compositor collects widget layers and resolves overlapping regions.

Implementations§

Source§

impl Compositor

Source

pub fn new(width: u16, height: u16) -> Self

Creates a new compositor with the given screen dimensions.

Source

pub fn clear(&mut self)

Removes all layers from the compositor.

Source

pub fn add_layer(&mut self, layer: Layer)

Adds a layer to the compositor stack.

Source

pub fn add_widget( &mut self, widget_id: u64, region: Rect, z_index: i32, lines: Vec<Vec<Segment>>, )

Convenience method that creates and adds a layer.

Creates a new layer from the given parameters and adds it to the stack.

Source

pub fn layer_count(&self) -> usize

Returns the number of layers in the compositor.

Source

pub fn screen_size(&self) -> Size

Returns the screen size.

Source

pub fn resize(&mut self, width: u16, height: u16)

Resizes the compositor screen dimensions.

Clears all layers since they may no longer be valid for the new size.

Source

pub fn layers(&self) -> &[Layer]

Returns a slice of all layers in the compositor.

Source

pub fn compose(&self, buf: &mut ScreenBuffer)

Compose all layers and write the result to the screen buffer.

Processes each row by calling compose_line to resolve overlapping layers, then writes the resulting segments as cells to the buffer.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.