pub struct StructuredLayout { /* private fields */ }Expand description
Container for the areas coming out of a layout function.
This is more or less a Vec<Rect>, but it takes a stride
as parameter and treats N Rects as one unit.
This way it can add some structure to the list and express something like ‘the label area for the 5th item’.
As a second feature it returns a handle for each item, which can be used to retrieve the item later.
pub enum LW {
Label,
Widget
}
let mut l = StructuredLayout::new(LW::count());
// ... some layout calculations ...
let w0 = l.add(&[
Rect::new(0,0,5,1),
Rect::new(6,0,15,1)
]);
// ... something entirely else ...
Span::from("label")
.render(l[w0][Label],&mut buf);
Checkbox::new()
.text("Check this out")
.render(l[w0][Widget], &mut buf, &mut state);
Implementations§
Source§impl StructuredLayout
impl StructuredLayout
Sourcepub fn area(&self) -> Rect
pub fn area(&self) -> Rect
Original area for which this layout has been calculated. Can be used to invalidate a layout if the area changes.
Sourcepub fn set_area(&mut self, area: Rect)
pub fn set_area(&mut self, area: Rect)
Original area for which this layout has been calculated. Can be used to invalidate a layout if the area changes.
Sourcepub fn width_change(&self, width: u16) -> bool
pub fn width_change(&self, width: u16) -> bool
Change detection.
Sourcepub fn height_change(&self, height: u16) -> bool
pub fn height_change(&self, height: u16) -> bool
Change detection.
Sourcepub fn pos_change(&self, pos: Position) -> bool
pub fn pos_change(&self, pos: Position) -> bool
Change detection.
Sourcepub fn add(&mut self, areay: &[Rect]) -> AreaHandle
pub fn add(&mut self, areay: &[Rect]) -> AreaHandle
Add the areas for one item.
You can refer Returns a handle to access the item later. You can always use a simple index too.
Sourcepub fn break_after_row(&mut self, y: u16)
pub fn break_after_row(&mut self, y: u16)
Add a manual break after the given position.
See SinglePager and DualPager who can work with this. Other widgets may simply ignore this.
Sourcepub fn break_before_row(&mut self, y: u16)
pub fn break_before_row(&mut self, y: u16)
Add a manual break before the given position.
See SinglePager and DualPager who can work with this. Other widgets may simply ignore this.
Sourcepub fn row_breaks(&self) -> &[u16]
pub fn row_breaks(&self) -> &[u16]
Return the manual page breaks.
Sourcepub fn row_breaks_mut(&mut self) -> &mut [u16]
pub fn row_breaks_mut(&mut self) -> &mut [u16]
Return the manual page breaks.
Sourcepub fn sort_row_breaks_desc(&mut self)
pub fn sort_row_breaks_desc(&mut self)
Sort and dedup the row-breaks.
Sourcepub fn as_slice(&self) -> &[Rect]
pub fn as_slice(&self) -> &[Rect]
All areas. If you want to access a specific item you must use the stride to calculate the offset.
Sourcepub fn as_mut_slice(&mut self) -> &mut [Rect]
pub fn as_mut_slice(&mut self) -> &mut [Rect]
All areas. If you want to access a specific item you must use the stride to calculate the offset.
Trait Implementations§
Source§impl Clone for StructuredLayout
impl Clone for StructuredLayout
Source§fn clone(&self) -> StructuredLayout
fn clone(&self) -> StructuredLayout
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StructuredLayout
impl Debug for StructuredLayout
Source§impl Default for StructuredLayout
impl Default for StructuredLayout
Source§impl Index<AreaHandle> for StructuredLayout
impl Index<AreaHandle> for StructuredLayout
Source§impl Index<DialogItem> for StructuredLayout
impl Index<DialogItem> for StructuredLayout
Source§impl Index<usize> for StructuredLayout
impl Index<usize> for StructuredLayout
Source§impl IndexMut<AreaHandle> for StructuredLayout
impl IndexMut<AreaHandle> for StructuredLayout
Source§impl IndexMut<DialogItem> for StructuredLayout
impl IndexMut<DialogItem> for StructuredLayout
Auto Trait Implementations§
impl !Freeze for StructuredLayout
impl !RefUnwindSafe for StructuredLayout
impl Send for StructuredLayout
impl !Sync for StructuredLayout
impl Unpin for StructuredLayout
impl UnwindSafe for StructuredLayout
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more