Trait egui_dock::TabViewer

source ·
pub trait TabViewer {
    type Tab;

    // Required methods
    fn ui(&mut self, ui: &mut Ui, tab: &mut Self::Tab);
    fn title(&mut self, tab: &mut Self::Tab) -> WidgetText;

    // Provided methods
    fn context_menu(&mut self, _ui: &mut Ui, _tab: &mut Self::Tab) { ... }
    fn on_tab_button(&mut self, _tab: &mut Self::Tab, _response: &Response) { ... }
    fn on_close(&mut self, _tab: &mut Self::Tab) -> bool { ... }
    fn on_add(&mut self, _node: NodeIndex) { ... }
    fn add_popup(&mut self, _ui: &mut Ui, _node: NodeIndex) { ... }
    fn force_close(&mut self, _tab: &mut Self::Tab) -> bool { ... }
    fn inner_margin_override(&self, style: &Style) -> Margin { ... }
    fn clear_background(&self, _tab: &Self::Tab) -> bool { ... }
}
Expand description

How to display a tab inside a Tree.

Required Associated Types§

source

type Tab

The type of tab in which you can store state to be drawn in your tabs.

Required Methods§

source

fn ui(&mut self, ui: &mut Ui, tab: &mut Self::Tab)

Actual tab content.

source

fn title(&mut self, tab: &mut Self::Tab) -> WidgetText

The title to be displayed.

Provided Methods§

source

fn context_menu(&mut self, _ui: &mut Ui, _tab: &mut Self::Tab)

Content inside context_menu.

source

fn on_tab_button(&mut self, _tab: &mut Self::Tab, _response: &Response)

Called after each tab button is shown, so you can add a tooltip, check for clicks, etc.

source

fn on_close(&mut self, _tab: &mut Self::Tab) -> bool

This is called when the tabs close button is pressed.

Returns true if the tab should close immediately, false otherwise.

NOTE if returning false ui will still be called once more if this tab is active.

source

fn on_add(&mut self, _node: NodeIndex)

This is called when the tabs add button is pressed.

This requires the dock style’s show_add_buttons to be true.

The _node specifies which Node or split of the tree that this particular add button was pressed on.

source

fn add_popup(&mut self, _ui: &mut Ui, _node: NodeIndex)

Content of add_popup. Displays a popup under the add button. Useful for selecting what type of tab to add.

This requires the dock style’s show_add_buttons and show_add_popup to be true.

source

fn force_close(&mut self, _tab: &mut Self::Tab) -> bool

This is called every frame after ui is called (if the tab is active).

Returns true if the tab should be forced to close, false otherwise.

In the event this function returns true the tab will be removed without calling on_close.

source

fn inner_margin_override(&self, style: &Style) -> Margin

Sets the margins between tab’s borders and its contents.

source

fn clear_background(&self, _tab: &Self::Tab) -> bool

Whether the tab will be cleared with the color specified in Style::tab_background_color

Implementors§