use crate::workspace::{DockArea, Panel};
pub struct SidebarPanel {
id: String,
title: String,
}
impl SidebarPanel {
pub fn new(id: impl Into<String>, title: impl Into<String>) -> Self {
Self {
id: id.into(),
title: title.into(),
}
}
}
impl Panel for SidebarPanel {
fn id(&self) -> &str {
&self.id
}
fn title(&self) -> &str {
&self.title
}
fn dock_area(&self) -> DockArea {
DockArea::Left
}
}
pub struct InspectorPanel {
id: String,
title: String,
}
impl InspectorPanel {
pub fn new(id: impl Into<String>, title: impl Into<String>) -> Self {
Self {
id: id.into(),
title: title.into(),
}
}
}
impl Panel for InspectorPanel {
fn id(&self) -> &str {
&self.id
}
fn title(&self) -> &str {
&self.title
}
fn dock_area(&self) -> DockArea {
DockArea::Right
}
}
pub struct BottomPanel {
id: String,
title: String,
}
impl BottomPanel {
pub fn new(id: impl Into<String>, title: impl Into<String>) -> Self {
Self {
id: id.into(),
title: title.into(),
}
}
}
impl Panel for BottomPanel {
fn id(&self) -> &str {
&self.id
}
fn title(&self) -> &str {
&self.title
}
fn dock_area(&self) -> DockArea {
DockArea::Bottom
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_sidebar_panel() {
let panel = SidebarPanel::new("sidebar", "Sidebar");
assert_eq!(panel.id(), "sidebar");
assert_eq!(panel.title(), "Sidebar");
assert!(matches!(panel.dock_area(), DockArea::Left));
}
#[test]
fn test_inspector_panel() {
let panel = InspectorPanel::new("inspector", "Inspector");
assert_eq!(panel.id(), "inspector");
assert_eq!(panel.title(), "Inspector");
assert!(matches!(panel.dock_area(), DockArea::Right));
}
#[test]
fn test_bottom_panel() {
let panel = BottomPanel::new("bottom", "Bottom");
assert_eq!(panel.id(), "bottom");
assert_eq!(panel.title(), "Bottom");
assert!(matches!(panel.dock_area(), DockArea::Bottom));
}
}