use egui::Color32;
use crate::chart::renderers::{LinearPriceMap, RenderContext, StyleColors};
use crate::model::{Bar, PriceSource};
pub struct CandleDataContext<'a> {
pub price_ctx: &'a RenderContext<'a>,
pub volume_ctx: &'a RenderContext<'a>,
pub price_scale: &'a LinearPriceMap,
pub colors: &'a StyleColors,
pub visible_data: &'a [Bar],
pub full_data: &'a [Bar],
pub start_idx: usize,
}
#[derive(Clone, Copy)]
pub struct BarDimensions {
pub bar_width: f32,
pub wick_width: f32,
}
impl BarDimensions {
pub fn new(bar_width: f32, wick_width: f32) -> Self {
Self {
bar_width,
wick_width,
}
}
}
#[derive(Clone, Copy)]
pub struct VolumeSettings {
pub show_volume: bool,
pub max_volume: f64,
}
impl VolumeSettings {
pub fn new(show_volume: bool, max_volume: f64) -> Self {
Self {
show_volume,
max_volume,
}
}
}
#[derive(Clone, Copy)]
pub struct JapaneseChartSettings {
pub renko_brick_size: f64,
pub kagi_reversal_amount: f64,
}
impl JapaneseChartSettings {
pub fn new(renko_brick_size: f64, kagi_reversal_amount: f64) -> Self {
Self {
renko_brick_size,
kagi_reversal_amount,
}
}
}
#[derive(Clone, Copy)]
pub struct TradingColors {
pub bullish: Color32,
pub bearish: Color32,
}
impl TradingColors {
pub fn new(bullish: Color32, bearish: Color32) -> Self {
Self { bullish, bearish }
}
}
pub struct CoordMapping {
pub chart_rect_min_x: f32,
}
impl CoordMapping {
pub fn new(chart_rect_min_x: f32) -> Self {
Self { chart_rect_min_x }
}
}
pub struct ChartTypeParams {
pub dimensions: BarDimensions,
pub volume: VolumeSettings,
pub japanese: JapaneseChartSettings,
pub colors: TradingColors,
pub coords: CoordMapping,
pub price_source: PriceSource,
}
impl ChartTypeParams {
pub fn new(
dimensions: BarDimensions,
volume: VolumeSettings,
japanese: JapaneseChartSettings,
colors: TradingColors,
coords: CoordMapping,
price_source: PriceSource,
) -> Self {
Self {
dimensions,
volume,
japanese,
colors,
coords,
price_source,
}
}
pub fn bar_width(&self) -> f32 {
self.dimensions.bar_width
}
pub fn wick_width(&self) -> f32 {
self.dimensions.wick_width
}
pub fn show_volume(&self) -> bool {
self.volume.show_volume
}
pub fn max_volume(&self) -> f64 {
self.volume.max_volume
}
pub fn renko_brick_size(&self) -> f64 {
self.japanese.renko_brick_size
}
pub fn kagi_reversal_amount(&self) -> f64 {
self.japanese.kagi_reversal_amount
}
pub fn bullish_color(&self) -> Color32 {
self.colors.bullish
}
pub fn bearish_color(&self) -> Color32 {
self.colors.bearish
}
pub fn chart_rect_min_x(&self) -> f32 {
self.coords.chart_rect_min_x
}
pub fn price_source(&self) -> PriceSource {
self.price_source
}
}