[go: up one dir, main page]

Trait Behavior

Source
pub trait Behavior<Pane> {
Show 32 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 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§

Source

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.

Source

fn tab_title_for_pane(&mut self, pane: &Pane) -> WidgetText

The title of a pane tab.

Provided Methods§

Source

fn is_tab_closable(&self, _tiles: &Tiles<Pane>, _tile_id: TileId) -> bool

Should the tab have a close-button?

Source

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).

Source

fn close_button_outer_size(&self) -> f32

The size of the close button in the tab.

Source

fn close_button_inner_margin(&self) -> f32

How much smaller the visual part of the close-button will be compared to Self::close_button_outer_size.

Source

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.

Source

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).

Source

fn drag_ui(&mut self, tiles: &Tiles<Pane>, ui: &mut Ui, tile_id: TileId)

Show the ui for the tab being dragged.

Source

fn on_tab_button( &mut self, _tiles: &Tiles<Pane>, _tile_id: TileId, button_response: Response, ) -> Response

Called by the default implementation of Self::tab_ui for each added button

Source

fn retain_pane(&mut self, _pane: &Pane) -> bool

Return false if a given pane should be removed from its parent.

Source

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.

Source

fn tab_bar_height(&self, _style: &Style) -> f32

The height of the bar holding tab titles.

Source

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.

Source

fn min_size(&self) -> f32

No child should shrink below this width nor height.

Source

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?

Source

fn dragged_overlay_color(&self, visuals: &Visuals) -> Color32

Cover the tile that is being dragged with this color.

Source

fn simplification_options(&self) -> SimplificationOptions

What are the rules for simplifying the tree?

Source

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.

Source

fn resize_stroke(&self, style: &Style, resize_state: ResizeState) -> Stroke

The stroke used for the lines in horizontal, vertical, and grid layouts.

Source

fn tab_title_spacing(&self, _visuals: &Visuals) -> f32

Extra spacing to left and right of tab titles.

Source

fn tab_bar_color(&self, visuals: &Visuals) -> Color32

The background color of the tab bar.

Source

fn tab_bg_color( &self, visuals: &Visuals, _tiles: &Tiles<Pane>, _tile_id: TileId, state: &TabState, ) -> Color32

The background color of a tab.

Source

fn tab_outline_stroke( &self, visuals: &Visuals, _tiles: &Tiles<Pane>, _tile_id: TileId, state: &TabState, ) -> Stroke

Stroke of the outline around a tab title.

Source

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.

Source

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.

Source

fn drag_preview_stroke(&self, visuals: &Visuals) -> Stroke

When drag-and-dropping a tile, the candidate area is drawn with this stroke.

Source

fn drag_preview_color(&self, visuals: &Visuals) -> Color32

When drag-and-dropping a tile, the candidate area is drawn with this background color.

Source

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?

Source

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.

Source

fn ideal_tile_aspect_ratio(&self) -> f32

When using crate::GridLayout::Auto, what is the ideal aspect ratio of a tile?

Source

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.

Implementors§