1use ecolor::Color32;
4use egui::Modifiers;
5
6use crate::{
7 SystemState,
8 clock_highlighting::ClockHighlightType,
9 config::{ArrowKeyBindings, AutoLoad, PrimaryMouseDrag, TransitionValue},
10 displayed_item::DisplayedItem,
11 hierarchy::{HierarchyStyle, ParameterDisplayLocation},
12};
13
14impl SystemState {
15 #[inline]
16 pub fn get_item_text_color(&self, item: &DisplayedItem) -> Color32 {
17 item.color()
18 .and_then(|color| self.user.config.theme.get_color(color))
19 .unwrap_or(self.user.config.theme.primary_ui_color.foreground)
20 }
21
22 #[inline]
23 pub fn show_statusbar(&self) -> bool {
24 self.user.show_statusbar.unwrap_or_else(|| {
25 (self.user.waves.is_some() || self.progress_tracker.is_some())
26 && self.user.config.layout.show_statusbar()
27 })
28 }
29
30 #[inline]
31 pub fn show_toolbar(&self) -> bool {
32 self.user
33 .show_toolbar
34 .unwrap_or_else(|| self.user.config.layout.show_toolbar())
35 }
36
37 #[inline]
38 pub fn show_overview(&self) -> bool {
39 self.user
40 .show_overview
41 .unwrap_or_else(|| self.user.config.layout.show_overview())
42 }
43
44 #[inline]
45 pub fn show_hierarchy(&self) -> bool {
46 self.user
47 .show_hierarchy
48 .unwrap_or_else(|| self.user.config.layout.show_hierarchy())
49 }
50
51 #[inline]
52 pub fn show_tooltip(&self) -> bool {
53 self.user
54 .show_tooltip
55 .unwrap_or_else(|| self.user.config.layout.show_tooltip())
56 }
57
58 #[inline]
59 pub fn show_scope_tooltip(&self) -> bool {
60 self.user
61 .show_scope_tooltip
62 .unwrap_or_else(|| self.user.config.layout.show_scope_tooltip())
63 }
64
65 #[inline]
66 pub fn show_ticks(&self) -> bool {
67 self.user
68 .show_ticks
69 .unwrap_or_else(|| self.user.config.layout.show_ticks())
70 }
71
72 #[inline]
73 pub fn show_menu(&self) -> bool {
74 self.user
75 .show_menu
76 .unwrap_or_else(|| self.user.config.layout.show_menu())
77 }
78
79 #[inline]
80 pub fn show_variable_indices(&self) -> bool {
81 self.user
82 .show_variable_indices
83 .unwrap_or_else(|| self.user.config.layout.show_variable_indices())
84 }
85
86 #[inline]
87 pub fn show_variable_direction(&self) -> bool {
88 self.user
89 .show_variable_direction
90 .unwrap_or_else(|| self.user.config.layout.show_variable_direction())
91 }
92
93 #[inline]
94 pub fn ui_zoom_factor(&self) -> f32 {
95 self.user
96 .ui_zoom_factor
97 .unwrap_or_else(|| self.user.config.layout.default_zoom_factor())
98 }
99
100 #[inline]
101 pub fn show_empty_scopes(&self) -> bool {
102 self.user
103 .show_empty_scopes
104 .unwrap_or_else(|| self.user.config.layout.show_empty_scopes())
105 }
106
107 #[inline]
108 pub fn show_hierarchy_icons(&self) -> bool {
109 self.user
110 .show_hierarchy_icons
111 .unwrap_or_else(|| self.user.config.layout.show_hierarchy_icons())
112 }
113
114 #[inline]
115 pub fn show_default_timeline(&self) -> bool {
116 self.user
117 .show_default_timeline
118 .unwrap_or_else(|| self.user.config.layout.show_default_timeline())
119 }
120
121 #[inline]
122 pub fn highlight_focused(&self) -> bool {
123 self.user
124 .highlight_focused
125 .unwrap_or_else(|| self.user.config.layout.highlight_focused())
126 }
127
128 #[inline]
129 pub fn fill_high_values(&self) -> bool {
130 self.user
131 .fill_high_values
132 .unwrap_or_else(|| self.user.config.layout.fill_high_values())
133 }
134
135 #[inline]
136 pub fn animation_enabled(&self) -> bool {
137 self.user
138 .animation_enabled
139 .unwrap_or_else(|| self.user.config.animation_enabled())
140 }
141
142 #[inline]
143 pub fn primary_button_drag_behavior(&self) -> PrimaryMouseDrag {
144 self.user
145 .primary_button_drag_behavior
146 .unwrap_or_else(|| self.user.config.behavior.primary_button_drag_behavior())
147 }
148
149 #[inline]
150 pub fn do_measure(&self, modifiers: &Modifiers) -> bool {
153 let drag_behavior = self.primary_button_drag_behavior();
154 (drag_behavior == PrimaryMouseDrag::Measure && !modifiers.shift)
155 || (drag_behavior == PrimaryMouseDrag::Cursor && modifiers.shift)
156 }
157
158 #[inline]
159 pub fn arrow_key_bindings(&self) -> ArrowKeyBindings {
160 self.user
161 .arrow_key_bindings
162 .unwrap_or_else(|| self.user.config.behavior.arrow_key_bindings())
163 }
164
165 #[inline]
166 pub fn clock_highlight_type(&self) -> ClockHighlightType {
167 self.user
168 .clock_highlight_type
169 .unwrap_or_else(|| self.user.config.default_clock_highlight_type())
170 }
171
172 #[inline]
173 pub fn hierarchy_style(&self) -> HierarchyStyle {
174 self.user
175 .hierarchy_style
176 .unwrap_or_else(|| self.user.config.layout.hierarchy_style())
177 }
178
179 #[inline]
180 pub fn autoreload_files(&self) -> AutoLoad {
181 self.user
182 .autoreload_files
183 .unwrap_or_else(|| self.user.config.autoreload_files())
184 }
185
186 #[inline]
187 pub fn autoload_sibling_state_files(&self) -> AutoLoad {
188 self.user
189 .autoload_sibling_state_files
190 .unwrap_or_else(|| self.user.config.autoload_sibling_state_files())
191 }
192
193 #[inline]
194 pub fn parameter_display_location(&self) -> ParameterDisplayLocation {
195 self.user
196 .parameter_display_location
197 .unwrap_or_else(|| self.user.config.layout.parameter_display_location())
198 }
199
200 #[inline]
201 pub fn use_dinotrace_style(&self) -> bool {
202 self.user
203 .use_dinotrace_style
204 .unwrap_or_else(|| self.user.config.layout.use_dinotrace_style())
205 }
206
207 #[inline]
208 pub fn transition_value(&self) -> TransitionValue {
209 self.user
210 .transition_value
211 .unwrap_or_else(|| self.user.config.layout.transition_value())
212 }
213
214 #[inline]
215 pub fn align_names_right(&self) -> bool {
216 self.user
217 .align_names_right
218 .unwrap_or_else(|| self.user.config.layout.align_names_right())
219 }
220}