use egui::{Color32, Context, Ui};
use crate::theme::context::{ThemeContextExt, ThemeData, ThemeUiExt};
#[derive(Clone, Debug)]
pub struct DesignTokens {
theme_data: ThemeData,
}
impl DesignTokens {
pub fn from_context(ctx: &Context) -> Self {
Self {
theme_data: ctx.theme_data(),
}
}
pub fn panel_fill(&self) -> Color32 {
self.theme_data.ui_panel_bg
}
pub fn panel_fill_secondary(&self) -> Color32 {
self.theme_data.ui_panel_bg_secondary
}
pub fn text_primary(&self) -> Color32 {
self.theme_data.ui_text
}
pub fn text_secondary(&self) -> Color32 {
self.theme_data.ui_text_secondary
}
pub fn text_muted(&self) -> Color32 {
self.theme_data.ui_text_muted
}
pub fn border(&self) -> Color32 {
self.theme_data.ui_border
}
pub fn border_subtle(&self) -> Color32 {
self.theme_data.ui_border_subtle
}
pub fn accent(&self) -> Color32 {
self.theme_data.ui_accent
}
pub fn icon(&self) -> Color32 {
self.theme_data.ui_icon
}
pub fn icon_hover(&self) -> Color32 {
self.theme_data.ui_icon_hover
}
pub fn icon_active(&self) -> Color32 {
self.theme_data.ui_icon_active
}
pub fn chart_bg(&self) -> Color32 {
self.theme_data.chart_bg
}
pub fn chart_axis_bg(&self) -> Color32 {
self.theme_data.chart_bg_axis
}
pub fn chart_grid(&self) -> Color32 {
self.theme_data.chart_grid
}
pub fn chart_text(&self) -> Color32 {
self.theme_data.chart_text
}
pub fn crosshair(&self) -> Color32 {
self.theme_data.chart_crosshair
}
pub fn bullish(&self) -> Color32 {
self.theme_data.bullish
}
pub fn bearish(&self) -> Color32 {
self.theme_data.bearish
}
pub fn volume_bullish(&self) -> Color32 {
self.theme_data.volume_bullish
}
pub fn volume_bearish(&self) -> Color32 {
self.theme_data.volume_bearish
}
pub fn warning(&self) -> Color32 {
self.theme_data.warning
}
pub fn success(&self) -> Color32 {
self.theme_data.success
}
pub fn hover_bg(&self) -> Color32 {
self.theme_data.ui_button_bg_hover
}
pub fn active_bg(&self) -> Color32 {
self.theme_data.ui_button_bg_active
}
pub fn poc_highlight(&self) -> Color32 {
self.theme_data.footprint_poc
}
pub fn value_area_fill(&self) -> Color32 {
self.theme_data.footprint_value_area
}
pub fn imbalance_buy(&self) -> Color32 {
self.theme_data.footprint_imbalance_buy
}
pub fn imbalance_sell(&self) -> Color32 {
self.theme_data.footprint_imbalance_sell
}
pub fn is_dark_ui(&self) -> bool {
self.theme_data.is_dark_ui
}
pub fn is_dark_chart(&self) -> bool {
self.theme_data.is_dark_chart
}
}
pub trait HasDesignTokens {
fn design_tokens(&self) -> DesignTokens;
fn panel_fill(&self) -> Color32 {
self.design_tokens().panel_fill()
}
fn text_color(&self) -> Color32 {
self.design_tokens().text_primary()
}
fn text_secondary(&self) -> Color32 {
self.design_tokens().text_secondary()
}
fn text_muted(&self) -> Color32 {
self.design_tokens().text_muted()
}
fn accent_color(&self) -> Color32 {
self.design_tokens().accent()
}
fn border_color(&self) -> Color32 {
self.design_tokens().border()
}
fn bullish_color(&self) -> Color32 {
self.design_tokens().bullish()
}
fn bearish_color(&self) -> Color32 {
self.design_tokens().bearish()
}
fn chart_bg(&self) -> Color32 {
self.design_tokens().chart_bg()
}
fn warning_color(&self) -> Color32 {
self.design_tokens().warning()
}
fn success_color(&self) -> Color32 {
self.design_tokens().success()
}
fn chart_grid(&self) -> Color32 {
self.design_tokens().chart_grid()
}
fn icon_color(&self) -> Color32 {
self.design_tokens().icon()
}
fn icon_hover(&self) -> Color32 {
self.design_tokens().icon_hover()
}
fn icon_active(&self) -> Color32 {
self.design_tokens().icon_active()
}
fn hover_bg(&self) -> Color32 {
self.design_tokens().hover_bg()
}
fn active_bg(&self) -> Color32 {
self.design_tokens().active_bg()
}
fn poc_highlight(&self) -> Color32 {
self.design_tokens().poc_highlight()
}
fn value_area_fill(&self) -> Color32 {
self.design_tokens().value_area_fill()
}
fn imbalance_buy(&self) -> Color32 {
self.design_tokens().imbalance_buy()
}
fn imbalance_sell(&self) -> Color32 {
self.design_tokens().imbalance_sell()
}
}
impl HasDesignTokens for Context {
fn design_tokens(&self) -> DesignTokens {
DesignTokens::from_context(self)
}
}
impl HasDesignTokens for Ui {
fn design_tokens(&self) -> DesignTokens {
DesignTokens::from_context(self.ctx())
}
fn panel_fill(&self) -> Color32 {
ThemeUiExt::theme_panel_bg(self)
}
fn bullish_color(&self) -> Color32 {
ThemeUiExt::theme_bullish(self)
}
fn bearish_color(&self) -> Color32 {
ThemeUiExt::theme_bearish(self)
}
fn chart_bg(&self) -> Color32 {
ThemeUiExt::theme_chart_bg(self)
}
fn warning_color(&self) -> Color32 {
ThemeUiExt::theme_warning(self)
}
fn success_color(&self) -> Color32 {
ThemeUiExt::theme_success(self)
}
fn hover_bg(&self) -> Color32 {
ThemeUiExt::theme_hover_bg(self)
}
fn active_bg(&self) -> Color32 {
ThemeUiExt::theme_active_bg(self)
}
fn poc_highlight(&self) -> Color32 {
ThemeUiExt::theme_poc_highlight(self)
}
fn value_area_fill(&self) -> Color32 {
ThemeUiExt::theme_value_area_fill(self)
}
fn imbalance_buy(&self) -> Color32 {
ThemeUiExt::theme_imbalance_buy(self)
}
fn imbalance_sell(&self) -> Color32 {
ThemeUiExt::theme_imbalance_sell(self)
}
}