re_data_ui/
component_name.rs

1use re_types_core::ComponentName;
2use re_ui::UiExt as _;
3use re_viewer_context::{UiLayout, ViewerContext};
4
5use super::DataUi;
6
7impl DataUi for ComponentName {
8    fn data_ui(
9        &self,
10        ctx: &ViewerContext<'_>,
11        ui: &mut egui::Ui,
12        ui_layout: UiLayout,
13        _query: &re_chunk_store::LatestAtQuery,
14        _db: &re_entity_db::EntityDb,
15    ) {
16        if ui_layout.is_single_line() {
17            ui.label(self.full_name());
18        } else {
19            ui.scope(|ui| {
20                ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);
21
22                if ui_layout.is_selection_panel() {
23                    ui.label(format!("Full name: {}", self.full_name()));
24                };
25
26                // Only show the first line of the docs:
27                if let Some(markdown) = ctx
28                    .reflection()
29                    .components
30                    .get(self)
31                    .map(|info| info.docstring_md)
32                {
33                    if ui_layout.is_selection_panel() {
34                        ui.markdown_ui(markdown);
35                    } else if let Some(first_line) = markdown.lines().next() {
36                        ui.markdown_ui(first_line);
37                    }
38                }
39
40                if let Some(url) = self.doc_url() {
41                    // Always open in a new tab
42                    ui.re_hyperlink("Full documentation", url, true);
43                }
44            });
45        }
46    }
47}