From ee67ff0d6b5b39376764d8a91a7a731ef5de854a Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 20 Feb 2024 10:47:28 +0100 Subject: [PATCH 1/5] Respect tooltip width when showing arrow data values --- crates/re_data_ui/src/component_ui_registry.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/re_data_ui/src/component_ui_registry.rs b/crates/re_data_ui/src/component_ui_registry.rs index 7c5caeb05022..ed12cd94f685 100644 --- a/crates/re_data_ui/src/component_ui_registry.rs +++ b/crates/re_data_ui/src/component_ui_registry.rs @@ -143,11 +143,13 @@ fn text_ui(string: &str, ui: &mut egui::Ui, verbosity: UiVerbosity) { } } + let galley = ui.fonts(|f| f.layout_job(layout_job)); // We control the text layout; not the label + if needs_scroll_area { egui::ScrollArea::vertical().show(ui, |ui| { - ui.label(layout_job); + ui.label(galley); }); } else { - ui.label(layout_job); + ui.label(galley); } } From aee5fa144365594232f4e6cfa7c28c20d07cf460 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 20 Feb 2024 10:47:55 +0100 Subject: [PATCH 2/5] Refactor: more consistent argument order --- crates/re_data_ui/src/component_ui_registry.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/re_data_ui/src/component_ui_registry.rs b/crates/re_data_ui/src/component_ui_registry.rs index ed12cd94f685..fc8b411dcc1b 100644 --- a/crates/re_data_ui/src/component_ui_registry.rs +++ b/crates/re_data_ui/src/component_ui_registry.rs @@ -85,14 +85,14 @@ fn arrow_ui(ui: &mut egui::Ui, verbosity: UiVerbosity, array: &dyn arrow2::array if let Some(utf8) = array.as_any().downcast_ref::>() { if utf8.len() == 1 { let string = utf8.value(0); - text_ui(string, ui, verbosity); + text_ui(ui, verbosity, string); return; } } if let Some(utf8) = array.as_any().downcast_ref::>() { if utf8.len() == 1 { let string = utf8.value(0); - text_ui(string, ui, verbosity); + text_ui(ui, verbosity, string); return; } } @@ -116,7 +116,7 @@ fn arrow_ui(ui: &mut egui::Ui, verbosity: UiVerbosity, array: &dyn arrow2::array )); } -fn text_ui(string: &str, ui: &mut egui::Ui, verbosity: UiVerbosity) { +fn text_ui(ui: &mut egui::Ui, verbosity: UiVerbosity, string: &str) { let font_id = egui::TextStyle::Monospace.resolve(ui.style()); let color = ui.visuals().text_color(); let wrap_width = ui.available_width(); From 5bed245aadaac741c1fbb2fb920b6562489b3483 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 20 Feb 2024 10:48:09 +0100 Subject: [PATCH 3/5] Don't show huge datatypes --- crates/re_data_ui/src/component_ui_registry.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/re_data_ui/src/component_ui_registry.rs b/crates/re_data_ui/src/component_ui_registry.rs index fc8b411dcc1b..f6417d16e1f5 100644 --- a/crates/re_data_ui/src/component_ui_registry.rs +++ b/crates/re_data_ui/src/component_ui_registry.rs @@ -109,11 +109,18 @@ fn arrow_ui(ui: &mut egui::Ui, verbosity: UiVerbosity, array: &dyn arrow2::array } // Fallback: - ui.label(format!( - "{} of {:?}", - re_format::format_bytes(num_bytes as _), - array.data_type() - )); + let bytes = re_format::format_bytes(num_bytes as _); + + // TODO(emilk): pretty-print data type + let data_type_formatted = format!("{:?}", array.data_type()); + + if data_type_formatted.len() < 20 { + // e.g. "4.2 KiB of Float32" + text_ui(ui, verbosity, &format!("{bytes} of {data_type_formatted}")); + } else { + // Huge datatype, probably a union horror show + ui.label(format!("{bytes} of data")); + } } fn text_ui(ui: &mut egui::Ui, verbosity: UiVerbosity, string: &str) { From b43e61681cd6f915322a5ad1e363d1dbb444b9c6 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 20 Feb 2024 10:48:19 +0100 Subject: [PATCH 4/5] Show bigger values --- crates/re_data_ui/src/component_ui_registry.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/re_data_ui/src/component_ui_registry.rs b/crates/re_data_ui/src/component_ui_registry.rs index f6417d16e1f5..cc39e4118b63 100644 --- a/crates/re_data_ui/src/component_ui_registry.rs +++ b/crates/re_data_ui/src/component_ui_registry.rs @@ -98,12 +98,12 @@ fn arrow_ui(ui: &mut egui::Ui, verbosity: UiVerbosity, array: &dyn arrow2::array } let num_bytes = array.total_size_bytes(); - if num_bytes < 256 { + if num_bytes < 3000 { // Print small items: let mut string = String::new(); let display = arrow2::array::get_display(array, "null"); if display(&mut string, 0).is_ok() { - ui.label(string); + text_ui(ui, verbosity, &string); return; } } From 74d98392d782ec79a9989d052115a439a271029a Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 20 Feb 2024 10:48:37 +0100 Subject: [PATCH 5/5] Make max tooltip width slightly wider (600 -> 720) --- crates/re_ui/src/design_tokens.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/re_ui/src/design_tokens.rs b/crates/re_ui/src/design_tokens.rs index ff185990d202..d30e7831a6eb 100644 --- a/crates/re_ui/src/design_tokens.rs +++ b/crates/re_ui/src/design_tokens.rs @@ -185,6 +185,8 @@ fn apply_design_tokens(ctx: &egui::Context) -> DesignTokens { egui_style.spacing.scroll.bar_width = 6.0; egui_style.spacing.scroll.bar_outer_margin = 2.0; + egui_style.spacing.tooltip_width = 720.0; + // don't color hyperlinks #2733 egui_style.visuals.hyperlink_color = default;