Skip to main content

DockAreaRenderer

Trait DockAreaRenderer 

Source
pub trait DockAreaRenderer: 'static {
    // Required methods
    fn tab_group_renderer(&self) -> Rc<dyn TabGroupRenderer>;
    fn tiles_renderer(&self) -> Rc<dyn TilesRenderer>;

    // Provided methods
    fn frame(&self, window: &mut Window, cx: &mut App) -> Stateful<Div> { ... }
    fn split_frame(
        &self,
        node: NodeId,
        axis: Axis,
        window: &mut Window,
        cx: &mut App,
    ) -> Stateful<Div> { ... }
    fn center_frame(&self, window: &mut Window, cx: &mut App) -> Stateful<Div> { ... }
    fn render_split_handle(
        &self,
        handle: &ResizeHandleContext,
        window: &mut Window,
        cx: &mut App,
    ) -> Option<AnyElement> { ... }
    fn render_dock(
        &self,
        dock: &DockContext,
        content: AnyElement,
        window: &mut Window,
        cx: &mut App,
    ) -> AnyElement { ... }
    fn build_placeholder(
        &self,
        state: &PanelState,
        window: &mut Window,
        cx: &mut App,
    ) -> Option<Arc<dyn PanelView>> { ... }
}
Expand description

Appearance for the dock area. Base draws none of it.

The frame hooks return the element itself rather than wrapping one, for the same reason TabGroupRenderer’s do: base tracks focus and records the area bounds on the very element the skin styles.

There is no separate render_resize_handle hook. A handle needs to be positioned against the dock it resizes, and positioning is the skin’s; the skin draws it inside Self::render_dock and drives it through DockContext::resize_to.

Required Methods§

Provided Methods§

Source

fn frame(&self, window: &mut Window, cx: &mut App) -> Stateful<Div>

The area’s outer frame, which base records its bounds on. Appearance only. The area is laid out as a row around whatever this returns, because that is what makes a dock a column beside the centre rather than a block above it, and a renderer cannot be expected to know it had a row to declare.

Source

fn split_frame( &self, node: NodeId, axis: Axis, window: &mut Window, cx: &mut App, ) -> Stateful<Div>

One split container’s frame, around base’s resizable group.

This one really is a wrapper, unlike the other frame hooks, and deliberately: base attaches nothing to it, so there is no hit area to separate from the painted area. It exists because the old StackPanel carried real appearance here — a background and an overflow clip — and without it a skin could style a dock and a tab group but nothing in between. Stateful<Div> rather than a plain one so the skin keeps a role, a tooltip, and scroll tracking.

Source

fn center_frame(&self, window: &mut Window, cx: &mut App) -> Stateful<Div>

The column holding the center region and the bottom dock. Appearance only; see DockAreaRenderer::frame. The centre fills what the side docks leave and stacks with the bottom dock either way.

Source

fn render_split_handle( &self, handle: &ResizeHandleContext, window: &mut Window, cx: &mut App, ) -> Option<AnyElement>

The painted part of the divider between two slots of a split.

None keeps base’s own one-pixel line, so a skin that has no opinion about dividers implements nothing. The hit area, the cursor and the drag itself stay with base either way — this hook supplies appearance only, and is told the axis and whether the divider is being dragged.

Source

fn render_dock( &self, dock: &DockContext, content: AnyElement, window: &mut Window, cx: &mut App, ) -> AnyElement

One dock’s chrome around its content: the title strip, the collapse affordance, and the resize handle.

Chrome only. The dock’s own box – its extent along its own axis, and the flex_none that holds it there – is applied by DockArea::render_dock around whatever this returns, so a renderer cannot misplace a dock by not knowing to size it, and the default here can be what it is: the content, undecorated.

Source

fn build_placeholder( &self, state: &PanelState, window: &mut Window, cx: &mut App, ) -> Option<Arc<dyn PanelView>>

The stand-in for a panel this build cannot construct — one whose panel_name no PanelRegistry builder answers to. None takes base’s own placeholder, which draws nothing.

The hook exists because a placeholder cannot be wrapped after the fact: presentation reaches base only through the handle a panel is registered behind, so whoever creates the panel decides what it can draw. An “unknown panel” message is presentation, so the skin creates that panel or does without one.

A placeholder is what gets written back out on the next save, so one supplied here should answer Panel::dump with state unchanged — otherwise saving after a load erases the panel it stood in for. Base’s own placeholder does; nothing here can enforce it of a skin’s.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§