pub struct Layout {
pub root: LayoutNode,
pub visible: bool,
pub minimum_size: usize,
pub renderables: HashMap<String, DynRenderable>,
pub splitters: Vec<Box<dyn Splitter>>,
/* private fields */
}Expand description
The Layout compute engine. Assigns screen regions to a tree of layout nodes by recursively splitting available space.
Fields§
§root: LayoutNodeThe root LayoutNode defining the split hierarchy.
visible: boolWhether the layout is visible.
minimum_size: usizeMinimum size for any region.
renderables: HashMap<String, DynRenderable>Named renderables for leaf nodes.
splitters: Vec<Box<dyn Splitter>>Active splitters for dividing regions among children.
Implementations§
Source§impl Layout
impl Layout
Sourcepub fn new(root: LayoutNode) -> Self
pub fn new(root: LayoutNode) -> Self
Create a new layout with the given root node.
Sourcepub fn from_renderable(
name: impl Into<String>,
renderable: impl Renderable + Send + Sync + 'static,
) -> Self
pub fn from_renderable( name: impl Into<String>, renderable: impl Renderable + Send + Sync + 'static, ) -> Self
Create a new layout from a named renderable (single-pane leaf).
This is a convenience constructor that wraps the renderable in a leaf node with the given name.
Sourcepub fn split(&mut self, direction: Direction) -> &mut LayoutNode
pub fn split(&mut self, direction: Direction) -> &mut LayoutNode
Split the current root node into the given direction.
The existing root becomes the first child of the new split, and a new empty leaf is added as the second child. Returns a mutable reference to the root node.
Sourcepub fn unsplit(&mut self)
pub fn unsplit(&mut self)
Remove the split at the root. If the root is a split, it is replaced with its first child. If the root is already a leaf, this is a no-op.
Sourcepub fn split_column(&mut self) -> &mut Self
pub fn split_column(&mut self) -> &mut Self
Convenience: split the root into a column layout (horizontal split).
Sourcepub fn split_row(&mut self) -> &mut Self
pub fn split_row(&mut self) -> &mut Self
Convenience: split the root into a row layout (vertical split).
Sourcepub fn add_split(
&mut self,
renderable: impl Renderable + Send + Sync + 'static,
ratio: usize,
) -> usize
pub fn add_split( &mut self, renderable: impl Renderable + Send + Sync + 'static, ratio: usize, ) -> usize
Add a child pane with a renderable and a ratio weight.
If the root is already a Split node, the new child is appended.
If the root is a Leaf, it is first converted to a Split containing
the old leaf and the new child.
Returns the pane ID (index of the new child in the children list).
Sourcepub fn renderable(&self) -> Option<&dyn Renderable>
pub fn renderable(&self) -> Option<&dyn Renderable>
Get the root renderable (if the root is a leaf and has a renderable).
Sourcepub fn children(&self) -> &[LayoutNode]
pub fn children(&self) -> &[LayoutNode]
Get child layout nodes (if the root is a split).
Sourcepub fn tree(&self) -> &LayoutNode
pub fn tree(&self) -> &LayoutNode
Get the layout tree root.
Sourcepub fn map(&mut self, f: impl Fn(&dyn Renderable) -> DynRenderable)
pub fn map(&mut self, f: impl Fn(&dyn Renderable) -> DynRenderable)
Apply a function to all leaf renderables, replacing each with the result.
Sourcepub fn get(&self, name: &str) -> Option<&dyn Renderable>
pub fn get(&self, name: &str) -> Option<&dyn Renderable>
Get a named renderable from the tree.
Sourcepub fn update(
&mut self,
name: &str,
renderable: impl Renderable + Send + Sync + 'static,
) -> bool
pub fn update( &mut self, name: &str, renderable: impl Renderable + Send + Sync + 'static, ) -> bool
Update a named renderable, returning true if it existed.
Sourcepub fn refresh_screen(&mut self, console: &mut Console)
pub fn refresh_screen(&mut self, console: &mut Console)
Refresh the layout on screen by re-rendering all visible regions.
Computes the layout for the current terminal size and renders each leaf’s renderable into the console.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Layout
impl !Send for Layout
impl !Sync for Layout
impl !UnwindSafe for Layout
impl Freeze for Layout
impl Unpin for Layout
impl UnsafeUnpin for Layout
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more