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
impl DockArea
Sourcepub fn new(
id: impl Into<SharedString>,
version: Option<usize>,
_window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Self
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.
Sourcepub fn with_renderer(self, renderer: Rc<dyn DockAreaRenderer>) -> Self
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.
pub fn id(&self) -> SharedString
pub fn version(&self) -> Option<usize>
Sourcepub fn set_version(
&mut self,
version: Option<usize>,
cx: &mut Context<'_, Self>,
)
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.
Sourcepub fn bounds(&self) -> Bounds<Pixels>
pub fn bounds(&self) -> Bounds<Pixels>
The area’s own bounds, recorded each frame. Dock resizing measures against it.
Sourcepub fn layout(&self, placement: DockPlacement) -> Option<&PaneTree>
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.
Sourcepub fn panel(&self, panel: PanelId) -> Option<&Arc<dyn PanelView>>
pub fn panel(&self, panel: PanelId) -> Option<&Arc<dyn PanelView>>
The live view for a panel, if the dock still holds it.
pub fn is_locked(&self) -> bool
Sourcepub fn is_empty(&self, placement: DockPlacement, cx: &App) -> bool
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.
Sourcepub fn set_locked(
&mut self,
locked: bool,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
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.
impl DockArea
Installing layouts: the center region and the three docks.
Sourcepub fn set_center(
&mut self,
layout: DockLayout,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
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.
Sourcepub fn set_dock(
&mut self,
placement: DockPlacement,
layout: DockLayout,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
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.
Sourcepub fn remove_dock(
&mut self,
placement: DockPlacement,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
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.
pub fn has_dock(&self, placement: DockPlacement) -> bool
Sourcepub fn is_dock_open(&self, placement: DockPlacement) -> bool
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.
Sourcepub fn toggle_dock(
&mut self,
placement: DockPlacement,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
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.
Sourcepub fn is_dock_collapsible(&self, placement: DockPlacement) -> bool
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.
pub fn set_dock_collapsible( &mut self, placement: DockPlacement, collapsible: bool, _window: &mut Window, cx: &mut Context<'_, Self>, )
Sourcepub fn dock_size(&self, placement: DockPlacement) -> Option<Pixels>
pub fn dock_size(&self, placement: DockPlacement) -> Option<Pixels>
The dock’s size along its axis.
pub fn set_dock_size( &mut self, placement: DockPlacement, size: Pixels, _window: &mut Window, cx: &mut Context<'_, Self>, )
Source§impl DockArea
Editing the layout.
impl DockArea
Editing the layout.
Sourcepub fn add_panel<P: Panel>(
&mut self,
panel: Entity<P>,
placement: DockPlacement,
size: Option<Pixels>,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
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.
Sourcepub fn add_panel_view(
&mut self,
panel: Arc<dyn PanelView>,
placement: DockPlacement,
size: Option<Pixels>,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
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.
Sourcepub fn add_tile<P: Panel>(
&mut self,
panel: Entity<P>,
placement: DockPlacement,
bounds: Bounds<Pixels>,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
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.
Sourcepub fn add_tile_view(
&mut self,
panel: Arc<dyn PanelView>,
placement: DockPlacement,
bounds: Bounds<Pixels>,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
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.
Sourcepub fn remove_panel<P: Panel>(
&mut self,
panel: Entity<P>,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
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.
Sourcepub fn move_panel(
&mut self,
panel: PanelId,
target: InsertTarget,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
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§impl DockArea
Zooming.
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.
Sourcepub fn set_zoomed_in(
&mut self,
node: NodeId,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
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.
Sourcepub fn set_zoomed_out(
&mut self,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
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.
pub fn is_zoomed(&self) -> bool
Sourcepub fn zoomed_group(&self) -> Option<NodeId>
pub fn zoomed_group(&self) -> Option<NodeId>
The tab group filling the area, if a group is what is zoomed.
Sourcepub fn zoomed_tile(&self) -> Option<PanelId>
pub fn zoomed_tile(&self) -> Option<PanelId>
The tile filling the area, if a tile is what is zoomed.
Source§impl DockArea
Persistence.
impl DockArea
Persistence.
Sourcepub fn load(
&mut self,
state: DockAreaState,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Result<()>
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.
Sourcepub fn dump(&self, cx: &App) -> DockAreaState
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§
impl EventEmitter<DockEvent> for DockArea
Source§impl Focusable for DockArea
impl Focusable for DockArea
Source§fn focus_handle(&self, _: &App) -> FocusHandle
fn focus_handle(&self, _: &App) -> FocusHandle
Auto Trait Implementations§
impl !RefUnwindSafe for DockArea
impl !Send for DockArea
impl !Sync for DockArea
impl !UnwindSafe for DockArea
impl Freeze for DockArea
impl Unpin for DockArea
impl UnsafeUnpin for DockArea
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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