Struct requestty_ui::layout::Layout
source · [−]pub struct Layout {
pub line_offset: u16,
pub offset_x: u16,
pub offset_y: u16,
pub width: u16,
pub height: u16,
pub max_height: u16,
pub render_region: RenderRegion,
}
Expand description
Layout
represents a portion of the screen that is available to be rendered to.
Assume the highlighted part of the block below is the place available for rendering in the given box
____________
| |
| ███████|
| ██████████|
| ██████████|
'------------'
Fields
line_offset: u16
____________
| vvv-- line_offset
| ███████|
| ██████████|
| ██████████|
'------------'
offset_x: u16
____________
|vv-- offset_x
| ███████|
| ██████████|
| ██████████|
'------------'
offset_y: u16
.-- offset_y
|'> |
| ███████|
| ██████████|
| ██████████|
'------------'
width: u16
____________
| |
| ███████|
| ██████████|
| ██████████|
'------------'
^^^^^^^^^^^^-- width
height: u16
_____ height --.
| | <'
| ███████| <'
| ██████████| <'
| ██████████| <'
'------------'
max_height: u16
____________
|.-- max_height
|'> ███████|
|'>██████████|
|'>██████████|
'------------'
render_region: RenderRegion
The region to render if full text cannot be rendered
Implementations
sourceimpl Layout
impl Layout
sourcepub fn with_line_offset(self, line_offset: u16) -> Self
pub fn with_line_offset(self, line_offset: u16) -> Self
Creates a new Layout
with given line_offset
.
sourcepub fn with_offset(self, offset_x: u16, offset_y: u16) -> Self
pub fn with_offset(self, offset_x: u16, offset_y: u16) -> Self
Creates a new Layout
with new offset_x
and offset_y
.
sourcepub fn with_render_region(self, region: RenderRegion) -> Self
pub fn with_render_region(self, region: RenderRegion) -> Self
Creates a new Layout
with new render_region
.
sourcepub fn with_max_height(self, max_height: u16) -> Self
pub fn with_max_height(self, max_height: u16) -> Self
Creates a new Layout
with new max_height
.
sourcepub fn with_cursor_pos(self, cursor_pos: (u16, u16)) -> Self
pub fn with_cursor_pos(self, cursor_pos: (u16, u16)) -> Self
Creates a new Layout
that represents a region past the cursor_pos
. cursor_pos
is
relative to offset_x
and offset_y
.
sourcepub fn offset_cursor(&self, cursor_pos: (u16, u16)) -> (u16, u16)
pub fn offset_cursor(&self, cursor_pos: (u16, u16)) -> (u16, u16)
Converts a cursor_pos
relative to (offset_x
, offset_y
) to be relative to (0, 0)
sourcepub fn line_width(&self) -> u16
pub fn line_width(&self) -> u16
Gets the width of renderable space on the first line.
____________
| vvvvvvv-- line_width
| ███████|
| ██████████|
| ██████████|
'------------'
sourcepub fn available_width(&self) -> u16
pub fn available_width(&self) -> u16
Gets the width of renderable space on subsequent lines.
____________
| vvvvvvvvvv-- available_width
| ███████|
| ██████████|
| ██████████|
'------------'
sourcepub fn get_start(&self, height: u16) -> u16
pub fn get_start(&self, height: u16) -> u16
Gets the starting line number for the given height
taking into account the max_height
and the render_region
.
If the height of the widget to render is 5 and the max_height is 2, then the start would be:
RenderRegion::Top
: 0RenderRegion::Middle
: 1RenderRegion::Top
: 3
Trait Implementations
sourceimpl PartialEq<Layout> for Layout
impl PartialEq<Layout> for Layout
impl Copy for Layout
impl Eq for Layout
impl StructuralEq for Layout
impl StructuralPartialEq for Layout
Auto Trait Implementations
impl RefUnwindSafe for Layout
impl Send for Layout
impl Sync for Layout
impl Unpin for Layout
impl UnwindSafe for Layout
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more