Skip to main content

DockArea

Struct DockArea 

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

The main area of the dock.

It owns one PaneTree per region and the entity cache that mirrors them. Nothing else turns a tree edit into live entities.

Implementations§

Source§

impl DockArea

Source

pub fn new( id: impl Into<SharedString>, version: Option<usize>, _window: &mut Window, cx: &mut Context<'_, Self>, ) -> Self

An empty area that draws nothing but its panels.

id names the area for the host’s own persistence; version is written into Self::dump and read back by Self::load, for a host that wants to reject or migrate a layout an older build wrote.

Install appearance with Self::with_renderer.

Source

pub fn with_renderer(self, renderer: Rc<dyn DockAreaRenderer>) -> Self

Install the appearance for this area and everything under it: the renderer also supplies the TabGroupRenderer and TilesRenderer every container it builds will use.

Source

pub fn id(&self) -> SharedString

Source

pub fn version(&self) -> Option<usize>

Source

pub fn set_version( &mut self, version: Option<usize>, cx: &mut Context<'_, Self>, )

Change the schema version a later dump writes.

Set at construction for an area whose layout never changes shape. A host that installs one of several preset layouts into the same area picks the version with the preset, which is after the area exists.

Source

pub fn bounds(&self) -> Bounds<Pixels>

The area’s own bounds, recorded each frame. Dock resizing measures against it.

Source

pub fn layout(&self, placement: DockPlacement) -> Option<&PaneTree>

The tree for one region, or None for a dock that does not exist.

The Option is in the signature rather than hidden behind a panic because a dock is genuinely optional — it is Option<DockState> in the persisted schema — and there is no borrowable empty tree to hand back for one that is absent.

Source

pub fn panel(&self, panel: PanelId) -> Option<&Arc<dyn PanelView>>

The live view for a panel, if the dock still holds it.

Source

pub fn is_locked(&self) -> bool

Source

pub fn is_empty(&self, placement: DockPlacement, cx: &App) -> bool

Whether a region currently holds no visible panel.

This is the question the old DockItem::is_empty answered, and it is the same one Self::is_node_visible answers per container: a region is empty when nothing in it would be drawn. A region that does not exist — a dock that was never installed — is empty too.

Source

pub fn set_locked( &mut self, locked: bool, window: &mut Window, cx: &mut Context<'_, Self>, )

Lock the layout against rearranging. Resizing stays available.

Source§

impl DockArea

Installing layouts: the center region and the three docks.

Source

pub fn set_center( &mut self, layout: DockLayout, window: &mut Window, cx: &mut Context<'_, Self>, )

Replace the center region with a described layout. Whatever was there leaves the dock, so its panels are told Panel::on_removed.

Source

pub fn set_dock( &mut self, placement: DockPlacement, layout: DockLayout, window: &mut Window, cx: &mut Context<'_, Self>, )

Replace one dock with a described layout, creating the dock if the area does not have one there yet. A new dock keeps the size and open state of the one it replaces, so re-filling a dock does not resize it.

DockPlacement::Center defers to Self::set_center: the center is not a dock and has no size or open state of its own.

Source

pub fn remove_dock( &mut self, placement: DockPlacement, window: &mut Window, cx: &mut Context<'_, Self>, )

Take a dock away entirely, panels and all. Distinct from Self::toggle_dock, which only takes it off screen.

Source

pub fn has_dock(&self, placement: DockPlacement) -> bool

Source

pub fn is_dock_open(&self, placement: DockPlacement) -> bool

Whether a dock is on screen. A dock the area does not have is never open, so this answers the question a caller usually means without a preceding Self::has_dock.

Source

pub fn toggle_dock( &mut self, placement: DockPlacement, window: &mut Window, cx: &mut Context<'_, Self>, )

Open a closed dock or close an open one. A dock that is not collapsible refuses to close; there is nothing to refuse when opening.

Source

pub fn is_dock_collapsible(&self, placement: DockPlacement) -> bool

Whether a dock may be collapsed at all. A skin drawing a collapse affordance in a tab bar reads this to decide whether to offer one.

Source

pub fn set_dock_collapsible( &mut self, placement: DockPlacement, collapsible: bool, _window: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn dock_size(&self, placement: DockPlacement) -> Option<Pixels>

The dock’s size along its axis.

Source

pub fn set_dock_size( &mut self, placement: DockPlacement, size: Pixels, _window: &mut Window, cx: &mut Context<'_, Self>, )

Source§

impl DockArea

Editing the layout.

Source

pub fn add_panel<P: Panel>( &mut self, panel: Entity<P>, placement: DockPlacement, size: Option<Pixels>, window: &mut Window, cx: &mut Context<'_, Self>, )

Add a panel to a region, merging it into the first tab group there, placing it on the region’s tiles canvas if that is what the region is, or starting a group when the region is empty.

Source

pub fn add_panel_view( &mut self, panel: Arc<dyn PanelView>, placement: DockPlacement, size: Option<Pixels>, window: &mut Window, cx: &mut Context<'_, Self>, )

Add an already-wrapped panel handle to a region.

The companion to Self::add_panel, for a layer that hands base its own concrete handle — see PanelView::as_any — rather than a bare entity. The id comes from PanelView::panel_id, which is the only place it can come from once the entity is behind the handle.

Source

pub fn add_tile<P: Panel>( &mut self, panel: Entity<P>, placement: DockPlacement, bounds: Bounds<Pixels>, window: &mut Window, cx: &mut Context<'_, Self>, )

Add a panel to a region’s tiles canvas at bounds.

Self::add_panel places a tile too, but only where the canvas itself chooses; this is for a host that knows where the tile belongs — most of all one acting on DockEvent::DragDrop with a DropTarget::Canvas, which reports that something was dropped on a canvas and leaves placing it to the host.

A region with no tiles canvas has nowhere to put a tile, so nothing happens and the panel is not registered.

Source

pub fn add_tile_view( &mut self, panel: Arc<dyn PanelView>, placement: DockPlacement, bounds: Bounds<Pixels>, window: &mut Window, cx: &mut Context<'_, Self>, )

Self::add_tile for an already-wrapped handle, for the same reason Self::add_panel_view is the companion to Self::add_panel.

Source

pub fn remove_panel<P: Panel>( &mut self, panel: Entity<P>, window: &mut Window, cx: &mut Context<'_, Self>, )

Remove a panel from wherever it lives, telling it that it was removed.

Source

pub fn move_panel( &mut self, panel: PanelId, target: InsertTarget, window: &mut Window, cx: &mut Context<'_, Self>, )

Move a panel to a new home. The panel never leaves the dock, so it is never told it was removed.

Source

pub fn split_at( &mut self, node: NodeId, panel: PanelId, placement: Placement, window: &mut Window, cx: &mut Context<'_, Self>, )

Put panel in a new tab group beside node.

Source§

impl DockArea

Zooming.

There is no set_zoomed_in(panel) here. A zoom is a container’s own act: only the container knows whether its displayed panel is zoomable, and only the container can tell that panel it was zoomed. So the way in is TabGroupContext::toggle_zoom or TileContext::toggle_zoom — a skin has one of those wherever it draws a zoom control — or Self::set_zoomed_in by node, which delegates to the same place. The area then installs the container that reported it.

Source

pub fn set_zoomed_in( &mut self, node: NodeId, window: &mut Window, cx: &mut Context<'_, Self>, )

Zoom the tab group at node in, as if its own zoom control had been used.

Nothing happens for a node that is not a live tab group, or when the group refuses — the group is the one that knows.

Source

pub fn set_zoomed_out( &mut self, window: &mut Window, cx: &mut Context<'_, Self>, )

Clear the zoom, putting the zoomed container’s own flag back with it.

A container toggles its zoom itself and only reports it, so an area that dropped the view without telling the container would leave it believing it still fills the dock — and a zoomed group refuses drops.

Source

pub fn is_zoomed(&self) -> bool

Source

pub fn zoomed_group(&self) -> Option<NodeId>

The tab group filling the area, if a group is what is zoomed.

Source

pub fn zoomed_tile(&self) -> Option<PanelId>

The tile filling the area, if a tile is what is zoomed.

Source§

impl DockArea

Persistence.

Source

pub fn load( &mut self, state: DockAreaState, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Result<()>

Read a persisted layout, rebuilding every panel through PanelRegistry. A panel this build does not know about becomes a placeholder that carries the original PanelState forward, so the next save does not erase it.

Source

pub fn dump(&self, cx: &App) -> DockAreaState

Write the layout out.

Slot sizes are resolved to concrete pixels first. The tree represents an unconstrained slot as None and the writer emits 0.0 for it, which this reader maps back to None — but an older build has no notion of the sentinel and would construct a real zero-pixel panel from it. Preference order is the split’s measured size, then the tree’s own size, then [PANEL_MIN_SIZE] for a slot nothing has ever measured.

The measurement wins because the tree does not track every change to it. ResizableState only emits Resized from a finished drag, so that is all the subscription in Self::split_entity writes back; adjust_to_container_size rescales every slot silently on each window resize, insert and remove. Preferring the tree would persist load-time or last-drag pixels after a window resize, and worse, mix them: a slot left None by a later insert would be filled from the current measurement while its untouched siblings kept file-era numbers, so the written ratio would match neither the file nor the screen. Reading the measurement for every slot of a split writes one internally consistent set, which is what the old StackPanel::dump did.

Trait Implementations§

Source§

impl EventEmitter<DockEvent> for DockArea

Source§

impl Focusable for DockArea

Source§

fn focus_handle(&self, _: &App) -> FocusHandle

Returns the focus handle associated with this view.
Source§

impl Render for DockArea

Source§

fn render( &mut self, window: &mut Window, cx: &mut Context<'_, Self>, ) -> impl IntoElement

Render this view into an element tree.

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> 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, 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