1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use re_types_core::ComponentName;
use re_ui::UiExt as _;
use re_viewer_context::{UiLayout, ViewerContext};

use super::DataUi;

impl DataUi for ComponentName {
    fn data_ui(
        &self,
        ctx: &ViewerContext<'_>,
        ui: &mut egui::Ui,
        ui_layout: UiLayout,
        _query: &re_chunk_store::LatestAtQuery,
        _db: &re_entity_db::EntityDb,
    ) {
        if ui_layout.is_single_line() {
            ui.label(self.full_name());
        } else {
            ui.scope(|ui| {
                ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

                if ui_layout.is_selection_panel() {
                    ui.label(format!("Full name: {}", self.full_name()));
                };

                // Only show the first line of the docs:
                if let Some(markdown) = ctx
                    .reflection
                    .components
                    .get(self)
                    .map(|info| info.docstring_md)
                {
                    if ui_layout.is_selection_panel() {
                        ui.markdown_ui(markdown);
                    } else if let Some(first_line) = markdown.lines().next() {
                        ui.markdown_ui(first_line);
                    }
                }

                if let Some(url) = self.doc_url() {
                    ui.re_hyperlink("Full documentation", url);
                }
            });
        }
    }
}