Skip to main content

egui_charts/ui/top_toolbar/components/settings_menu/
config.rs

1//! Configuration types for the settings dialog and quick settings menu.
2
3use crate::model::ChartType;
4use crate::scales::PriceScaleMode;
5use egui::Color32;
6
7// ============================================================================
8// Configuration
9// ============================================================================
10
11/// Dialog layout configuration (width, height, colors)
12pub struct SettingsDialogConfig {
13    /// Width, in egui logical points.
14    pub width: f32,
15    /// Outer height override; zero sizes the dialog for the active tab.
16    pub height: f32,
17    /// Background color value; the settings dialog currently uses the supplied theme instead.
18    pub bg_color: Color32,
19    /// Tab background color value; the settings dialog currently uses the supplied theme instead.
20    pub tab_bg_color: Color32,
21    /// Tab active color value; the settings dialog currently uses the supplied theme instead.
22    pub tab_active_color: Color32,
23    /// Text color value; the settings dialog currently uses the supplied theme instead.
24    pub text_color: Color32,
25    /// Muted text color value; the settings dialog currently uses the supplied theme instead.
26    pub muted_text_color: Color32,
27}
28
29impl Default for SettingsDialogConfig {
30    fn default() -> Self {
31        // Colors are TRANSPARENT to signal that colors should be fetched from
32        // ui.style().visuals at render time for proper theme support.
33        Self {
34            width: 752.0,
35            height: 0.0,
36            bg_color: Color32::TRANSPARENT,
37            tab_bg_color: Color32::TRANSPARENT,
38            tab_active_color: Color32::TRANSPARENT,
39            text_color: Color32::TRANSPARENT,
40            muted_text_color: Color32::TRANSPARENT,
41        }
42    }
43}
44
45// ============================================================================
46// Simple Settings (backward compatibility)
47// ============================================================================
48
49/// Simplified chart settings for the quick settings popup menu
50#[derive(Debug, Clone)]
51pub struct ChartSettings {
52    /// Price scale transformation.
53    pub scale_mode: PriceScaleMode,
54    /// Chart representation selected in the menu.
55    pub chart_type: ChartType,
56    /// Whether to show horizontal grid.
57    pub show_horizontal_grid: bool,
58    /// Whether to show vertical grid.
59    pub show_vertical_grid: bool,
60    /// Whether to show right axis.
61    pub show_right_axis: bool,
62    /// Whether to show left axis.
63    pub show_left_axis: bool,
64    /// Whether the price-to-bar ratio is locked.
65    pub lock_scale: bool,
66    /// Whether autoscaling considers only the main price series.
67    pub scale_price_chart_only: bool,
68    /// Whether to show symbol labels.
69    pub show_symbol_labels: bool,
70    /// Whether to show symbol last value.
71    pub show_symbol_last_val: bool,
72    /// Whether to show symbol prev close.
73    pub show_symbol_prev_close: bool,
74    /// Whether to show indicator labels.
75    pub show_indicator_labels: bool,
76    /// Whether to show indicator last value.
77    pub show_indicator_last_val: bool,
78    /// Whether price axis labels should avoid overlapping.
79    pub no_overlapping_labels: bool,
80    /// Whether to show countdown.
81    pub show_countdown: bool,
82}
83
84impl Default for ChartSettings {
85    fn default() -> Self {
86        Self {
87            scale_mode: PriceScaleMode::Normal,
88            chart_type: ChartType::Candles,
89            show_horizontal_grid: true,
90            show_vertical_grid: true,
91            show_right_axis: true,
92            show_left_axis: false,
93            lock_scale: false,
94            scale_price_chart_only: false,
95            show_symbol_labels: true,
96            show_symbol_last_val: true,
97            show_symbol_prev_close: false,
98            show_indicator_labels: true,
99            show_indicator_last_val: true,
100            no_overlapping_labels: true,
101            show_countdown: false,
102        }
103    }
104}
105
106// ============================================================================
107// Quick Settings Menu (popup from button)
108// ============================================================================