Skip to main content

PaneTree

Struct PaneTree 

Source
pub struct PaneTree { /* private fields */ }
Expand description

One region’s layout, as pure data.

A DockArea owns one of these per region — the center plus each dock it has. Containers are addressed by NodeId and panels by PanelId; no entity handle lives in here, so a tree can be built, edited, compared and serialized with no App in sight.

Every edit method normalizes before returning and reports what it did as an EditResult, so there is no window in which a caller can observe a tree with an empty container, a one-child split, or an out-of-range active index.

Implementations§

Source§

impl PaneTree

Source

pub fn insert_panel( &mut self, panel: PanelId, target: InsertTarget, ) -> EditResult

Source

pub fn remove_panel(&mut self, panel: PanelId) -> EditResult

Source

pub fn move_panel(&mut self, panel: PanelId, target: InsertTarget) -> EditResult

Move a panel to a new home without ever removing it from the tree’s perspective, so the caller never fires on_removed for a drag.

Source

pub fn split( &mut self, at: NodeId, panel: PanelId, placement: Placement, size: Option<Pixels>, ) -> EditResult

Source

pub fn set_active(&mut self, node: NodeId, ix: usize) -> EditResult

Source

pub fn set_sizes( &mut self, node: NodeId, new_sizes: Vec<Option<Pixels>>, ) -> EditResult

Replace a split’s slot sizes wholesale.

A no-op, like every other operation given input it cannot resolve, if new_sizes.len() does not match the split’s child count: no rule in normalize repairs a length mismatch, so applying it would otherwise leave children.len() != sizes.len() and trip normalize’s debug_assert!.

Source

pub fn set_tile_bounds( &mut self, panel: PanelId, bounds: Bounds<Pixels>, ) -> EditResult

Source

pub fn bring_to_front(&mut self, panel: PanelId) -> EditResult

Source§

impl PaneTree

Source

pub fn contains_panel(&self, panel: PanelId) -> bool

Whether panel is anywhere in this tree.

Source§

impl PaneTree

Source

pub fn normalize(&mut self)

Collapse the tree to canonical shape.

One post-order pass repeated to a fixpoint. This is the only place a container is removed for being empty, replacing the mutually recursive remove_self_if_empty pair the old implementation used. It needs no parent pointers and no deferred work, so the tree is self-consistent the instant an edit returns.

Rules, applied bottom up:

  1. An empty Tabs, Tiles, or Split is removed from its parent.
  2. A Split with one child is replaced by that child. The child keeps its own NodeId and inherits the split’s slot size.
  3. A Split whose child is a Split of the same axis splices that child’s children into itself.
  4. active_ix is clamped.
  5. The root is preserved according to RootKind.

Idempotent: normalize(normalize(t)) == normalize(t).

Source§

impl PaneTree

Source

pub fn new(root_kind: RootKind) -> Self

Source

pub fn root(&self) -> &PaneNode

Source

pub fn root_kind(&self) -> RootKind

Source

pub fn node_ids(&self) -> Vec<NodeId>

Every container id in the tree, in pre-order.

Source

pub fn panels(&self) -> impl Iterator<Item = PanelId>

Every panel in the tree, in pre-order.

Source

pub fn find_node(&self, id: NodeId) -> Option<&PaneNode>

Source

pub fn find_panel_node(&self, panel: PanelId) -> Option<NodeId>

The tab or tiles node holding panel.

Source§

impl PaneTree

Source

pub fn to_state(&self, source: &dyn PanelSource) -> PanelState

Source§

impl PaneTree

Source

pub fn from_state( state: &PanelState, root_kind: RootKind, builder: &mut dyn PanelBuilder, ) -> Self

Read a persisted layout.

Compatibility rules, all previously implicit in PanelState::to_item:

  • a Tabs whose children are themselves Tabs is flattened;
  • a bare Panel leaf appearing where a container belongs is wrapped in a Tabs;
  • a node named TabPanel carrying PanelInfo::Panel is read as an empty tab group, recovering data written by the old dump defect (an empty TabPanel never entered the loop that set its info to Tabs, so it kept PanelState’s default Panel(Value::Null)). The old reader had no such rule: it looked “TabPanel” up in the panel registry, found nothing, and rendered an InvalidPanel placeholder where an empty tab group belonged. This rule is a genuine fix, not a preserved behavior;
  • a Tiles child without a matching meta keeps the default placement. The old writer’s counterpart (DockItem::tiles) hard-asserted items.len() == metas.len() and panicked the whole load on a short metas list, so this rule is a new safety net, not a preserved graceful-degradation path.

Trait Implementations§

Source§

impl Clone for PaneTree

Source§

fn clone(&self) -> PaneTree

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 PaneTree

Source§

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

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

impl PartialEq for PaneTree

Source§

fn eq(&self, other: &PaneTree) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PaneTree

Auto Trait Implementations§

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<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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more