use gpui::{ AnyElement, AnyView, App, Element, Entity, EventEmitter, FocusHandle, Focusable, Hsla, Render, SharedString, Window, }; use crate::button::Button; use crate::popup_menu::PopupMenu; pub enum PanelEvent { ZoomIn, ZoomOut, LayoutChanged, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum PanelStyle { /// Display the TabBar when there are multiple tabs, otherwise display the simple title. Default, /// Always display the tab bar. TabBar, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct TitleStyle { pub background: Hsla, pub foreground: Hsla, } pub trait Panel: EventEmitter + Render + Focusable { /// 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 id, this must not be changed. fn panel_id(&self) -> SharedString; /// The title of the panel fn title(&self, _cx: &App) -> AnyElement { SharedString::from("Unnamed").into_any() } /// Whether the panel can be closed, default is `true`. fn closable(&self, _cx: &App) -> bool { true } /// Return true if the panel is zoomable, default is `false`. fn zoomable(&self, _cx: &App) -> bool { true } /// 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. fn visible(&self, _cx: &App) -> bool { true } /// 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. fn set_active(&self, _active: bool, _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. fn set_zoomed(&self, _zoomed: bool, _cx: &mut App) {} /// The addition popup menu of the panel, default is `None`. fn popup_menu(&self, this: PopupMenu, _cx: &App) -> PopupMenu { this } /// The addition toolbar buttons of the panel used to show in the right of the title bar, default is `None`. fn toolbar_buttons(&self, _window: &Window, _cx: &App) -> Vec