flowsurface_data/config/
state.rs1use super::ScaleFactor;
2use super::sidebar::Sidebar;
3use super::timezone::UserTimezone;
4use crate::config::network::Network;
5use crate::layout::WindowSpec;
6use crate::{AudioStream, Layout, Theme};
7
8use serde::{Deserialize, Serialize};
9
10#[derive(Clone, Serialize, Deserialize, Default)]
11pub struct Layouts {
12 pub layouts: Vec<Layout>,
13 pub active_layout: Option<String>,
14 #[serde(default)]
15 pub chart_presets: Vec<crate::chart::kline::ChartPreset>,
16}
17
18#[derive(Default, Clone, Deserialize, Serialize)]
19#[serde(default)]
20pub struct State {
21 pub layout_manager: Layouts,
22 pub selected_theme: Theme,
23 pub custom_theme: Option<Theme>,
24 pub main_window: Option<WindowSpec>,
25 pub timezone: UserTimezone,
26 pub sidebar: Sidebar,
27 pub scale_factor: ScaleFactor,
28 pub audio_cfg: AudioStream,
29 pub network: Network,
30 pub size_in_quote_ccy: exchange::SizeUnit,
31 pub cache_market_metadata: bool,
32 #[serde(default = "default_antialiasing")]
33 pub antialiasing: bool,
34}
35
36impl State {
37 pub fn from_parts(
38 layout_manager: Layouts,
39 selected_theme: Theme,
40 custom_theme: Option<Theme>,
41 main_window: Option<WindowSpec>,
42 timezone: UserTimezone,
43 sidebar: Sidebar,
44 scale_factor: ScaleFactor,
45 audio_cfg: AudioStream,
46 network: Network,
47 volume_size_unit: exchange::SizeUnit,
48 cache_market_metadata: bool,
49 antialiasing: bool,
50 ) -> Self {
51 State {
52 layout_manager,
53 selected_theme: Theme(selected_theme.0),
54 custom_theme: custom_theme.map(|t| Theme(t.0)),
55 main_window,
56 timezone,
57 sidebar,
58 scale_factor,
59 audio_cfg,
60 network,
61 size_in_quote_ccy: volume_size_unit,
62 cache_market_metadata,
63 antialiasing,
64 }
65 }
66}
67
68const fn default_antialiasing() -> bool {
69 true
70}