#[derive(Clone, Debug)]
pub struct BorderConfig {
pub top: Option<BorderStroke>,
pub right: Option<BorderStroke>,
pub bottom: Option<BorderStroke>,
pub left: Option<BorderStroke>,
}
#[derive(Clone, Copy, Debug)]
pub struct BorderStroke {
pub width: f64,
pub opacity: f64,
}
impl Default for BorderStroke {
fn default() -> Self {
Self { width: 1.0, opacity: 1.0 }
}
}
impl BorderConfig {
pub fn none() -> Self {
Self { top: None, right: None, bottom: None, left: None }
}
pub fn all() -> Self {
let s = Some(BorderStroke::default());
Self { top: s, right: s, bottom: s, left: s }
}
}
#[derive(Clone, Copy, Debug)]
pub struct DividerConfig {
pub visible: bool,
pub width: f64,
pub opacity: f64,
pub length_frac: f64,
}
impl Default for DividerConfig {
fn default() -> Self {
Self { visible: true, width: 1.0, opacity: 1.0, length_frac: 1.0 }
}
}
#[derive(Debug, Clone)]
pub enum BackgroundFill {
Solid,
Glass {
blur_radius: f64,
},
}
pub trait SidebarStyle {
fn header_height(&self) -> f64;
fn tab_strip_height(&self) -> f64;
fn padding(&self) -> f64;
fn resize_zone_width(&self) -> f64;
fn border_width(&self) -> f64;
fn min_width(&self) -> f64;
fn max_width(&self) -> f64;
fn default_width(&self) -> f64;
fn scrollbar_width(&self) -> f64;
fn background_fill(&self) -> BackgroundFill {
BackgroundFill::Solid
}
fn show_header_divider(&self) -> bool {
true
}
fn borders(&self) -> BorderConfig {
BorderConfig {
top: None,
right: None,
bottom: None,
left: None,
} }
fn header_divider(&self) -> DividerConfig {
DividerConfig::default()
}
fn footer_divider(&self) -> DividerConfig {
DividerConfig { visible: false, ..DividerConfig::default() }
}
}
#[derive(Default)]
pub struct DefaultSidebarStyle;
impl SidebarStyle for DefaultSidebarStyle {
fn header_height(&self) -> f64 { 40.0 }
fn tab_strip_height(&self) -> f64 { 32.0 }
fn padding(&self) -> f64 { 12.0 }
fn resize_zone_width(&self) -> f64 { 8.0 }
fn border_width(&self) -> f64 { 1.0 }
fn min_width(&self) -> f64 { 280.0 }
fn max_width(&self) -> f64 { 4000.0 }
fn default_width(&self) -> f64 { 340.0 }
fn scrollbar_width(&self) -> f64 { 8.0 }
}
pub type RightSidebarStyle = DefaultSidebarStyle;
pub type LeftSidebarStyle = DefaultSidebarStyle;
#[derive(Default)]
pub struct WithTypeSelectorStyle;
impl SidebarStyle for WithTypeSelectorStyle {
fn header_height(&self) -> f64 { 40.0 }
fn tab_strip_height(&self) -> f64 { 32.0 }
fn padding(&self) -> f64 { 12.0 }
fn resize_zone_width(&self) -> f64 { 8.0 }
fn border_width(&self) -> f64 { 1.0 }
fn min_width(&self) -> f64 { 280.0 }
fn max_width(&self) -> f64 { 4000.0 }
fn default_width(&self) -> f64 { 340.0 }
fn scrollbar_width(&self) -> f64 { 8.0 }
}
#[derive(Default)]
pub struct EmbeddedSidebarStyle;
impl SidebarStyle for EmbeddedSidebarStyle {
fn header_height(&self) -> f64 { 40.0 }
fn tab_strip_height(&self) -> f64 { 32.0 }
fn padding(&self) -> f64 { 12.0 }
fn resize_zone_width(&self) -> f64 { 0.0 }
fn border_width(&self) -> f64 { 0.0 }
fn min_width(&self) -> f64 { 280.0 }
fn max_width(&self) -> f64 { 4000.0 }
fn default_width(&self) -> f64 { 280.0 }
fn scrollbar_width(&self) -> f64 { 8.0 }
}