use crate::model::PriceSource;
use crate::scales::PriceScaleMode;
use crate::tokens::DESIGN_TOKENS;
use egui::Color32;
#[derive(Debug, Clone, Copy, PartialEq, Default)]
pub enum BackgroundStyle {
#[default]
Solid,
VerticalGradient {
top_color: Color32,
bottom_color: Color32,
},
HorizontalGradient {
left_color: Color32,
right_color: Color32,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum SessionBreakStyle {
#[default]
Solid,
Dashed,
Dotted,
}
#[derive(Debug, Clone, PartialEq)]
pub struct SessionConfig {
pub session_start: String,
pub session_end: String,
pub timezone: String,
pub show_premarket: bool,
pub show_postmarket: bool,
pub premarket_start: Option<String>,
pub postmarket_end: Option<String>,
}
impl Default for SessionConfig {
fn default() -> Self {
Self {
session_start: "09:30".to_string(),
session_end: "16:00".to_string(),
timezone: "America/New_York".to_string(),
show_premarket: false,
show_postmarket: false,
premarket_start: Some("04:00".to_string()),
postmarket_end: Some("20:00".to_string()),
}
}
}
impl SessionConfig {
pub fn nyse() -> Self {
Self::default()
}
pub fn lse() -> Self {
Self {
session_start: "08:00".to_string(),
session_end: "16:30".to_string(),
timezone: "Europe/London".to_string(),
show_premarket: false,
show_postmarket: false,
premarket_start: None,
postmarket_end: None,
}
}
pub fn tse() -> Self {
Self {
session_start: "09:00".to_string(),
session_end: "15:00".to_string(),
timezone: "Asia/Tokyo".to_string(),
show_premarket: false,
show_postmarket: false,
premarket_start: None,
postmarket_end: None,
}
}
pub fn crypto_24_7() -> Self {
Self {
session_start: "00:00".to_string(),
session_end: "23:59".to_string(),
timezone: "UTC".to_string(),
show_premarket: false,
show_postmarket: false,
premarket_start: None,
postmarket_end: None,
}
}
pub fn forex() -> Self {
Self {
session_start: "17:00".to_string(), session_end: "17:00".to_string(), timezone: "America/New_York".to_string(),
show_premarket: false,
show_postmarket: false,
premarket_start: None,
postmarket_end: None,
}
}
}
#[derive(Debug, Clone)]
pub struct ChartConfig {
pub bullish_color: Color32,
pub bearish_color: Color32,
pub bullish_border_color: Option<Color32>,
pub bearish_border_color: Option<Color32>,
pub bullish_wick_color: Option<Color32>,
pub bearish_wick_color: Option<Color32>,
pub price_source: PriceSource,
pub background_color: Color32,
pub background_style: BackgroundStyle,
pub grid_color: Color32,
pub text_color: Color32,
pub candle_width: f32,
pub wick_width: f32,
pub candle_border_width: f32,
pub show_grid: bool,
pub show_horizontal_grid: bool,
pub show_vertical_grid: bool,
pub show_volume: bool,
pub volume_height_fraction: f32,
pub padding: f32,
pub show_time_labels: bool,
pub show_ohlc_info: bool,
pub show_right_axis: bool,
pub show_left_axis: bool,
pub right_axis_width: f32,
pub left_axis_width: f32,
pub right_axis_scale_mode: PriceScaleMode,
pub left_axis_scale_mode: PriceScaleMode,
pub show_symbol_labels: bool,
pub show_symbol_last_val: bool,
pub show_symbol_prev_close: bool,
pub show_indicator_labels: bool,
pub show_indicator_last_val: bool,
pub show_countdown: bool,
pub show_realtime_btn: bool,
pub realtime_button_pos: RealtimeButtonPos,
pub realtime_button_text: Option<String>,
pub realtime_button_size: (f32, f32),
pub realtime_button_color: Color32,
pub realtime_button_hover_color: Color32,
pub realtime_button_text_color: Color32,
pub show_session_breaks: bool,
pub session_break_color: Color32,
pub session_break_style: SessionBreakStyle,
pub session_config: Option<SessionConfig>,
pub show_watermark: bool,
pub watermark_text: Option<String>,
pub watermark_color: Color32,
pub watermark_font_size: f32,
pub watermark_pos: WatermarkPos,
pub skip_background: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum RealtimeButtonPos {
TopLeft,
#[default]
TopCenter,
TopRight,
BottomLeft,
BottomCenter,
BottomRight,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum WatermarkPos {
#[default]
Center,
TopLeft,
TopRight,
BottomLeft,
BottomRight,
}
impl Default for ChartConfig {
fn default() -> Self {
Self {
bullish_color: DESIGN_TOKENS.semantic.extended.bullish,
bearish_color: DESIGN_TOKENS.semantic.extended.bearish,
bullish_border_color: None,
bearish_border_color: None,
bullish_wick_color: None,
bearish_wick_color: None,
price_source: PriceSource::default(),
background_color: DESIGN_TOKENS.semantic.chart.bg,
background_style: BackgroundStyle::Solid,
grid_color: DESIGN_TOKENS.semantic.chart.grid_line,
text_color: DESIGN_TOKENS.semantic.extended.chart_text,
candle_width: 0.8,
wick_width: 1.0,
candle_border_width: 0.0,
show_grid: true,
show_horizontal_grid: true,
show_vertical_grid: true,
show_volume: true,
volume_height_fraction: 0.2,
padding: 40.0,
show_time_labels: true,
show_ohlc_info: true,
show_right_axis: true,
show_left_axis: false,
right_axis_width: 70.0,
left_axis_width: 70.0,
right_axis_scale_mode: PriceScaleMode::Normal,
left_axis_scale_mode: PriceScaleMode::Normal,
show_symbol_labels: true,
show_symbol_last_val: true,
show_symbol_prev_close: false,
show_indicator_labels: true,
show_indicator_last_val: true,
show_countdown: false,
show_realtime_btn: true,
realtime_button_pos: RealtimeButtonPos::TopCenter,
realtime_button_text: None,
realtime_button_size: (110.0, 28.0),
realtime_button_color: DESIGN_TOKENS.semantic.extended.chart_tooltip_bg,
realtime_button_hover_color: DESIGN_TOKENS.semantic.extended.chart_axis_bg,
realtime_button_text_color: DESIGN_TOKENS.semantic.extended.chart_text,
show_session_breaks: false,
session_break_color: DESIGN_TOKENS.semantic.chart.grid_line_major,
session_break_style: SessionBreakStyle::Dashed,
session_config: None,
show_watermark: false,
watermark_text: None,
watermark_color: DESIGN_TOKENS.semantic.chart.grid_line,
watermark_font_size: 48.0,
watermark_pos: WatermarkPos::Center,
skip_background: false,
}
}
}