Trait egui_dock::widgets::tab_viewer::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 id(&mut self, tab: &mut Self::Tab) -> Id { ... }
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 tab_style_override(
&self,
_tab: &Self::Tab,
_global_style: &TabStyle
) -> Option<TabStyle> { ... }
fn clear_background(&self, _tab: &Self::Tab) -> bool { ... }
}
Expand description
Defines how to display a tab inside a Tree
.
Required Associated Types§
Required Methods§
sourcefn title(&mut self, tab: &mut Self::Tab) -> WidgetText
fn title(&mut self, tab: &mut Self::Tab) -> WidgetText
The title to be displayed.
Provided Methods§
Content inside context_menu.
sourcefn id(&mut self, tab: &mut Self::Tab) -> Id
fn id(&mut self, tab: &mut Self::Tab) -> Id
Unique id for this tab.
If not implemented, uses tab title text as an id source.
Called after each tab button is shown, so you can add a tooltip, check for clicks, etc.
sourcefn on_close(&mut self, _tab: &mut Self::Tab) -> bool
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.
sourcefn on_add(&mut self, _node: NodeIndex)
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.
sourcefn add_popup(&mut self, _ui: &mut Ui, _node: NodeIndex)
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
.
sourcefn force_close(&mut self, _tab: &mut Self::Tab) -> bool
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
.
sourcefn tab_style_override(
&self,
_tab: &Self::Tab,
_global_style: &TabStyle
) -> Option<TabStyle>
fn tab_style_override( &self, _tab: &Self::Tab, _global_style: &TabStyle ) -> Option<TabStyle>
Sets custom style for given tab.
sourcefn clear_background(&self, _tab: &Self::Tab) -> bool
fn clear_background(&self, _tab: &Self::Tab) -> bool
Whether the tab will be cleared with the color specified in TabBarStyle::bg_fill