re_data_ui/
app_id.rs

1use itertools::Itertools as _;
2
3use re_entity_db::EntityDb;
4use re_log_types::ApplicationId;
5use re_types::{archetypes::RecordingInfo, components::Timestamp};
6use re_viewer_context::{UiLayout, ViewerContext};
7
8use crate::item_ui::entity_db_button_ui;
9
10impl crate::DataUi for ApplicationId {
11    fn data_ui(
12        &self,
13        ctx: &ViewerContext<'_>,
14        ui: &mut egui::Ui,
15        ui_layout: UiLayout,
16        _query: &re_chunk_store::LatestAtQuery,
17        _db: &re_entity_db::EntityDb,
18    ) {
19        egui::Grid::new("application_id")
20            .num_columns(2)
21            .show(ui, |ui| {
22                ui.label("Application ID");
23
24                let mut label = self.to_string();
25                if self == ctx.store_context.application_id() {
26                    label.push_str(" (active)");
27                }
28                UiLayout::List.label(ui, label);
29                ui.end_row();
30            });
31
32        if ui_layout.is_single_line() {
33            return;
34        }
35
36        // ---------------------------------------------------------------------
37
38        // Find all recordings with this app id
39        let recordings: Vec<&EntityDb> = ctx
40            .storage_context
41            .bundle
42            .recordings()
43            .filter(|db| db.application_id() == self)
44            .sorted_by_key(|entity_db| {
45                entity_db
46                    .recording_info_property::<Timestamp>(&RecordingInfo::descriptor_start_time())
47            })
48            .collect();
49
50        // Using the same content ui also for tooltips even if it can't be interacted with.
51        // (still displays the content we want)
52        if !recordings.is_empty() {
53            ui.scope(|ui| {
54                ui.spacing_mut().item_spacing.y = 0.0;
55
56                ui.add_space(8.0);
57                ui.strong("Loaded recordings for this app");
58                for entity_db in recordings {
59                    entity_db_button_ui(ctx, ui, entity_db, ui_layout, true);
60                }
61            });
62        }
63    }
64}