Skip to main content

GridNode

Struct GridNode 

Source
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: Rect

The rectangle in which all children of this node are drawn.

§layout: GridLayout

How the number of columns is chosen.

§fully_collapsed: bool

Whether all subnodes are collapsed.

§collapsed_leaf_count: i32

The number of collapsed leaf subnodes.

Implementations§

Source§

impl GridNode

Source

pub fn new(layout: GridLayout, children: Vec<NodeIndex>) -> Self

Creates a grid holding children, row by row, with even columns and rows.

Source

pub fn set_rect(&mut self, new_rect: Rect)

Set the area which this node occupies.

Source

pub fn rect(&self) -> Rect

Get the area which this node occupies.

Source

pub fn children(&self) -> &[NodeIndex]

The children, row by row, each row from left to right.

Source

pub fn len(&self) -> usize

The number of children.

Source

pub fn is_empty(&self) -> bool

Whether the node has no children (never the case in a Tree).

Source

pub fn position(&self, child: NodeIndex) -> Option<usize>

Where child is among the children.

Source

pub fn columns(&self) -> usize

The number of columns: see GridLayout. At least 1, even with no children.

Source

pub fn rows(&self) -> usize

The number of rows: enough for all children, the last row possibly short.

Source

pub fn cell(&self, index: usize) -> (usize, usize)

The column and the row of the child at index.

Source

pub fn col_shares(&self) -> &[f32]

The shares of the columns, left to right.

Source

pub fn row_shares(&self) -> &[f32]

The shares of the rows, top to bottom.

Source

pub fn col_fraction(&self, index: usize) -> f32

The part of the width (0 to 1) the column index gets.

§Panics

If index is not a column.

Source

pub fn row_fraction(&self, index: usize) -> f32

The part of the height (0 to 1) the row index gets.

§Panics

If index is not a row.

Source

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.

Source

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.

Source

pub fn set_shares(&mut self, col_shares: Vec<f32>, row_shares: Vec<f32>)

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.

Source

pub fn set_layout(&mut self, layout: GridLayout)

Sets how the number of columns is chosen, and fits the shares to it.

Trait Implementations§

Source§

impl Clone for GridNode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GridNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GridNode

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Forget for GridNode

§

impl Freeze for GridNode

§

impl Move for GridNode

§

impl RefUnwindSafe for GridNode

§

impl Send for GridNode
where RawVecInner: Send,

§

impl Sync for GridNode
where RawVecInner: Sync,

§

impl Unpin for GridNode
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for GridNode

§

impl UnwindSafe for GridNode
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.