pub trait Behavior<Pane> {
Show 33 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_hover_cursor_icon(&self) -> CursorIcon { ... }
fn is_tab_closable(&self, _tiles: &Tiles<Pane>, _tile_id: TileId) -> bool { ... }
fn on_tab_close(
&mut self,
_tiles: &mut Tiles<Pane>,
_tile_id: TileId,
) -> bool { ... }
fn close_button_outer_size(&self) -> f32 { ... }
fn close_button_inner_margin(&self) -> f32 { ... }
fn tab_title_for_tile(
&mut self,
tiles: &Tiles<Pane>,
tile_id: TileId,
) -> WidgetText { ... }
fn tab_ui(
&mut self,
tiles: &mut Tiles<Pane>,
ui: &mut Ui,
id: Id,
tile_id: TileId,
state: &TabState,
) -> Response { ... }
fn drag_ui(&mut self, tiles: &Tiles<Pane>, ui: &mut Ui, tile_id: TileId) { ... }
fn on_tab_button(
&mut self,
_tiles: &Tiles<Pane>,
_tile_id: TileId,
button_response: Response,
) -> Response { ... }
fn retain_pane(&mut self, _pane: &Pane) -> bool { ... }
fn top_bar_right_ui(
&mut self,
_tiles: &Tiles<Pane>,
_ui: &mut Ui,
_tile_id: TileId,
_tabs: &Tabs,
_scroll_offset: &mut f32,
) { ... }
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 paint_on_top_of_tile(
&self,
_painter: &Painter,
_style: &Style,
_tile_id: TileId,
_rect: Rect,
) { ... }
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,
_tiles: &Tiles<Pane>,
_tile_id: TileId,
state: &TabState,
) -> Color32 { ... }
fn tab_outline_stroke(
&self,
visuals: &Visuals,
_tiles: &Tiles<Pane>,
_tile_id: TileId,
state: &TabState,
) -> Stroke { ... }
fn tab_bar_hline_stroke(&self, visuals: &Visuals) -> Stroke { ... }
fn tab_text_color(
&self,
visuals: &Visuals,
_tiles: &Tiles<Pane>,
_tile_id: TileId,
state: &TabState,
) -> Color32 { ... }
fn drag_preview_stroke(&self, visuals: &Visuals) -> Stroke { ... }
fn drag_preview_color(&self, visuals: &Visuals) -> 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 { ... }
fn on_edit(&mut self, _edit_action: EditAction) { ... }
}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_hover_cursor_icon(&self) -> CursorIcon
fn tab_hover_cursor_icon(&self) -> CursorIcon
The cursor icon when hovering over a tab.
Sourcefn is_tab_closable(&self, _tiles: &Tiles<Pane>, _tile_id: TileId) -> bool
fn is_tab_closable(&self, _tiles: &Tiles<Pane>, _tile_id: TileId) -> bool
Should the tab have a close-button?
Sourcefn on_tab_close(&mut self, _tiles: &mut Tiles<Pane>, _tile_id: TileId) -> bool
fn on_tab_close(&mut self, _tiles: &mut Tiles<Pane>, _tile_id: TileId) -> bool
Called when the close-button on a tab is pressed.
Return false to abort the closing of a tab (e.g. after showing a message box).
The size of the close button in the tab.
How much smaller the visual part of the close-button will be
compared to Self::close_button_outer_size.
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::Containers.
Sourcefn tab_ui(
&mut self,
tiles: &mut Tiles<Pane>,
ui: &mut Ui,
id: Id,
tile_id: TileId,
state: &TabState,
) -> Response
fn tab_ui( &mut self, tiles: &mut Tiles<Pane>, ui: &mut Ui, id: Id, tile_id: TileId, state: &TabState, ) -> 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).
Sourcefn drag_ui(&mut self, tiles: &Tiles<Pane>, ui: &mut Ui, tile_id: TileId)
fn drag_ui(&mut self, tiles: &Tiles<Pane>, ui: &mut Ui, tile_id: TileId)
Show the ui for the tab being dragged.
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_right_ui(
&mut self,
_tiles: &Tiles<Pane>,
_ui: &mut Ui,
_tile_id: TileId,
_tabs: &Tabs,
_scroll_offset: &mut f32,
)
fn top_bar_right_ui( &mut self, _tiles: &Tiles<Pane>, _ui: &mut Ui, _tile_id: TileId, _tabs: &Tabs, _scroll_offset: &mut f32, )
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.
_scroll_offset is a mutable reference to the tab scroll value.
Adding to this value will scroll the tabs to the right, subtracting to the 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 paint_on_top_of_tile(
&self,
_painter: &Painter,
_style: &Style,
_tile_id: TileId,
_rect: Rect,
)
fn paint_on_top_of_tile( &self, _painter: &Painter, _style: &Style, _tile_id: TileId, _rect: Rect, )
Add some custom painting on top of a tile (container or pane), e.g. draw an outline on top of it.
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,
_tiles: &Tiles<Pane>,
_tile_id: TileId,
state: &TabState,
) -> Color32
fn tab_bg_color( &self, visuals: &Visuals, _tiles: &Tiles<Pane>, _tile_id: TileId, state: &TabState, ) -> Color32
The background color of a tab.
Sourcefn tab_outline_stroke(
&self,
visuals: &Visuals,
_tiles: &Tiles<Pane>,
_tile_id: TileId,
state: &TabState,
) -> Stroke
fn tab_outline_stroke( &self, visuals: &Visuals, _tiles: &Tiles<Pane>, _tile_id: TileId, state: &TabState, ) -> 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,
_tiles: &Tiles<Pane>,
_tile_id: TileId,
state: &TabState,
) -> Color32
fn tab_text_color( &self, visuals: &Visuals, _tiles: &Tiles<Pane>, _tile_id: TileId, state: &TabState, ) -> Color32
The color of the title text of the tab.
This is the fallback color used if Self::tab_title_for_tile
has no color.
Sourcefn drag_preview_stroke(&self, visuals: &Visuals) -> Stroke
fn drag_preview_stroke(&self, visuals: &Visuals) -> Stroke
When drag-and-dropping a tile, the candidate area is drawn with this stroke.
Sourcefn drag_preview_color(&self, visuals: &Visuals) -> Color32
fn drag_preview_color(&self, visuals: &Visuals) -> Color32
When drag-and-dropping a tile, the candidate area is drawn with this background color.
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?
Sourcefn on_edit(&mut self, _edit_action: EditAction)
fn on_edit(&mut self, _edit_action: EditAction)
Called if the user edits the tree somehow, e.g. changes the size of some container, clicks a tab, or drags a tile.