use crate::{BlockStyle, TextStyle};
use super::Theme;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ComponentRole {
Body,
Muted,
Accent,
Success,
Error,
PromptQuestion,
PromptAnswer,
PromptPlaceholder,
PromptCursor,
PromptOption,
PromptOptionSelected,
PromptButton,
PromptButtonFocused,
PromptHelp,
PromptError,
}
impl ComponentRole {
pub(super) const fn index(self) -> usize {
match self {
Self::Body => 0,
Self::Muted => 1,
Self::Accent => 2,
Self::Success => 3,
Self::Error => 4,
Self::PromptQuestion => 5,
Self::PromptAnswer => 6,
Self::PromptPlaceholder => 7,
Self::PromptCursor => 8,
Self::PromptOption => 9,
Self::PromptOptionSelected => 10,
Self::PromptButton => 11,
Self::PromptButtonFocused => 12,
Self::PromptHelp => 13,
Self::PromptError => 14,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PanelRole {
Panel,
PanelFocused,
}
impl BlockThemeRole for PanelRole {
fn resolve(self, theme: &Theme) -> BlockStyle {
match self {
Self::Panel => theme.components().get_panel().clone(),
Self::PanelFocused => theme.components().get_panel_focused().clone(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ListRole {
Item,
Enumerator,
}
impl TextThemeRole for ListRole {
fn resolve(self, theme: &Theme) -> TextStyle {
theme.components().get_list_style(self).clone()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TreeRole {
Root,
Item,
Connector,
}
impl TextThemeRole for TreeRole {
fn resolve(self, theme: &Theme) -> TextStyle {
theme.components().get_tree_style(self).clone()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ScrollbarRole {
Thumb,
Track,
Begin,
End,
}
impl ScrollbarRole {
pub(crate) const fn index(self) -> usize {
match self {
Self::Thumb => 0,
Self::Track => 1,
Self::Begin => 2,
Self::End => 3,
}
}
}
impl TextThemeRole for ScrollbarRole {
fn resolve(self, theme: &Theme) -> TextStyle {
theme.components().get_scrollbar_style(self).clone()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TableRole {
Header,
Cell,
}
impl BlockThemeRole for TableRole {
fn resolve(self, theme: &Theme) -> BlockStyle {
theme.components().get_table_style(self).clone()
}
}
pub trait TextThemeRole: Copy {
fn resolve(self, theme: &Theme) -> TextStyle;
}
pub trait BlockThemeRole: Copy {
fn resolve(self, theme: &Theme) -> BlockStyle;
}
impl TextThemeRole for ComponentRole {
fn resolve(self, theme: &Theme) -> TextStyle {
theme.components().get_text_style(self).clone()
}
}