use gpui::{ AnyElement, AnyView, AppContext, EventEmitter, FocusHandle, FocusableView, Global, Hsla, IntoElement, SharedString, View, WeakView, WindowContext, }; use std::{collections::HashMap, sync::Arc}; use super::{DockArea, PanelInfo, PanelState}; use crate::{button::Button, 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 + 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) -> SharedString; /// The title of the panel fn title(&self, _cx: &WindowContext) -> AnyElement { SharedString::from("Untitled").into_any_element() } /// 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 } /// 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