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

Creates a new Layout.

Creates a new Layout with given line_offset.

Creates a new Layout with given width and height.

Creates a new Layout with new offset_x and offset_y.

Creates a new Layout with new render_region.

Creates a new Layout with new max_height.

Creates a new Layout that represents a region past the cursor_pos. cursor_pos is relative to offset_x and offset_y.

Sets the width and height of the layout.

Converts a cursor_pos relative to (offset_x, offset_y) to be relative to (0, 0)

Gets the width of renderable space on the first line.

 ____________
|     vvvvvvv-- line_width
|     ███████|
|  ██████████|
|  ██████████|
'------------'

Gets the width of renderable space on subsequent lines.

 ____________
|  vvvvvvvvvv-- available_width
|     ███████|
|  ██████████|
|  ██████████|
'------------'

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: 0
  • RenderRegion::Middle: 1
  • RenderRegion::Top: 3

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.