pub struct Layout { /* private fields */ }
Implementations§
Source§impl Layout
impl Layout
pub fn constraints<C>(self, constraints: C) -> Layout
pub fn margin(self, margin: u16) -> Layout
pub fn horizontal_margin(self, horizontal: u16) -> Layout
pub fn vertical_margin(self, vertical: u16) -> Layout
pub fn direction(self, direction: Direction) -> Layout
Sourcepub fn split(&self, area: Rect) -> Vec<Rect>
pub fn split(&self, area: Rect) -> Vec<Rect>
Wrapper function around the cassowary-rs solver to be able to split a given area into smaller ones based on the preferred widths or heights and the direction.
§Examples
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Length(5), Constraint::Min(0)].as_ref())
.split(Rect {
x: 2,
y: 2,
width: 10,
height: 10,
});
assert_eq!(
chunks,
vec![
Rect {
x: 2,
y: 2,
width: 10,
height: 5
},
Rect {
x: 2,
y: 7,
width: 10,
height: 5
}
]
);
let chunks = Layout::default()
.direction(Direction::Horizontal)
.constraints([Constraint::Ratio(1, 3), Constraint::Ratio(2, 3)].as_ref())
.split(Rect {
x: 0,
y: 0,
width: 9,
height: 2,
});
assert_eq!(
chunks,
vec![
Rect {
x: 0,
y: 0,
width: 3,
height: 2
},
Rect {
x: 3,
y: 0,
width: 6,
height: 2
}
]
);
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 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
Mutably borrows from an owned value. Read more