trading_charts/data/options/layout/
panes.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Clone)]
4pub struct LayoutPanesOptions {
5 #[serde(rename = "enableResize", default = "defaults::enable_resize")]
6 pub enable_resize: bool,
7
8 #[serde(rename = "separatorColor", default = "defaults::separator_color")]
9 pub separator_color: String,
10
11 #[serde(rename = "separatorHoverColor", default = "defaults::separator_hover_color")]
12 pub separator_hover_color: String,
13}
14
15impl LayoutPanesOptions {
16 pub fn new() -> Self {
17 Self::default()
18 }
19
20 pub fn with_enable_resize(self, enable_resize: bool) -> Self {
21 Self {
22 enable_resize,
23 ..self
24 }
25 }
26
27 pub fn with_separator_color(self, separator_color: String) -> Self {
28 Self {
29 separator_color,
30 ..self
31 }
32 }
33
34 pub fn with_separator_hover_color(self, separator_hover_color: String) -> Self {
35 Self {
36 separator_hover_color,
37 ..self
38 }
39 }
40
41 pub fn enable_resize(&self) -> bool {
42 self.enable_resize
43 }
44
45 pub fn set_enable_resize(&mut self, enable_resize: bool) {
46 self.enable_resize = enable_resize;
47 }
48
49 pub fn separator_color(&self) -> &str {
50 &self.separator_color
51 }
52
53 pub fn set_separator_color(&mut self, separator_color: String) {
54 self.separator_color = separator_color;
55 }
56
57 pub fn separator_hover_color(&self) -> &str {
58 &self.separator_hover_color
59 }
60
61 pub fn set_separator_hover_color(&mut self, separator_hover_color: String) {
62 self.separator_hover_color = separator_hover_color;
63 }
64}
65
66impl Default for LayoutPanesOptions {
67 fn default() -> Self {
68 Self {
69 enable_resize: defaults::enable_resize(),
70 separator_color: defaults::separator_color(),
71 separator_hover_color: defaults::separator_hover_color(),
72 }
73 }
74}
75
76mod defaults {
77 pub(super) fn enable_resize() -> bool {
78 true
79 }
80
81 pub(super) fn separator_color() -> String {
82 String::from("#2B2B43")
83 }
84
85 pub(super) fn separator_hover_color() -> String {
86 String::from("rgba(178, 181, 189, 0.2)")
87 }
88}