pub struct Layout { /* private fields */ }Expand description
Represents a new layout instance with the specified format string.
§Examples
use appcui::prelude::*;
// Absolute positioning with alignment
let layout = layout!("x:8,y:5,w:33%,h:6,p:tl");
// Anchors with short aliases
let layout = layout!("t:10,r:20,w:50,h:20");
// Aligning to parent with short alias
let layout = layout!("a:c,w:30,h:50%");
// Full anchors with short aliases
let layout = layout!("l:20,t:7,r:10,b:10");Implementations§
Source§impl Layout
impl Layout
Sourcepub fn absolute(x: i32, y: i32, width: u32, height: u32) -> Self
pub fn absolute(x: i32, y: i32, width: u32, height: u32) -> Self
Creates a new layout instance with absolute positioning.
In absolute positioning, the control’s position is defined by its top-left corner
at coordinates (x, y), and its size is specified by width and height.
The control does not automatically adjust to parent size changes and will remain
at the specified fixed position.
This is the simplest and most predictable layout mode, typically used when you need full control over the element’s exact position on the screen.
§Parameters
x- The X coordinate of the control’s top-left corner (absolute or relative to the parent).y- The Y coordinate of the control’s top-left corner.width- The width of the control (in character cells).height- The height of the control (in character cells).
§Examples
use appcui::prelude::*;
// Creates a control positioned at (8, 5) with a size of 33x6 characters.
let layout = Layout::absolute(8, 5, 33, 6);Sourcepub fn fill() -> Self
pub fn fill() -> Self
Creates a new layout instance that completely fills the parent container.
This layout mode uses Dock::Fill, meaning the control will occupy all available space
inside its parent. It is typically used for elements like panels or views that should
expand and resize automatically with the parent container.
Unlike absolute or pivot layouts, a fill layout automatically adapts
when the parent size changes, ensuring the control always covers the entire area.
§Behavior
- The control will ignore its own width and height settings.
- It will stretch horizontally and vertically to match the parent’s size.
§Examples
use appcui::prelude::*;
// Creates a layout that occupies the entire parent container.
let layout = Layout::fill();Sourcepub fn pivot(x: i32, y: i32, width: u32, height: u32, pivot: Pivot) -> Self
pub fn pivot(x: i32, y: i32, width: u32, height: u32, pivot: Pivot) -> Self
Creates a new layout instance using a pivot point.
A pivot point determines how the control is positioned relative to a given reference point (x, y).
Unlike absolute positioning (which always treats (x, y) as the top-left corner), a pivot allows
(x, y) to represent any logical point of the control (e.g., center, bottom-right).
The pivot parameter specifies which part of the control is aligned to the (x, y) coordinates:
Pivot::TopLeft→(x, y)will be the top-left corner of the control.Pivot::TopCenter→(x, y)will align with the middle of the top edge.Pivot::Center→(x, y)will be the center of the control.Pivot::BottomRight→(x, y)will be the bottom-right corner.
This is useful for positioning elements in a more natural way without manually adjusting offsets.
§Parameters
x- The reference X coordinate (absolute or relative to the parent).y- The reference Y coordinate.width- The width of the control.height- The height of the control.pivot- APivotvalue indicating which point of the control attaches to(x, y).
§Examples
use appcui::prelude::*;
// Create a layout for a 6x6 control, with its center positioned at (10, 10)
let layout = Layout::pivot(10, 10, 6, 6, Pivot::Center);
// Another example: align bottom-right corner at (50, 20)
let layout_br = Layout::pivot(50, 20, 12, 5, Pivot::BottomRight);Sourcepub fn aligned(align: Alignment, width: u32, height: u32) -> Self
pub fn aligned(align: Alignment, width: u32, height: u32) -> Self
Creates a new layout instance that positions the control using alignment relative to its parent container.
The align parameter determines which position within the parent the control
will occupy. This can be one of nine predefined positions:
Alignment::TopLeftAlignment::TopCenterAlignment::TopRightAlignment::CenterLeftAlignment::CenterAlignment::CenterRightAlignment::BottomLeftAlignment::BottomCenterAlignment::BottomRight
The control’s size is fixed using width and height. Unlike a dock or fill
layout, an aligned control does not stretch; it simply places the control
at the specified alignment within its parent.
§Parameters
align- AnAlignmentvalue specifying the position relative to the parent.width- The width of the control (in character cells).height- The height of the control (in character cells).
§Examples
use appcui::prelude::*;
// Creates a control aligned to the bottom-right corner of the parent with a fixed size.
let layout = Layout::aligned(Alignment::BottomRight, 20, 5);Trait Implementations§
impl Eq for Layout
impl StructuralPartialEq for Layout
Auto Trait Implementations§
impl Freeze for Layout
impl RefUnwindSafe for Layout
impl Send for Layout
impl Sync for Layout
impl Unpin for Layout
impl UnsafeUnpin for Layout
impl UnwindSafe for Layout
Blanket Implementations§
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.