egui_charts/ui/dialogs/indicator_dialog/
config.rs1use crate::theme::Theme;
6use egui::Color32;
7
8#[derive(Debug, Clone)]
13pub struct IndicatorDialogConfig {
14 pub width: f32,
16 pub height: f32,
18 pub text_color: Color32,
20 pub muted_color: Color32,
22 pub hover_color: Color32,
24 pub favorite_color: Color32,
26}
27
28impl IndicatorDialogConfig {
29 pub fn from_theme(theme: &Theme) -> Self {
34 let ui = &theme.ui;
35 Self {
36 text_color: ui.text,
37 muted_color: ui.text_secondary,
38 hover_color: ui.btn_bg_hover,
39 favorite_color: ui.warning,
40 ..Self::default()
41 }
42 }
43
44 pub(super) fn resolved(&self, theme: &Theme) -> Self {
46 let themed = Self::from_theme(theme);
47 let or = |color: Color32, theme: Color32| {
48 if color == Color32::TRANSPARENT {
49 theme
50 } else {
51 color
52 }
53 };
54 Self {
55 text_color: or(self.text_color, themed.text_color),
56 muted_color: or(self.muted_color, themed.muted_color),
57 hover_color: or(self.hover_color, themed.hover_color),
58 favorite_color: or(self.favorite_color, themed.favorite_color),
59 ..self.clone()
60 }
61 }
62}
63
64impl Default for IndicatorDialogConfig {
65 fn default() -> Self {
66 Self {
67 width: 840.0,
68 height: 640.0,
69 text_color: Color32::TRANSPARENT,
70 muted_color: Color32::TRANSPARENT,
71 hover_color: Color32::TRANSPARENT,
72 favorite_color: Color32::TRANSPARENT,
73 }
74 }
75}