pub trait Panel:
EventEmitter<PanelEvent>
+ Render
+ Focusable {
Show 14 methods
// Required method
fn panel_name(&self) -> &'static str;
// Provided methods
fn tab_name(&self, cx: &App) -> Option<SharedString> { ... }
fn title(&self, window: &Window, cx: &App) -> AnyElement { ... }
fn title_style(&self, cx: &App) -> Option<TitleStyle> { ... }
fn title_suffix(
&self,
window: &mut Window,
cx: &mut App,
) -> Option<AnyElement> { ... }
fn closable(&self, cx: &App) -> bool { ... }
fn zoomable(&self, cx: &App) -> Option<PanelControl> { ... }
fn visible(&self, cx: &App) -> bool { ... }
fn set_active(&mut self, active: bool, window: &mut Window, cx: &mut App) { ... }
fn set_zoomed(&mut self, zoomed: bool, window: &mut Window, cx: &mut App) { ... }
fn popup_menu(
&self,
this: PopupMenu,
window: &Window,
cx: &App,
) -> PopupMenu { ... }
fn toolbar_buttons(
&self,
window: &mut Window,
cx: &mut App,
) -> Option<Vec<Button>> { ... }
fn dump(&self, cx: &App) -> PanelState { ... }
fn inner_padding(&self, cx: &App) -> bool { ... }
}
Expand description
The Panel trait used to define the panel.
Required Methods§
Sourcefn panel_name(&self) -> &'static str
fn panel_name(&self) -> &'static str
The name of the panel used to serialize, deserialize and identify the panel.
This is used to identify the panel when deserializing the panel. Once you have defined a panel name, this must not be changed.
Provided Methods§
Sourcefn tab_name(&self, cx: &App) -> Option<SharedString>
fn tab_name(&self, cx: &App) -> Option<SharedString>
The name of the tab of the panel, default is None
.
Used to display in the already collapsed tab panel.
Sourcefn title(&self, window: &Window, cx: &App) -> AnyElement
fn title(&self, window: &Window, cx: &App) -> AnyElement
The title of the panel
Sourcefn title_style(&self, cx: &App) -> Option<TitleStyle>
fn title_style(&self, cx: &App) -> Option<TitleStyle>
The theme of the panel title, default is None
.
Sourcefn title_suffix(&self, window: &mut Window, cx: &mut App) -> Option<AnyElement>
fn title_suffix(&self, window: &mut Window, cx: &mut App) -> Option<AnyElement>
The suffix of the panel title, default is None
.
This is used to add a suffix element to the panel title.
Sourcefn closable(&self, cx: &App) -> bool
fn closable(&self, cx: &App) -> bool
Whether the panel can be closed, default is true
.
This method called in Panel render, we should make sure it is fast.
Sourcefn zoomable(&self, cx: &App) -> Option<PanelControl>
fn zoomable(&self, cx: &App) -> Option<PanelControl>
Return PanelControl
if the panel is zoomable, default is PanelControl::Menu
.
This method called in Panel render, we should make sure it is fast.
Sourcefn visible(&self, cx: &App) -> bool
fn visible(&self, cx: &App) -> bool
Return false to hide panel, true to show panel, default is true
.
This method called in Panel render, we should make sure it is fast.
Sourcefn set_active(&mut self, active: bool, window: &mut Window, cx: &mut App)
fn set_active(&mut self, active: bool, window: &mut Window, cx: &mut App)
Set active state of the panel.
This method will be called when the panel is active or inactive.
The last_active_panel and current_active_panel will be touched when the panel is active.
Sourcefn set_zoomed(&mut self, zoomed: bool, window: &mut Window, cx: &mut App)
fn set_zoomed(&mut self, zoomed: bool, window: &mut Window, cx: &mut App)
Set zoomed state of the panel.
This method will be called when the panel is zoomed or unzoomed.
Only current Panel will touch this method.
The addition popup menu of the panel, default is None
.
The addition toolbar buttons of the panel used to show in the right of the title bar, default is None
.
Sourcefn dump(&self, cx: &App) -> PanelState
fn dump(&self, cx: &App) -> PanelState
Dump the panel, used to serialize the panel.
Sourcefn inner_padding(&self, cx: &App) -> bool
fn inner_padding(&self, cx: &App) -> bool
Whether the panel has inner padding when the panel is in the tabs layout, default is true
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.