|
5 | 5 | use re_entity_db::{EntityTree, InstancePath};
|
6 | 6 | use re_format::format_uint;
|
7 | 7 | use re_log_types::{
|
8 |
| - ApplicationId, ComponentPath, EntityPath, TimeInt, TimeType, Timeline, TimelineName, |
| 8 | + ApplicationId, ComponentPath, EntityPath, TableId, TimeInt, TimeType, Timeline, TimelineName, |
9 | 9 | };
|
10 | 10 | use re_types::components::{Name, Timestamp};
|
11 | 11 | use re_ui::{icons, list_item, SyntaxHighlighting as _, UiExt as _};
|
12 |
| -use re_viewer_context::{HoverHighlight, Item, UiLayout, ViewId, ViewerContext}; |
| 12 | +use re_viewer_context::{ |
| 13 | + HoverHighlight, Item, SystemCommand, SystemCommandSender as _, UiLayout, ViewId, ViewerContext, |
| 14 | +}; |
13 | 15 |
|
14 | 16 | use super::DataUi as _;
|
15 | 17 |
|
@@ -722,7 +724,7 @@ pub fn store_id_button_ui(
|
722 | 724 | store_id: &re_log_types::StoreId,
|
723 | 725 | ui_layout: UiLayout,
|
724 | 726 | ) {
|
725 |
| - if let Some(entity_db) = ctx.store_context.bundle.get(store_id) { |
| 727 | + if let Some(entity_db) = ctx.storage_context.bundle.get(store_id) { |
726 | 728 | entity_db_button_ui(ctx, ui, entity_db, ui_layout, true);
|
727 | 729 | } else {
|
728 | 730 | ui_layout.label(ui, store_id.to_string());
|
@@ -801,7 +803,7 @@ pub fn entity_db_button_ui(
|
801 | 803 | });
|
802 | 804 | if resp.clicked() {
|
803 | 805 | ctx.command_sender()
|
804 |
| - .send_system(SystemCommand::CloseStore(store_id.clone())); |
| 806 | + .send_system(SystemCommand::CloseEntry(store_id.clone().into())); |
805 | 807 | }
|
806 | 808 | resp
|
807 | 809 | });
|
@@ -843,10 +845,73 @@ pub fn entity_db_button_ui(
|
843 | 845 | // for the blueprint.
|
844 | 846 | if store_id.kind == re_log_types::StoreKind::Recording {
|
845 | 847 | ctx.command_sender()
|
846 |
| - .send_system(SystemCommand::ActivateRecording(store_id.clone())); |
| 848 | + .send_system(SystemCommand::ActivateEntry(store_id.clone().into())); |
847 | 849 | }
|
848 | 850 |
|
849 | 851 | ctx.command_sender()
|
850 | 852 | .send_system(SystemCommand::SetSelection(item));
|
851 | 853 | }
|
852 | 854 | }
|
| 855 | + |
| 856 | +pub fn table_id_button_ui( |
| 857 | + ctx: &ViewerContext<'_>, |
| 858 | + ui: &mut egui::Ui, |
| 859 | + table_id: &TableId, |
| 860 | + ui_layout: UiLayout, |
| 861 | +) { |
| 862 | + let item = re_viewer_context::Item::TableId(table_id.clone()); |
| 863 | + |
| 864 | + let icon = &icons::VIEW_DATAFRAME; |
| 865 | + |
| 866 | + let mut item_content = |
| 867 | + list_item::LabelContent::new(table_id.as_str()).with_icon_fn(|ui, rect, visuals| { |
| 868 | + // Color icon based on whether this is the active table or not: |
| 869 | + let color = if ctx.active_table.as_ref() == Some(table_id) { |
| 870 | + visuals.fg_stroke.color |
| 871 | + } else { |
| 872 | + ui.visuals().widgets.noninteractive.fg_stroke.color |
| 873 | + }; |
| 874 | + icon.as_image().tint(color).paint_at(ui, rect); |
| 875 | + }); |
| 876 | + |
| 877 | + if ui_layout.is_selection_panel() { |
| 878 | + item_content = item_content.with_buttons(|ui| { |
| 879 | + // Close-button: |
| 880 | + let resp = ui |
| 881 | + .small_icon_button(&icons::REMOVE) |
| 882 | + .on_hover_text("Close this table (all data will be lost)"); |
| 883 | + if resp.clicked() { |
| 884 | + ctx.command_sender() |
| 885 | + .send_system(SystemCommand::CloseEntry(table_id.clone().into())); |
| 886 | + } |
| 887 | + resp |
| 888 | + }); |
| 889 | + } |
| 890 | + |
| 891 | + let mut list_item = ui |
| 892 | + .list_item() |
| 893 | + .selected(ctx.selection().contains_item(&item)); |
| 894 | + |
| 895 | + if ctx.hovered().contains_item(&item) { |
| 896 | + list_item = list_item.force_hovered(true); |
| 897 | + } |
| 898 | + |
| 899 | + let response = list_item::list_item_scope(ui, "entity db button", |ui| { |
| 900 | + list_item |
| 901 | + .show_hierarchical(ui, item_content) |
| 902 | + .on_hover_ui(|ui| { |
| 903 | + ui.label(format!("Table: {table_id}")); |
| 904 | + }) |
| 905 | + }); |
| 906 | + |
| 907 | + if response.hovered() { |
| 908 | + ctx.selection_state().set_hovered(item.clone()); |
| 909 | + } |
| 910 | + |
| 911 | + if response.clicked() { |
| 912 | + ctx.command_sender() |
| 913 | + .send_system(SystemCommand::ActivateEntry(table_id.clone().into())); |
| 914 | + ctx.command_sender() |
| 915 | + .send_system(SystemCommand::SetSelection(item)); |
| 916 | + } |
| 917 | +} |
0 commit comments