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: ViewIdThe current view’s id
nodes: &'a ViewNodesImmutable access to the view nodes tree.
layout: &'a LayoutNodesImmutable access to the layout nodes tree.
palette: &'a PaletteThe current palette
animation: &'a mut AnimationsMutable access to the animation context
Implementations§
Source§impl<'a, 'b> Render<'a, 'b>
impl<'a, 'b> Render<'a, 'b>
Sourcepub fn local_rect(&self) -> Rect
pub fn local_rect(&self) -> Rect
Get the local rect for this view (translated so the origin is your top-left corner)
Sourcepub fn is_focused(&self) -> bool
pub fn is_focused(&self) -> bool
Is the current view focused?
Sourcepub fn is_hovered(&self) -> bool
pub fn is_hovered(&self) -> bool
Is the current view hovered?
Sourcepub fn is_parent_focused(&self) -> bool
pub fn is_parent_focused(&self) -> bool
Is the current view’s parent focused?
Sourcepub fn is_parent_hovered(&self) -> bool
pub fn is_parent_hovered(&self) -> bool
Is the current view’s parent hovered?
Sourcepub fn parent_axis(&self) -> Axis
pub fn parent_axis(&self) -> Axis
Get the axis of the parent view
Sourcepub fn shrink(&mut self, size: impl Into<Vec2>, render: impl FnOnce(&mut Self))
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
Sourcepub fn local_space(&mut self, render: impl FnOnce(&mut Self))
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
Sourcepub fn crop(&mut self, rect: Rect, render: impl FnOnce(&mut Self))
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
Sourcepub fn fill_bg(&mut self, color: impl Into<Rgba>) -> &mut Self
pub fn fill_bg(&mut self, color: impl Into<Rgba>) -> &mut Self
Fill this render context with a specific color
Sourcepub fn fill_with(&mut self, pixel: impl Into<Pixel>) -> &mut Self
pub fn fill_with(&mut self, pixel: impl Into<Pixel>) -> &mut Self
Fill this render context with a specific pixel
Sourcepub fn horizontal_line(
&mut self,
y: i32,
range: RangeInclusive<i32>,
pixel: impl Into<Pixel>,
) -> &mut Self
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
Sourcepub fn vertical_line(
&mut self,
x: i32,
range: RangeInclusive<i32>,
pixel: impl Into<Pixel>,
) -> &mut Self
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
Sourcepub fn line(
&mut self,
axis: Axis,
offset: impl Into<Pos2>,
range: RangeInclusive<i32>,
pixel: impl Into<Pixel>,
) -> &mut Self
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
Sourcepub fn text<'t>(&mut self, text: impl Into<TextShape<'t>>) -> &mut Self
pub fn text<'t>(&mut self, text: impl Into<TextShape<'t>>) -> &mut Self
Draws a TextShape into the region