Trait egui_tiles::Behavior
source · pub trait Behavior<Pane> {
Show 23 methods
// Required methods
fn pane_ui(
&mut self,
_ui: &mut Ui,
_tile_id: TileId,
_pane: &mut Pane
) -> UiResponse;
fn tab_title_for_pane(&mut self, pane: &Pane) -> WidgetText;
// Provided methods
fn tab_title_for_tile(
&mut self,
tiles: &Tiles<Pane>,
tile_id: TileId
) -> WidgetText { ... }
fn tab_ui(
&mut self,
tiles: &Tiles<Pane>,
ui: &mut Ui,
id: Id,
tile_id: TileId,
active: bool,
is_being_dragged: bool
) -> Response { ... }
fn on_tab_button(
&mut self,
_tiles: &Tiles<Pane>,
_tile_id: TileId,
_button_response: &Response
) { ... }
fn retain_pane(&mut self, _pane: &Pane) -> bool { ... }
fn top_bar_rtl_ui(
&mut self,
_tiles: &Tiles<Pane>,
_ui: &mut Ui,
_tile_id: TileId,
_tabs: &Tabs
) { ... }
fn tab_bar_height(&self, _style: &Style) -> f32 { ... }
fn gap_width(&self, _style: &Style) -> f32 { ... }
fn min_size(&self) -> f32 { ... }
fn preview_dragged_panes(&self) -> bool { ... }
fn dragged_overlay_color(&self, visuals: &Visuals) -> Color32 { ... }
fn simplification_options(&self) -> SimplificationOptions { ... }
fn resize_stroke(&self, style: &Style, resize_state: ResizeState) -> Stroke { ... }
fn tab_title_spacing(&self, _visuals: &Visuals) -> f32 { ... }
fn tab_bar_color(&self, visuals: &Visuals) -> Color32 { ... }
fn tab_bg_color(
&self,
visuals: &Visuals,
_tile_id: TileId,
active: bool
) -> Color32 { ... }
fn tab_outline_stroke(
&self,
visuals: &Visuals,
_tile_id: TileId,
active: bool
) -> Stroke { ... }
fn tab_bar_hline_stroke(&self, visuals: &Visuals) -> Stroke { ... }
fn tab_text_color(
&self,
visuals: &Visuals,
_tile_id: TileId,
active: bool
) -> Color32 { ... }
fn paint_drag_preview(
&self,
visuals: &Visuals,
painter: &Painter,
parent_rect: Option<Rect>,
preview_rect: Rect
) { ... }
fn grid_auto_column_count(
&self,
num_visible_children: usize,
rect: Rect,
gap: f32
) -> usize { ... }
fn ideal_tile_aspect_ratio(&self) -> f32 { ... }
}
Expand description
Trait defining how the super::Tree
and its panes should be shown.
Required Methods§
sourcefn pane_ui(
&mut self,
_ui: &mut Ui,
_tile_id: TileId,
_pane: &mut Pane
) -> UiResponse
fn pane_ui( &mut self, _ui: &mut Ui, _tile_id: TileId, _pane: &mut Pane ) -> UiResponse
Show a pane tile in the given egui::Ui
.
You can make the pane draggable by returning UiResponse::DragStarted
when the user drags some handle.
sourcefn tab_title_for_pane(&mut self, pane: &Pane) -> WidgetText
fn tab_title_for_pane(&mut self, pane: &Pane) -> WidgetText
The title of a pane tab.
Provided Methods§
sourcefn tab_title_for_tile(
&mut self,
tiles: &Tiles<Pane>,
tile_id: TileId
) -> WidgetText
fn tab_title_for_tile( &mut self, tiles: &Tiles<Pane>, tile_id: TileId ) -> WidgetText
The title of a general tab.
The default implementation calls Self::tab_title_for_pane
for panes and
uses the name of the crate::ContainerKind
for crate::Container
s.
sourcefn tab_ui(
&mut self,
tiles: &Tiles<Pane>,
ui: &mut Ui,
id: Id,
tile_id: TileId,
active: bool,
is_being_dragged: bool
) -> Response
fn tab_ui( &mut self, tiles: &Tiles<Pane>, ui: &mut Ui, id: Id, tile_id: TileId, active: bool, is_being_dragged: bool ) -> Response
Show the ui for the a tab of some tile.
The default implementation shows a clickable button with the title for that tile,
gotten with Self::tab_title_for_tile
.
The default implementation also calls Self::on_tab_button
.
You can override the default implementation to add e.g. a close button. Make sure it is sensitive to clicks and drags (if you want to enable drag-and-drop of tabs).
Called by the default implementation of Self::tab_ui
for each added button
sourcefn retain_pane(&mut self, _pane: &Pane) -> bool
fn retain_pane(&mut self, _pane: &Pane) -> bool
Return false
if a given pane should be removed from its parent.
sourcefn top_bar_rtl_ui(
&mut self,
_tiles: &Tiles<Pane>,
_ui: &mut Ui,
_tile_id: TileId,
_tabs: &Tabs
)
fn top_bar_rtl_ui( &mut self, _tiles: &Tiles<Pane>, _ui: &mut Ui, _tile_id: TileId, _tabs: &Tabs )
Adds some UI to the top right of each tab bar.
You can use this to, for instance, add a button for adding new tabs.
The widgets will be added right-to-left.
sourcefn tab_bar_height(&self, _style: &Style) -> f32
fn tab_bar_height(&self, _style: &Style) -> f32
The height of the bar holding tab titles.
sourcefn gap_width(&self, _style: &Style) -> f32
fn gap_width(&self, _style: &Style) -> f32
Width of the gap between tiles in a horizontal or vertical layout, and between rows/columns in a grid layout.
sourcefn preview_dragged_panes(&self) -> bool
fn preview_dragged_panes(&self) -> bool
Show we preview panes that are being dragged, i.e. show their ui in the region where they will end up?
sourcefn dragged_overlay_color(&self, visuals: &Visuals) -> Color32
fn dragged_overlay_color(&self, visuals: &Visuals) -> Color32
Cover the tile that is being dragged with this color.
sourcefn simplification_options(&self) -> SimplificationOptions
fn simplification_options(&self) -> SimplificationOptions
What are the rules for simplifying the tree?
sourcefn resize_stroke(&self, style: &Style, resize_state: ResizeState) -> Stroke
fn resize_stroke(&self, style: &Style, resize_state: ResizeState) -> Stroke
The stroke used for the lines in horizontal, vertical, and grid layouts.
sourcefn tab_title_spacing(&self, _visuals: &Visuals) -> f32
fn tab_title_spacing(&self, _visuals: &Visuals) -> f32
Extra spacing to left and right of tab titles.
sourcefn tab_bar_color(&self, visuals: &Visuals) -> Color32
fn tab_bar_color(&self, visuals: &Visuals) -> Color32
The background color of the tab bar.
sourcefn tab_bg_color(
&self,
visuals: &Visuals,
_tile_id: TileId,
active: bool
) -> Color32
fn tab_bg_color( &self, visuals: &Visuals, _tile_id: TileId, active: bool ) -> Color32
The background color of a tab.
sourcefn tab_outline_stroke(
&self,
visuals: &Visuals,
_tile_id: TileId,
active: bool
) -> Stroke
fn tab_outline_stroke( &self, visuals: &Visuals, _tile_id: TileId, active: bool ) -> Stroke
Stroke of the outline around a tab title.
sourcefn tab_bar_hline_stroke(&self, visuals: &Visuals) -> Stroke
fn tab_bar_hline_stroke(&self, visuals: &Visuals) -> Stroke
Stroke of the line separating the tab title bar and the content of the active tab.
sourcefn tab_text_color(
&self,
visuals: &Visuals,
_tile_id: TileId,
active: bool
) -> Color32
fn tab_text_color( &self, visuals: &Visuals, _tile_id: TileId, active: bool ) -> Color32
The color of the title text of the tab.
sourcefn paint_drag_preview(
&self,
visuals: &Visuals,
painter: &Painter,
parent_rect: Option<Rect>,
preview_rect: Rect
)
fn paint_drag_preview( &self, visuals: &Visuals, painter: &Painter, parent_rect: Option<Rect>, preview_rect: Rect )
When drag-and-dropping a tile, how do we preview what is about to happen?
sourcefn grid_auto_column_count(
&self,
num_visible_children: usize,
rect: Rect,
gap: f32
) -> usize
fn grid_auto_column_count( &self, num_visible_children: usize, rect: Rect, gap: f32 ) -> usize
How many columns should we use for a crate::Grid
put into crate::GridLayout::Auto
?
The default heuristic tried to find a good column count that results in a per-tile aspect-ratio
of Self::ideal_tile_aspect_ratio
.
The rect
is the available space for the grid,
and gap
is the distance between each column and row.
sourcefn ideal_tile_aspect_ratio(&self) -> f32
fn ideal_tile_aspect_ratio(&self) -> f32
When using crate::GridLayout::Auto
, what is the ideal aspect ratio of a tile?