pub struct GridNode {
pub rect: Rect,
pub layout: GridLayout,
pub fully_collapsed: bool,
pub collapsed_leaf_count: i32,
/* private fields */
}Expand description
The inner data of a Node::Grid: children laid out in rows and columns,
left to right then top to bottom.
Each column and each row has a share of the space, a relative weight as in a
LinearNode. A separator stands on each line between two columns and
on each line between two rows; it resizes the two columns, or the two rows, beside it.
The number of columns follows layout and the number of children, so the
shares are fitted to the columns and rows whenever the children change: a new column or
row gets the mean share of the others.
Tree adds and removes children; Tree::arrange_as_grid
turns a row or a column into a grid.
Fields§
§rect: RectThe rectangle in which all children of this node are drawn.
layout: GridLayoutHow the number of columns is chosen.
fully_collapsed: boolWhether all subnodes are collapsed.
collapsed_leaf_count: i32The number of collapsed leaf subnodes.
Implementations§
Source§impl GridNode
impl GridNode
Sourcepub fn new(layout: GridLayout, children: Vec<NodeIndex>) -> Self
pub fn new(layout: GridLayout, children: Vec<NodeIndex>) -> Self
Creates a grid holding children, row by row, with even columns and rows.
Sourcepub fn columns(&self) -> usize
pub fn columns(&self) -> usize
The number of columns: see GridLayout. At least 1, even with no children.
Sourcepub fn rows(&self) -> usize
pub fn rows(&self) -> usize
The number of rows: enough for all children, the last row possibly short.
Sourcepub fn cell(&self, index: usize) -> (usize, usize)
pub fn cell(&self, index: usize) -> (usize, usize)
The column and the row of the child at index.
The shares of the columns, left to right.
The shares of the rows, top to bottom.
Sourcepub fn col_fraction(&self, index: usize) -> f32
pub fn col_fraction(&self, index: usize) -> f32
Sourcepub fn row_fraction(&self, index: usize) -> f32
pub fn row_fraction(&self, index: usize) -> f32
Sourcepub fn col_boundary(&self, index: usize) -> f32
pub fn col_boundary(&self, index: usize) -> f32
Where the line after the column index stands, from 0 (the left of the node) to 1.
Sourcepub fn row_boundary(&self, index: usize) -> f32
pub fn row_boundary(&self, index: usize) -> f32
Where the line after the row index stands, from 0 (the top of the node) to 1.
Replaces the shares of the columns and of the rows.
§Panics
If there is not one share per column and one per row, or a share is negative or not finite.
Sourcepub fn set_layout(&mut self, layout: GridLayout)
pub fn set_layout(&mut self, layout: GridLayout)
Sets how the number of columns is chosen, and fits the shares to it.
Trait Implementations§
Auto Trait Implementations§
impl Forget for GridNode
impl Freeze for GridNode
impl Move for GridNode
impl RefUnwindSafe for GridNode
impl Send for GridNodewhere
RawVecInner: Send,
impl Sync for GridNodewhere
RawVecInner: Sync,
impl Unpin for GridNode
impl UnsafeUnpin for GridNodewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<NodeIndex>: UnsafeUnpin,
PhantomData<f32>: UnsafeUnpin,
impl UnwindSafe for GridNodewhere
RawVecInner: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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