use std::{collections::HashMap, sync::Arc}; use crate::{button::Button, popup_menu::PopupMenu}; use gpui::{ AnyElement, AnyView, AppContext, EventEmitter, FocusHandle, FocusableView, Global, Hsla, IntoElement, SharedString, View, WeakView, WindowContext, }; use rust_i18n::t; use super::{DockArea, DockItemInfo, DockItemState}; pub enum PanelEvent { ZoomIn, ZoomOut, LayoutChanged, } pub struct TitleStyle { pub background: Hsla, pub foreground: Hsla, } pub trait Panel: EventEmitter + FocusableView { /// 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. fn panel_name(&self) -> &'static str; /// The title of the panel fn title(&self, _cx: &WindowContext) -> AnyElement { SharedString::from(t!("Dock.Unnamed")).into_any_element() } /// The theme of the panel title, default is `None`. fn title_style(&self, _cx: &WindowContext) -> Option { None } /// Whether the panel can be closed, default is `true`. fn closeable(&self, _cx: &WindowContext) -> bool { true } /// Return true if the panel is zoomable, default is `false`. fn zoomable(&self, _cx: &WindowContext) -> bool { true } /// Return true if the panel is collapsible, default is `false`. fn collapsible(&self, _cx: &WindowContext) -> bool { false } /// The addition popup menu of the panel, default is `None`. fn popup_menu(&self, this: PopupMenu, _cx: &WindowContext) -> 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, _cx: &WindowContext) -> Vec