|
1 | 1 | mod example_page; |
2 | 2 | mod welcome_page; |
3 | 3 |
|
| 4 | +use std::hash::Hash; |
| 5 | + |
4 | 6 | use egui::Widget; |
| 7 | +use welcome_page::welcome_page_ui; |
| 8 | + |
5 | 9 | use re_log_types::LogMsg; |
6 | | -use re_smart_channel::{ReceiveSet, SmartChannelSource}; |
| 10 | +use re_smart_channel::ReceiveSet; |
7 | 11 | use re_ui::ReUi; |
8 | | -use std::hash::Hash; |
9 | | -use welcome_page::welcome_page_ui; |
10 | 12 |
|
11 | 13 | #[derive(Debug, Default, PartialEq, Hash)] |
12 | 14 | enum WelcomeScreenPage { |
@@ -104,39 +106,6 @@ impl WelcomeScreen { |
104 | 106 | } |
105 | 107 | } |
106 | 108 |
|
107 | | -/// Full-screen UI shown while in loading state. |
108 | | -pub fn loading_ui(ui: &mut egui::Ui, rx: &ReceiveSet<LogMsg>) { |
109 | | - let status_strings = status_strings(rx); |
110 | | - if status_strings.is_empty() { |
111 | | - return; |
112 | | - } |
113 | | - |
114 | | - ui.centered_and_justified(|ui| { |
115 | | - for status_string in status_strings { |
116 | | - let style = ui.style(); |
117 | | - let mut layout_job = egui::text::LayoutJob::default(); |
118 | | - layout_job.append( |
119 | | - status_string.status, |
120 | | - 0.0, |
121 | | - egui::TextFormat::simple( |
122 | | - egui::TextStyle::Heading.resolve(style), |
123 | | - style.visuals.strong_text_color(), |
124 | | - ), |
125 | | - ); |
126 | | - layout_job.append( |
127 | | - &format!("\n\n{}", status_string.source), |
128 | | - 0.0, |
129 | | - egui::TextFormat::simple( |
130 | | - egui::TextStyle::Body.resolve(style), |
131 | | - style.visuals.text_color(), |
132 | | - ), |
133 | | - ); |
134 | | - layout_job.halign = egui::Align::Center; |
135 | | - ui.label(layout_job); |
136 | | - } |
137 | | - }); |
138 | | -} |
139 | | - |
140 | 109 | fn set_large_button_style(ui: &mut egui::Ui) { |
141 | 110 | ui.style_mut().spacing.button_padding = egui::vec2(10.0, 7.0); |
142 | 111 | let visuals = ui.visuals_mut(); |
@@ -182,64 +151,3 @@ fn large_text_button(ui: &mut egui::Ui, text: impl Into<egui::WidgetText>) -> eg |
182 | 151 | }) |
183 | 152 | .inner |
184 | 153 | } |
185 | | - |
186 | | -/// Describes the current state of the Rerun viewer. |
187 | | -struct StatusString { |
188 | | - /// General status string (e.g. "Ready", "Loading…", etc.). |
189 | | - status: &'static str, |
190 | | - |
191 | | - /// Source string (e.g. listening IP, file path, etc.). |
192 | | - source: String, |
193 | | - |
194 | | - /// Whether or not the status is valid once data loading is completed, i.e. if data may still |
195 | | - /// be received later. |
196 | | - long_term: bool, |
197 | | -} |
198 | | - |
199 | | -impl StatusString { |
200 | | - fn new(status: &'static str, source: String, long_term: bool) -> Self { |
201 | | - Self { |
202 | | - status, |
203 | | - source, |
204 | | - long_term, |
205 | | - } |
206 | | - } |
207 | | -} |
208 | | - |
209 | | -/// Returns the status strings to be displayed by the loading and welcome screen. |
210 | | -fn status_strings(rx: &ReceiveSet<LogMsg>) -> Vec<StatusString> { |
211 | | - rx.sources() |
212 | | - .into_iter() |
213 | | - .map(|s| status_string(&s)) |
214 | | - .collect() |
215 | | -} |
216 | | - |
217 | | -fn status_string(source: &SmartChannelSource) -> StatusString { |
218 | | - match source { |
219 | | - re_smart_channel::SmartChannelSource::File(path) => { |
220 | | - StatusString::new("Loading…", path.display().to_string(), false) |
221 | | - } |
222 | | - re_smart_channel::SmartChannelSource::RrdHttpStream { url } => { |
223 | | - StatusString::new("Loading…", url.clone(), false) |
224 | | - } |
225 | | - re_smart_channel::SmartChannelSource::RrdWebEventListener => { |
226 | | - StatusString::new("Ready", "Waiting for logging data…".to_owned(), true) |
227 | | - } |
228 | | - re_smart_channel::SmartChannelSource::Sdk => StatusString::new( |
229 | | - "Ready", |
230 | | - "Waiting for logging data from SDK".to_owned(), |
231 | | - true, |
232 | | - ), |
233 | | - re_smart_channel::SmartChannelSource::WsClient { ws_server_url } => { |
234 | | - // TODO(emilk): it would be even better to know whether or not we are connected, or are attempting to connect |
235 | | - StatusString::new( |
236 | | - "Ready", |
237 | | - format!("Waiting for data from {ws_server_url}"), |
238 | | - true, |
239 | | - ) |
240 | | - } |
241 | | - re_smart_channel::SmartChannelSource::TcpServer { port } => { |
242 | | - StatusString::new("Ready", format!("Listening on port {port}"), true) |
243 | | - } |
244 | | - } |
245 | | -} |
0 commit comments