Skip to main content

Panel

Trait Panel 

Source
pub trait Panel: Panel {
    // Provided methods
    fn tab_name(&self, cx: &App) -> Option<SharedString> { ... }
    fn title(
        &mut self,
        window: &mut Window,
        cx: &mut Context<'_, Self>,
    ) -> impl IntoElement { ... }
    fn title_style(&self, cx: &App) -> Option<TitleStyle> { ... }
    fn title_suffix(
        &mut self,
        window: &mut Window,
        cx: &mut Context<'_, Self>,
    ) -> Option<impl IntoElement> { ... }
    fn toolbar_buttons(
        &mut self,
        window: &mut Window,
        cx: &mut Context<'_, Self>,
    ) -> Option<Vec<Button>> { ... }
    fn dropdown_menu(
        &mut self,
        menu: PopupMenu,
        window: &mut Window,
        cx: &mut Context<'_, Self>,
    ) -> PopupMenu { ... }
    fn zoom_control(&self, cx: &App) -> Option<PanelControl> { ... }
    fn inner_padding(&self, cx: &App) -> bool { ... }
}
Expand description

What a panel draws, on top of the behavior gpui_base::dock::Panel defines.

Everything here has a default, so a panel that only implements base’s trait plus this one gets an unnamed title and no chrome.

Provided Methods§

Source

fn tab_name(&self, cx: &App) -> Option<SharedString>

The short name shown when a tab bar has no room for the full title.

Used by an already-collapsed tab group, where only the strip of tabs is on screen.

Source

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

The panel’s title, as an element rather than a string so a panel can draw an icon, a badge, or a styled fragment in the tab.

Source

fn title_style(&self, cx: &App) -> Option<TitleStyle>

Colors for the title, for a panel that wants its tab to stand out.

Source

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

An element pinned to the trailing end of the title bar.

Source

fn toolbar_buttons( &mut self, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<Vec<Button>>

Buttons for the title bar’s toolbar.

Source

fn dropdown_menu( &mut self, menu: PopupMenu, window: &mut Window, cx: &mut Context<'_, Self>, ) -> PopupMenu

Entries the panel adds to the title bar’s ellipsis menu.

Source

fn zoom_control(&self, cx: &App) -> Option<PanelControl>

Where the zoom affordance appears, or None for nowhere.

None withholds the whole affordance, not just the button: the ToggleZoom action refuses to zoom a panel that offers no control, so either answer alone is enough to mean “never zoom”. Zooming out is never refused — a panel that stops offering the control while zoomed would otherwise strand the user with no way back.

gpui_base::dock::Panel::zoomable is the other half: it decides whether zooming happens at all, and base refuses a zoom that fails it however the zoom was asked for.

Source

fn inner_padding(&self, cx: &App) -> bool

Whether the tab group pads the panel’s content when it draws it inside a tab bar.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§