Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nicer ready text #1078

Merged
merged 1 commit into from
Feb 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,26 +469,47 @@ impl eframe::App for App {
if let (true, Some(rx)) = (log_db.is_empty(), &self.rx) {
egui::CentralPanel::default().show(egui_ctx, |ui| {
ui.centered_and_justified(|ui| {
fn ready_and_waiting(txt: &str) -> String {
format!("Ready!\n\n{txt}")
fn ready_and_waiting(ui: &mut egui::Ui, txt: &str) {
let style = ui.style();
let mut layout_job = egui::text::LayoutJob::default();
layout_job.append(
"Ready",
0.0,
egui::TextFormat::simple(
egui::TextStyle::Heading.resolve(style),
style.visuals.strong_text_color(),
),
);
layout_job.append(
&format!("\n\n{txt}"),
0.0,
egui::TextFormat::simple(
egui::TextStyle::Body.resolve(style),
style.visuals.text_color(),
),
);
layout_job.halign = egui::Align::Center;
ui.label(layout_job);
}

let text = match rx.source() {
match rx.source() {
re_smart_channel::Source::File { path } => {
format!("Loading {}…", path.display())
ui.strong(format!("Loading {}…", path.display()));
}
re_smart_channel::Source::Sdk => {
ready_and_waiting("Waiting for logging data from SDK")
ready_and_waiting(ui, "Waiting for logging data from SDK");
}
re_smart_channel::Source::WsClient { ws_server_url } => {
// TODO(emilk): it would be even better to know wether or not we are connected, or are attempting to connect
ready_and_waiting(&format!("Waiting for data from {ws_server_url}"))
ready_and_waiting(
ui,
&format!("Waiting for data from {ws_server_url}"),
);
}
re_smart_channel::Source::TcpServer { port } => {
ready_and_waiting(&format!("Listening on port {port}"))
ready_and_waiting(ui, &format!("Listening on port {port}"));
}
};
ui.strong(text);
});
});
} else {
Expand Down