Skip to main content

egui_charts/ui/dialogs/series_settings/tabs/
mod.rs

1//! Series settings tabs for the Settings dialog.
2//!
3//! Tabs: Symbol, Status line, Scales and lines, Canvas
4
5mod canvas;
6mod scales;
7mod status_line;
8mod symbol;
9
10pub use canvas::CanvasTab;
11pub use scales::ScalesTab;
12pub use status_line::StatusLineTab;
13pub use symbol::SymbolTab;
14
15use crate::icons::{Icon, icons as embedded_icons};
16
17/// Tab selection for series settings
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
19pub enum SeriesSettingsTab {
20    #[default]
21    /// Symbol and series appearance.
22    Symbol,
23    /// Legend and status line visibility.
24    StatusLine,
25    /// Price scale and reference line options.
26    ScalesAndLines,
27    /// Chart background, grid and crosshair appearance.
28    Canvas,
29}
30
31impl SeriesSettingsTab {
32    /// Display label for this value.
33    pub fn label(&self) -> &'static str {
34        match self {
35            Self::Symbol => "Symbol",
36            Self::StatusLine => "Status line",
37            Self::ScalesAndLines => "Scales and lines",
38            Self::Canvas => "Canvas",
39        }
40    }
41
42    /// Icon representing this value.
43    pub fn icon(&self) -> &'static Icon {
44        match self {
45            Self::Symbol => &embedded_icons::SETTINGS_SYMBOL,
46            Self::StatusLine => &embedded_icons::SETTINGS_STATUS_LINE,
47            Self::ScalesAndLines => &embedded_icons::SETTINGS_SCALES_LINES,
48            Self::Canvas => &embedded_icons::SETTINGS_CANVAS,
49        }
50    }
51
52    /// Values in display order.
53    pub fn all() -> [Self; 4] {
54        [
55            Self::Symbol,
56            Self::StatusLine,
57            Self::ScalesAndLines,
58            Self::Canvas,
59        ]
60    }
61}