pub trait Panel:
EventEmitter<PanelEvent>
+ Render
+ Focusable {
// Required method
fn panel_name(&self) -> &'static str;
// Provided methods
fn visible(&self, cx: &App) -> bool { ... }
fn closable(&self, cx: &App) -> bool { ... }
fn zoomable(&self, cx: &App) -> bool { ... }
fn set_active(
&mut self,
active: bool,
window: &mut Window,
cx: &mut Context<'_, Self>,
) { ... }
fn set_zoomed(
&mut self,
zoomed: bool,
window: &mut Window,
cx: &mut Context<'_, Self>,
) { ... }
fn on_added_to(
&mut self,
group: WeakEntity<TabGroup>,
window: &mut Window,
cx: &mut Context<'_, Self>,
) { ... }
fn on_removed(&mut self, window: &mut Window, cx: &mut Context<'_, Self>) { ... }
fn dump(&self, cx: &App) -> PanelState { ... }
}Expand description
Behavior a dockable panel provides. Presentation lives in the layer above:
gpui_component::dock::Panel extends this with titles, toolbars, and menus.
Required Methods§
Sourcefn panel_name(&self) -> &'static str
fn panel_name(&self) -> &'static str
Identifies the panel in persisted layouts. Once chosen, never change it.
Provided Methods§
Sourcefn visible(&self, cx: &App) -> bool
fn visible(&self, cx: &App) -> bool
Whether the panel is drawn at all. A hidden panel keeps its place in the layout tree and its tab, and reappears when this turns back on; a container whose panels are all hidden gives up its slot.
Sourcefn closable(&self, cx: &App) -> bool
fn closable(&self, cx: &App) -> bool
Whether the panel may be closed. A container can still refuse — the last group of a dock does — so this is permission, not a guarantee.
Sourcefn zoomable(&self, cx: &App) -> bool
fn zoomable(&self, cx: &App) -> bool
Whether the panel can zoom at all. Where the zoom control appears is a presentation decision and belongs to the layer above.
Sourcefn set_active(
&mut self,
active: bool,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
fn set_active( &mut self, active: bool, window: &mut Window, cx: &mut Context<'_, Self>, )
Called with the frame-end net state when this panel becomes, or stops being, the displayed tab of its group: exactly one notification per edge, delivered on the next tick after the change — never same-value repeats nor false-then-true flips within one frame.
A panel removed from its group is NOT told false; Panel::on_removed
is the deactivation signal. A hidden panel occupying the active slot
still receives true even though rendering falls back to the first
visible panel.
Sourcefn set_zoomed(
&mut self,
zoomed: bool,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
fn set_zoomed( &mut self, zoomed: bool, window: &mut Window, cx: &mut Context<'_, Self>, )
Called when the group displaying this panel zooms in or out.
Only the panel that is currently displayed is told: a group has one zoom state, and it is the visible panel that fills the dock. Panels sharing the group’s other tabs hear nothing, and a panel that is not displayed when the zoom changes is never told about it retroactively.
Sourcefn on_added_to(
&mut self,
group: WeakEntity<TabGroup>,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
fn on_added_to( &mut self, group: WeakEntity<TabGroup>, window: &mut Window, cx: &mut Context<'_, Self>, )
Called when the panel joins a tab group, with a weak handle on it.
Delivered before any set_active, so a panel can hold the handle and
act on the first activation. A panel moved between groups is told
again, with the new group; it is not told it was removed in between.
Sourcefn on_removed(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
fn on_removed(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Called when the panel leaves the dock for good — closed, or displaced
by a wholesale set_center, set_dock, remove_dock or load.
This is also the deactivation signal: a panel that was displayed is not
told set_active(false) on its way out. A panel dragged from one group
to another never leaves the dock, so it never hears this.
Sourcefn dump(&self, cx: &App) -> PanelState
fn dump(&self, cx: &App) -> PanelState
The panel’s own persisted state, written into the layout under its
panel_name and handed back to the
PanelRegistry builder on the next load.
The default records the name and nothing else, which is enough for a panel whose builder can reconstruct it from the name alone.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".