pub struct Layout { /* private fields */ }Expand description
A node in a layout tree. Mirrors rich.layout.Layout.
Implementations§
Source§impl Layout
impl Layout
Sourcepub fn new() -> Self
pub fn new() -> Self
An empty layout (no renderable, so it shows the placeholder; no children).
Sourcepub fn with_renderable(renderable: Box<dyn Renderable>) -> Self
pub fn with_renderable(renderable: Box<dyn Renderable>) -> Self
A leaf layout wrapping renderable.
Sourcepub fn visible(self, visible: bool) -> Self
pub fn visible(self, visible: bool) -> Self
Show or hide this layout (upstream visible, default on). A hidden
child takes no space in its parent’s split.
Sourcepub fn size(self, size: usize) -> Self
pub fn size(self, size: usize) -> Self
Pin this region to a fixed size along its parent’s split axis.
Sourcepub fn minimum_size(self, minimum_size: usize) -> Self
pub fn minimum_size(self, minimum_size: usize) -> Self
Set the minimum size this region may shrink to.
Sourcepub fn set_name(&mut self, name: Option<String>) -> &mut Self
pub fn set_name(&mut self, name: Option<String>) -> &mut Self
Set (or clear) the name in place.
Sourcepub fn set_visible(&mut self, visible: bool) -> &mut Self
pub fn set_visible(&mut self, visible: bool) -> &mut Self
Set the visibility in place.
Sourcepub fn set_size(&mut self, size: Option<usize>) -> &mut Self
pub fn set_size(&mut self, size: Option<usize>) -> &mut Self
Set (or clear) the fixed size in place.
Sourcepub fn set_minimum_size(&mut self, minimum_size: usize) -> &mut Self
pub fn set_minimum_size(&mut self, minimum_size: usize) -> &mut Self
Set the minimum size in place.
Sourcepub fn is_visible(&self) -> bool
pub fn is_visible(&self) -> bool
Whether this layout is visible.
Sourcepub fn get_minimum_size(&self) -> usize
pub fn get_minimum_size(&self) -> usize
The minimum size.
Sourcepub fn renderable(&self) -> Option<&dyn Renderable>
pub fn renderable(&self) -> Option<&dyn Renderable>
The leaf renderable, if one is set (none shows the placeholder).
Sourcepub fn update(&mut self, renderable: Box<dyn Renderable>)
pub fn update(&mut self, renderable: Box<dyn Renderable>)
Replace the leaf renderable. Port of Layout.update.
Sourcepub fn all_children(&self) -> &[Layout]
pub fn all_children(&self) -> &[Layout]
Every child, hidden ones included (upstream _children).
Sourcepub fn all_children_mut(&mut self) -> &mut Vec<Layout>
pub fn all_children_mut(&mut self) -> &mut Vec<Layout>
Every child, mutably.
Sourcepub fn split(&mut self, children: Vec<Layout>, splitter: Splitter)
pub fn split(&mut self, children: Vec<Layout>, splitter: Splitter)
Split into children with splitter. Port of Layout.split.
Sourcepub fn split_column(&mut self, children: Vec<Layout>)
pub fn split_column(&mut self, children: Vec<Layout>)
Split into children stacked vertically. Port of Layout.split_column.
Sourcepub fn split_row(&mut self, children: Vec<Layout>)
pub fn split_row(&mut self, children: Vec<Layout>)
Split into children placed side by side. Port of Layout.split_row.
Sourcepub fn add_split(&mut self, children: Vec<Layout>)
pub fn add_split(&mut self, children: Vec<Layout>)
Add children to the existing split. Port of Layout.add_split.
Sourcepub fn get(&self, name: &str) -> Option<&Layout>
pub fn get(&self, name: &str) -> Option<&Layout>
The first layout named name, depth first from this one. Port of
Layout.get.
Sourcepub fn at_path(&self, path: &[usize]) -> Option<&Layout>
pub fn at_path(&self, path: &[usize]) -> Option<&Layout>
The layout at path (child indexes, hidden children counted), as
LayoutRender::path records it.
Sourcepub fn tree(&self) -> Tree
pub fn tree(&self) -> Tree
A tree renderable showing the layout’s structure. Port of
Layout.tree.
Sourcepub fn region_map(
&self,
width: usize,
height: usize,
) -> Vec<(Vec<usize>, Region)>
pub fn region_map( &self, width: usize, height: usize, ) -> Vec<(Vec<usize>, Region)>
Every layout’s region for a width by height render, as (path, region) sorted by region. Port of Layout._make_region_map.
Sourcepub fn render_regions(
&self,
console: &Console,
options: &ConsoleOptions,
) -> Vec<LayoutRender>
pub fn render_regions( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<LayoutRender>
Render every leaf into its region. Port of Layout.render: options
give the width and (else the console’s) height.
Sourcepub fn refresh_screen(
&self,
console: &Console,
layout_name: &str,
) -> Result<bool>
pub fn refresh_screen( &self, console: &Console, layout_name: &str, ) -> Result<bool>
Render the layout named layout_name again and write it over its
region of the alternate screen. Port of Layout.refresh_screen: the
layout must be a leaf of the last render (upstream raises KeyError
otherwise; here, Ok(false) and nothing is written), and the console
must be in the alternate screen (RichError::NoAltScreen otherwise).
Sourcepub fn map(&self) -> Vec<LayoutRender>
pub fn map(&self) -> Vec<LayoutRender>
The leaves of the last render. Port of Layout.map.
Trait Implementations§
Source§impl Renderable for Layout
impl Renderable for Layout
fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>
Source§fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement
fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement
(minimum, maximum) cell width this renderable wants. The default
assumes the renderable fills the available width (e.g. Panel, Table);
Text overrides it with its content width so the top-level print path can
shrink to fit. Port of __rich_measure__ / Measurement.get.Source§fn fit_to_measurement(&self) -> bool
fn fit_to_measurement(&self) -> bool
Console::print shrinks this renderable to its
measured width. Upstream renders every top-level renderable at the full
console width, so the default is false; an extension may opt in.