pub struct Layout {
pub order: u32,
pub location: Point<f32>,
pub size: Size<f32>,
pub scrollable_overflow_rect: Rect<f32>,
pub scrollbar_size: Size<f32>,
pub border: Rect<f32>,
pub padding: Rect<f32>,
pub margin: Rect<f32>,
}Expand description
The final result of a layout algorithm for a single node.
Fields§
§order: u32The relative ordering of the node
Nodes with a higher order should be rendered on top of those with a lower order. This is effectively a topological sort of each tree.
location: Point<f32>The top-left corner of the node
size: Size<f32>The width and height of the node
scrollable_overflow_rect: Rect<f32>content_size only.The scrollable overflow rectangle of the node: the axis-aligned rectangle containing the content of the node (the border boxes of its descendants plus their non-clipped overflow), corresponding to the CSS “scrollable overflow rectangle” (https://www.w3.org/TR/css-overflow-3/#scrollable), except that transforms are not accounted for.
Coordinates are measured from the node’s scroll origin: the corner of the padding box at
the block-start/inline-start edge (the top-left corner in LTR, the top-right corner in
RTL), with left/right measuring along the inline axis in the direction of reachable
scrolling. The rectangle always contains the origin, so left/top are <= 0.0 (negative
values represent overflow before the scroll origin, which is unreachable by scrolling) and
right/bottom are >= 0.0 (representing the reachable extent of the content, which is
useful for computing a “scroll width/height” for scrollable nodes).
scrollbar_size: Size<f32>The size of the scrollbars in each dimension. If there is no scrollbar then the size will be zero.
border: Rect<f32>The size of the borders of the node
padding: Rect<f32>The size of the padding of the node
margin: Rect<f32>The size of the margin of the node
Implementations§
Source§impl Layout
impl Layout
Sourcepub const fn with_order(order: u32) -> Self
pub const fn with_order(order: u32) -> Self
Creates a new zero-Layout with the supplied order value.
Nodes with a higher order should be rendered on top of those with a lower order. The Zero-layout has size and location set to ZERO.
Examples found in repository?
More examples
36 fn default() -> Self {
37 Node {
38 kind: NodeKind::Flexbox,
39 style: Style::default(),
40 text_data: None,
41 image_data: None,
42 cache: Cache::new(),
43 unrounded_layout: Layout::with_order(0),
44 final_layout: Layout::with_order(0),
45 children: Vec::new(),
46 }
47 }34 fn default() -> Self {
35 Node {
36 kind: NodeKind::Flexbox,
37 style: Style::default(),
38 text_data: None,
39 image_data: None,
40 cache: Cache::new(),
41 unrounded_layout: Layout::with_order(0),
42 final_layout: Layout::with_order(0),
43 children: Vec::new(),
44 }
45 }Sourcepub fn content_box_width(&self) -> f32
pub fn content_box_width(&self) -> f32
Get the width of the node’s content box
Sourcepub fn content_box_height(&self) -> f32
pub fn content_box_height(&self) -> f32
Get the height of the node’s content box
Sourcepub fn content_box_size(&self) -> Size<f32>
pub fn content_box_size(&self) -> Size<f32>
Get the size of the node’s content box
Sourcepub fn content_box_x(&self) -> f32
pub fn content_box_x(&self) -> f32
Get x offset of the node’s content box relative to it’s parent’s border box
Sourcepub fn content_box_y(&self) -> f32
pub fn content_box_y(&self) -> f32
Get x offset of the node’s content box relative to it’s parent’s border box
Source§impl Layout
impl Layout
Sourcepub fn scroll_width(&self) -> f32
Available on crate feature content_size only.
pub fn scroll_width(&self) -> f32
content_size only.Return the maximum horizontal scroll offset of the node. This is the reachable extent of the content less the width of the padding box, floored at zero.
Sourcepub fn scroll_height(&self) -> f32
Available on crate feature content_size only.
pub fn scroll_height(&self) -> f32
content_size only.Return the maximum vertical scroll offset of the node. This is the reachable extent of the content less the height of the padding box, floored at zero.