Skip to main content

DockLayout

Struct DockLayout 

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

Everything gpui_base::dock exports, so a consumer never has to depend on the foundation crate directly to write a skin or read a container’s state. Kept in step with base’s own list by every_base_dock_export_is_reachable_from_here.

Two names are handled elsewhere and one is deliberately absent: base’s Panel and PanelView arrive as BasePanel and BasePanelView because this module’s Panel/PanelView are the presentation halves that extend them, and base’s Dock — a plain state struct holding one dock’s open, collapsible, size and resizing flags — is not re-exported at all, because the name meant a panel container in every released version of this crate and handing it back with a different meaning is worse than dropping it. A skin reads a dock through DockContext. Describes a layout without constructing any entity.

Building a layout used to require window and cx because every node was an entity. Now a layout is data, and DockArea reconciles it into entities when it is installed.

Misuse — a panel added to a split, a child container added to a tab group, an active index on anything but a tab group — trips a debug_assert! and is otherwise ignored, matching how the old DockItem::active_index guarded itself. A type-state builder would reject the same mistakes at compile time, but it needs four marker types and leaks into every consumer signature; the runtime assertion is proportionate for a builder whose misuse shows up on the first debug run.

Implementations§

Source§

impl DockLayout

Source

pub fn h_split() -> DockLayout

A split whose children sit side by side.

Source

pub fn v_split() -> DockLayout

A split whose children stack.

Source

pub fn tabs() -> DockLayout

A tab group: panels stacked one at a time, selected from a tab bar.

Source

pub fn tiles() -> DockLayout

A tiles canvas: panels placed at free coordinates, each dragged and resized on its own.

Source

pub fn child(self, child: DockLayout, size: Option<Pixels>) -> DockLayout

Add a child container to a split. size is the child’s slot along the split’s axis; None leaves it unconstrained.

Source

pub fn panel<P>(self, panel: Entity<P>) -> DockLayout
where P: Panel,

Add a panel to a tab group.

Source

pub fn panel_view(self, panel: Arc<dyn PanelView>, cx: &App) -> DockLayout

Add an already-wrapped panel handle to a tab group.

The companion to Self::panel, for a layer that hands base its own concrete handle — see PanelView::as_any — rather than a bare entity. cx is here because the id has to come from PanelView::panel_id: unlike Self::panel, there is no entity in hand to take it from.

Source

pub fn tile<P>(self, panel: Entity<P>, bounds: Bounds<Pixels>) -> DockLayout
where P: Panel,

Place a panel on a tiles canvas.

Source

pub fn tile_view( self, panel: Arc<dyn PanelView>, bounds: Bounds<Pixels>, cx: &App, ) -> DockLayout

Place an already-wrapped panel handle on a tiles canvas. The companion to Self::tile, for the same reason Self::panel_view is the companion to Self::panel.

Source

pub fn active_index(self, ix: usize) -> DockLayout

Which tab is displayed. Out-of-range values are clamped by normalize once the layout is installed.

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