Render

Struct Render 

Source
pub struct Render<'a, 'b> {
    pub current: ViewId,
    pub nodes: &'a ViewNodes,
    pub layout: &'a LayoutNodes,
    pub palette: &'a Palette,
    pub animation: &'a mut Animations,
    /* private fields */
}
Expand description

The render context

Fields§

§current: ViewId

The current view’s id

§nodes: &'a ViewNodes

Immutable access to the view nodes tree.

§layout: &'a LayoutNodes

Immutable access to the layout nodes tree.

§palette: &'a Palette

The current palette

§animation: &'a mut Animations

Mutable access to the animation context

Implementations§

Source§

impl<'a, 'b> Render<'a, 'b>

Source

pub fn draw(&mut self, id: ViewId)

Draw a specific view

Source

pub fn mouse_pos(&self) -> Pos2

Get the current mouse position

Source

pub fn rect(&self) -> Rect

Get the drawble rect for the view

Source

pub fn offset(&self) -> Pos2

Get the offset from the screen rect for this view

Source

pub fn local_rect(&self) -> Rect

Get the local rect for this view (translated so the origin is your top-left corner)

Source

pub fn is_focused(&self) -> bool

Is the current view focused?

Source

pub fn is_hovered(&self) -> bool

Is the current view hovered?

Source

pub fn is_parent_focused(&self) -> bool

Is the current view’s parent focused?

Source

pub fn is_parent_hovered(&self) -> bool

Is the current view’s parent hovered?

Source

pub fn parent_axis(&self) -> Axis

Get the axis of the parent view

Source

pub fn shrink(&mut self, size: impl Into<Vec2>, render: impl FnOnce(&mut Self))

Shrink the view to this size, giving you a closure to the new render context

When the closure returns, the size will be reset to the default rect for this view

Source

pub fn local_space(&mut self, render: impl FnOnce(&mut Self))

Scope the render context to the local rect

When this closure reutrns, the rect will be reset to the default rect for this view

Source

pub fn crop(&mut self, rect: Rect, render: impl FnOnce(&mut Self))

Crop this render context to a new rect, giving you a closure to the new render context

The provided rect cannot exceed the rect given to you by the initial render context.

The new render context will be localized to the rect. e.g. origin will be the top-left of this new rect

When the closure returns, the rect will be reset to the default rect for this view

Source

pub fn fill_bg(&mut self, color: impl Into<Rgba>) -> &mut Self

Fill this render context with a specific color

Source

pub fn fill_with(&mut self, pixel: impl Into<Pixel>) -> &mut Self

Fill this render context with a specific pixel

Source

pub fn horizontal_line( &mut self, y: i32, range: RangeInclusive<i32>, pixel: impl Into<Pixel>, ) -> &mut Self

Draw a horizontal line at the y offset between x0..=x1 using the provided pixel

Source

pub fn vertical_line( &mut self, x: i32, range: RangeInclusive<i32>, pixel: impl Into<Pixel>, ) -> &mut Self

Draw a vertical line at the x offset between y0..=y1 using the provided pixel

Source

pub fn line( &mut self, axis: Axis, offset: impl Into<Pos2>, range: RangeInclusive<i32>, pixel: impl Into<Pixel>, ) -> &mut Self

Draws a line in a specific orientation starting an offset x0,x1..=y0,y1 using the provided pixel

Source

pub fn text<'t>(&mut self, text: impl Into<TextShape<'t>>) -> &mut Self

Draws a TextShape into the region

Source

pub fn patch( &mut self, pos: impl Into<Pos2>, patch: impl Fn(&mut Cell), ) -> &mut Self

Update a specific cell.

This gives you a closure with the cell at that position, if it exists.

You can use this for changing existing properties on a cell

Source

pub fn set(&mut self, pos: impl Into<Pos2>, cell: impl Into<Cell>) -> &mut Self

Sets a cell as a specific position

Auto Trait Implementations§

§

impl<'a, 'b> Freeze for Render<'a, 'b>

§

impl<'a, 'b> !RefUnwindSafe for Render<'a, 'b>

§

impl<'a, 'b> !Send for Render<'a, 'b>

§

impl<'a, 'b> !Sync for Render<'a, 'b>

§

impl<'a, 'b> Unpin for Render<'a, 'b>

§

impl<'a, 'b> !UnwindSafe for Render<'a, 'b>

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.