use super::config_struct::Config;
use crate::themes::Theme;
use crate::types::TabStyle;
impl Config {
pub fn apply_tab_style(&mut self) {
match self.tab_style {
TabStyle::Dark => {
self.tab_bar_background = crate::defaults::tab_bar_background();
self.tab_active_background = crate::defaults::tab_active_background();
self.tab_inactive_background = crate::defaults::tab_inactive_background();
self.tab_hover_background = crate::defaults::tab_hover_background();
self.tab_active_text = crate::defaults::tab_active_text();
self.tab_inactive_text = crate::defaults::tab_inactive_text();
self.tab_active_indicator = crate::defaults::tab_active_indicator();
self.tab_border_color = crate::defaults::tab_border_color();
self.tab_border_width = crate::defaults::tab_border_width();
self.tab_bar_height = crate::defaults::tab_bar_height();
}
TabStyle::Light => {
self.tab_bar_background = [235, 235, 235];
self.tab_active_background = [255, 255, 255];
self.tab_inactive_background = [225, 225, 225];
self.tab_hover_background = [240, 240, 240];
self.tab_active_text = [30, 30, 30];
self.tab_inactive_text = [100, 100, 100];
self.tab_active_indicator = [50, 120, 220];
self.tab_border_color = [200, 200, 200];
self.tab_border_width = 1.0;
self.tab_bar_height = crate::defaults::tab_bar_height();
}
TabStyle::Compact => {
self.tab_bar_background = [35, 35, 35];
self.tab_active_background = [55, 55, 55];
self.tab_inactive_background = [35, 35, 35];
self.tab_hover_background = [45, 45, 45];
self.tab_active_text = [240, 240, 240];
self.tab_inactive_text = [160, 160, 160];
self.tab_active_indicator = [80, 140, 240];
self.tab_border_color = [60, 60, 60];
self.tab_border_width = 0.5;
self.tab_bar_height = 22.0;
}
TabStyle::Minimal => {
self.tab_bar_background = [30, 30, 30];
self.tab_active_background = [30, 30, 30];
self.tab_inactive_background = [30, 30, 30];
self.tab_hover_background = [40, 40, 40];
self.tab_active_text = [255, 255, 255];
self.tab_inactive_text = [120, 120, 120];
self.tab_active_indicator = [100, 150, 255];
self.tab_border_color = [30, 30, 30]; self.tab_border_width = 0.0;
self.tab_bar_height = 26.0;
}
TabStyle::HighContrast => {
self.tab_bar_background = [0, 0, 0];
self.tab_active_background = [255, 255, 255];
self.tab_inactive_background = [30, 30, 30];
self.tab_hover_background = [60, 60, 60];
self.tab_active_text = [0, 0, 0];
self.tab_inactive_text = [255, 255, 255];
self.tab_active_indicator = [255, 255, 0];
self.tab_border_color = [255, 255, 255];
self.tab_border_width = 2.0;
self.tab_bar_height = 30.0;
}
TabStyle::Automatic => {
}
}
}
pub fn load_theme(&self) -> Theme {
Theme::by_name(&self.theme).unwrap_or_default()
}
pub fn apply_system_theme(&mut self, is_dark: bool) -> bool {
if !self.auto_dark_mode {
return false;
}
let new_theme = if is_dark {
&self.dark_theme
} else {
&self.light_theme
};
if self.theme != *new_theme {
self.theme = new_theme.clone();
true
} else {
false
}
}
pub fn apply_system_tab_style(&mut self, is_dark: bool) -> bool {
if self.tab_style != TabStyle::Automatic {
return false;
}
let target = if is_dark {
self.dark_tab_style
} else {
self.light_tab_style
};
self.tab_style = target;
self.apply_tab_style();
self.tab_style = TabStyle::Automatic;
true
}
}