#[non_exhaustive]pub enum LayoutTree<W> {
Leaf(W),
Spacer(LayoutRequest),
Margin {
margin: FaceMap<u8>,
child: Arc<LayoutTree<W>>,
},
Stack {
direction: Face6,
children: Vec<Arc<LayoutTree<W>>>,
},
Shrink(Arc<LayoutTree<W>>),
Hud {
crosshair: Arc<LayoutTree<W>>,
toolbar: Arc<LayoutTree<W>>,
control_bar: Arc<LayoutTree<W>>,
},
}Expand description
A user interface laid out in 3-dimensional space.
Leaf nodes contain values of type W which describe individual ‘widgets’ (values
that implement Layoutable); the tree structure itself describes how they are
arranged relative to each other. In this system, widgets do not contain other widgets
(at least, not for the purposes of the layout algorithm).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Leaf(W)
A single widget.
Spacer(LayoutRequest)
An space laid out like a widget but left empty.
Margin
Add the specified amount of space around the child.
Stack
Fill the available space with the children arranged along an axis.
Shrink(Arc<LayoutTree<W>>)
Don’t lay out the contents bigger than minimum.
Hud
A custom layout dedicated to the HUD.
TODO: Find a better abstraction than a variant of LayoutTree for this.
Implementations§
Source§impl<W> LayoutTree<W>
impl<W> LayoutTree<W>
Sourcepub fn leaf(widget_value: W) -> Arc<Self>
pub fn leaf(widget_value: W) -> Arc<Self>
Constructs a LayoutTree::Leaf, already wrapped in Arc.
Sourcepub fn spacer(requirements: LayoutRequest) -> Arc<Self>
pub fn spacer(requirements: LayoutRequest) -> Arc<Self>
Constructs a LayoutTree::Spacer, already wrapped in Arc.
Source§impl<W: Layoutable + Clone> LayoutTree<W>
impl<W: Layoutable + Clone> LayoutTree<W>
Sourcepub fn perform_layout(
&self,
grant: LayoutGrant,
) -> Result<Arc<LayoutTree<Positioned<W>>>, Infallible>
pub fn perform_layout( &self, grant: LayoutGrant, ) -> Result<Arc<LayoutTree<Positioned<W>>>, Infallible>
Given the specified outermost bounds, perform layout and return a tree
whose leaves are all Positioned.
TODO: haven’t decided whether layout can fail yet, hence the placeholder non-error
Source§impl LayoutTree<Arc<dyn Widget>>
impl LayoutTree<Arc<dyn Widget>>
Sourcepub fn to_space<B: Bounds>(
self: &Arc<Self>,
read_ticket: ReadTicket<'_>,
builder: Builder<'_, B>,
gravity: Gravity,
) -> Result<Space, InstallVuiError>
pub fn to_space<B: Bounds>( self: &Arc<Self>, read_ticket: ReadTicket<'_>, builder: Builder<'_, B>, gravity: Gravity, ) -> Result<Space, InstallVuiError>
Create a Space with these widgets installed in it, just large enough to fit.
Note that the widgets will not actually appear as blocks until the first time the space is stepped.
Source§impl LayoutTree<Positioned<Arc<dyn Widget>>>
impl LayoutTree<Positioned<Arc<dyn Widget>>>
Sourcepub fn installation(
&self,
read_ticket: ReadTicket<'_>,
) -> Result<SpaceTransaction, InstallVuiError>
pub fn installation( &self, read_ticket: ReadTicket<'_>, ) -> Result<SpaceTransaction, InstallVuiError>
Creates a transaction which will install all of the widgets in this tree.
The provided read_ticket should be for the universe the transaction will be executed in.
Returns an error if the widgets conflict with each other.
Trait Implementations§
Source§impl<W: Clone> Clone for LayoutTree<W>
impl<W: Clone> Clone for LayoutTree<W>
Source§fn clone(&self) -> LayoutTree<W>
fn clone(&self) -> LayoutTree<W>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<W: Debug> Debug for LayoutTree<W>
impl<W: Debug> Debug for LayoutTree<W>
Source§impl<W: Layoutable> Layoutable for LayoutTree<W>
impl<W: Layoutable> Layoutable for LayoutTree<W>
Source§fn requirements(&self) -> LayoutRequest
fn requirements(&self) -> LayoutRequest
Source§impl<W: PartialEq> PartialEq for LayoutTree<W>
impl<W: PartialEq> PartialEq for LayoutTree<W>
impl<W: Eq> Eq for LayoutTree<W>
impl<W> StructuralPartialEq for LayoutTree<W>
Auto Trait Implementations§
impl<W> Freeze for LayoutTree<W>where
W: Freeze,
impl<W> RefUnwindSafe for LayoutTree<W>where
W: RefUnwindSafe,
impl<W> Send for LayoutTree<W>
impl<W> Sync for LayoutTree<W>
impl<W> Unpin for LayoutTree<W>where
W: Unpin,
impl<W> UnwindSafe for LayoutTree<W>where
W: UnwindSafe + RefUnwindSafe,
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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