Skip to content

Commit db8aca8

Browse files
committed
stash
1 parent 29bedad commit db8aca8

File tree

25 files changed

+265
-43
lines changed

25 files changed

+265
-43
lines changed

crates/viewer/re_blueprint_tree/src/blueprint_tree.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ impl BlueprintTree {
10231023
focused_item: &Item,
10241024
) -> Option<Item> {
10251025
match focused_item {
1026-
Item::AppId(_) | Item::DataSource(_) | Item::StoreId(_) => None,
1026+
Item::AppId(_) | Item::TableId(_) | Item::DataSource(_) | Item::StoreId(_) => None,
10271027

10281028
Item::Container(container_id) => {
10291029
self.expand_all_contents_until(

crates/viewer/re_context_menu/src/actions/collapse_expand_all.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ impl ContextMenuAction for CollapseExpandAllAction {
3434
// TODO(ab): in an ideal world, we'd check the fully expended/collapsed state of the item to
3535
// avoid showing a command that wouldn't have an effect but that's lots of added complexity.
3636
match item {
37-
Item::AppId(_) | Item::DataSource(_) | Item::StoreId(_) | Item::ComponentPath(_) => {
38-
false
39-
}
37+
Item::AppId(_)
38+
| Item::TableId(_)
39+
| Item::DataSource(_)
40+
| Item::StoreId(_)
41+
| Item::ComponentPath(_) => false,
4042

4143
Item::View(_) | Item::Container(_) | Item::InstancePath(_) => true,
4244

crates/viewer/re_context_menu/src/actions/copy_entity_path.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ impl ContextMenuAction for CopyEntityPathToClipboard {
1212
fn supports_item(&self, _ctx: &ContextMenuContext<'_>, item: &Item) -> bool {
1313
match item {
1414
Item::AppId(_)
15+
| Item::TableId(_)
1516
| Item::DataSource(_)
1617
| Item::StoreId(_)
1718
| Item::Container(_)

crates/viewer/re_context_menu/src/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use once_cell::sync::OnceCell;
44

55
use re_entity_db::InstancePath;
66
use re_viewer_context::{
7-
ContainerId, Contents, Item, ItemCollection, ItemContext, ViewId, ViewerContext,
7+
ContainerId, Contents, Item, ItemCollection, ItemContext, TableId, ViewId, ViewerContext,
88
};
99
use re_viewport_blueprint::{ContainerBlueprint, ViewportBlueprint};
1010

@@ -358,6 +358,7 @@ trait ContextMenuAction {
358358
for (item, _) in ctx.selection.iter() {
359359
match item {
360360
Item::AppId(app_id) => self.process_app_id(ctx, app_id),
361+
Item::TableId(table_id) => self.process_table_id(ctx, table_id),
361362
Item::DataSource(data_source) => self.process_data_source(ctx, data_source),
362363
Item::StoreId(store_id) => self.process_store_id(ctx, store_id),
363364
Item::ComponentPath(component_path) => {
@@ -386,6 +387,9 @@ trait ContextMenuAction {
386387
/// Process a single recording.
387388
fn process_store_id(&self, _ctx: &ContextMenuContext<'_>, _store_id: &re_log_types::StoreId) {}
388389

390+
/// Process a table.
391+
fn process_table_id(&self, _ctx: &ContextMenuContext<'_>, _store_id: &TableId) {}
392+
389393
/// Process a single container.
390394
fn process_container(&self, _ctx: &ContextMenuContext<'_>, _container_id: &ContainerId) {}
391395

crates/viewer/re_data_ui/src/item_ui.rs

+92-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use re_log_types::{
99
};
1010
use re_types::components::{Name, Timestamp};
1111
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::{HoverHighlight, Item, TableId, UiLayout, ViewId, ViewerContext};
1313

1414
use super::DataUi as _;
1515

@@ -852,3 +852,94 @@ pub fn entity_db_button_ui(
852852
.send_system(SystemCommand::SetSelection(item));
853853
}
854854
}
855+
856+
pub fn table_id_button_ui(
857+
ctx: &ViewerContext<'_>,
858+
ui: &mut egui::Ui,
859+
table_id: &TableId,
860+
// entity_db: &re_entity_db::EntityDb,
861+
ui_layout: UiLayout,
862+
) {
863+
use re_byte_size::SizeBytes as _;
864+
use re_viewer_context::{SystemCommand, SystemCommandSender as _};
865+
866+
// let size = re_format::format_bytes(entity_db.total_size_bytes() as _);
867+
// let title = format!("{app_id_prefix}{recording_name} - {size}");
868+
869+
// let store_id = entity_db.store_id().clone();
870+
let item = re_viewer_context::Item::TableId(table_id.clone());
871+
872+
let icon = &icons::VIEW_DATAFRAME;
873+
874+
let mut item_content =
875+
list_item::LabelContent::new(table_id.as_ref()).with_icon_fn(|ui, rect, visuals| {
876+
// Color icon based on whether this is the active recording or not:
877+
// let color = if ctx.store_context.is_active(&store_id) {
878+
let color = if false {
879+
visuals.fg_stroke.color
880+
} else {
881+
ui.visuals().widgets.noninteractive.fg_stroke.color
882+
};
883+
icon.as_image().tint(color).paint_at(ui, rect);
884+
});
885+
886+
if ui_layout.is_selection_panel() {
887+
item_content = item_content.with_buttons(|ui| {
888+
// Close-button:
889+
let resp = ui
890+
.small_icon_button(&icons::REMOVE)
891+
.on_hover_text("Close this table (all data will be lost)");
892+
if resp.clicked() {
893+
// TODO:
894+
// ctx.command_sender()
895+
// .send_system(SystemCommand::CloseStore(store_id.clone()));
896+
}
897+
resp
898+
});
899+
}
900+
901+
let mut list_item = ui
902+
.list_item()
903+
.selected(ctx.selection().contains_item(&item));
904+
905+
if ctx.hovered().contains_item(&item) {
906+
list_item = list_item.force_hovered(true);
907+
}
908+
909+
let response = list_item::list_item_scope(ui, "entity db button", |ui| {
910+
list_item
911+
.show_hierarchical(ui, item_content)
912+
.on_hover_ui(|ui| {
913+
// entity_db.data_ui(
914+
// ctx,
915+
// ui,
916+
// re_viewer_context::UiLayout::Tooltip,
917+
// &ctx.current_query(),
918+
// entity_db,
919+
// );
920+
ui.label("TODO: add hover");
921+
})
922+
});
923+
924+
if response.hovered() {
925+
ctx.selection_state().set_hovered(item.clone());
926+
}
927+
928+
if response.clicked() {
929+
// TODO
930+
// // When we click on a recording, we directly activate it. This is safe to do because
931+
// // it's non-destructive and recordings are immutable. Switching back is easy.
932+
// // We don't do the same thing for blueprints as swapping them can be much more disruptive.
933+
// // It is much less obvious how to undo a blueprint switch and what happened to your original
934+
// // blueprint.
935+
// // TODO(jleibs): We should still have an `Activate this Blueprint` button in the selection panel
936+
// // for the blueprint.
937+
// if store_id.kind == re_log_types::StoreKind::Recording {
938+
// ctx.command_sender()
939+
// .send_system(SystemCommand::ActivateRecording(store_id.clone()));
940+
// }
941+
942+
// ctx.command_sender()
943+
// .send_system(SystemCommand::SetSelection(item));
944+
}
945+
}

crates/viewer/re_selection_panel/src/item_heading_no_breadcrumbs.rs

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ fn item_heading_no_breadcrumbs(
4444
Item::AppId(_)
4545
| Item::DataSource(_)
4646
| Item::StoreId(_)
47+
| Item::TableId(_)
4748
| Item::Container(_)
4849
| Item::View(_) => {
4950
let ItemTitle {

crates/viewer/re_selection_panel/src/item_heading_with_breadcrumbs.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn item_bread_crumbs_ui(
7373
item: &Item,
7474
) {
7575
match item {
76-
Item::AppId(_) | Item::DataSource(_) | Item::StoreId(_) => {
76+
Item::AppId(_) | Item::DataSource(_) | Item::StoreId(_) | Item::TableId(_) => {
7777
// These have no bread crumbs, at least not currently.
7878
// I guess one could argue that the `StoreId` should have the `AppId` as its ancestor?
7979
}
@@ -192,6 +192,7 @@ fn last_part_of_item_heading(
192192
| Item::DataSource { .. }
193193
| Item::Container { .. }
194194
| Item::View { .. }
195+
| Item::TableId { .. }
195196
| Item::StoreId { .. } => true,
196197

197198
Item::InstancePath { .. } | Item::DataResult { .. } | Item::ComponentPath { .. } => false,

crates/viewer/re_selection_panel/src/item_title.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ use re_ui::{
1010
syntax_highlighting::{InstanceInBrackets as InstanceWithBrackets, SyntaxHighlightedBuilder},
1111
SyntaxHighlighting as _,
1212
};
13-
use re_viewer_context::{contents_name_style, ContainerId, Contents, Item, ViewId, ViewerContext};
13+
use re_viewer_context::{
14+
contents_name_style, ContainerId, Contents, Item, TableId, ViewId, ViewerContext,
15+
};
1416
use re_viewport_blueprint::ViewportBlueprint;
1517

1618
pub fn is_component_static(ctx: &ViewerContext<'_>, component_path: &ComponentPath) -> bool {
@@ -47,6 +49,7 @@ impl ItemTitle {
4749
}
4850

4951
Item::StoreId(store_id) => Self::from_store_id(ctx, store_id),
52+
Item::TableId(table_id) => Self::from_table_id(ctx, table_id),
5053

5154
Item::InstancePath(instance_path) => {
5255
Self::from_instance_path(ctx, style, instance_path)
@@ -73,6 +76,10 @@ impl ItemTitle {
7376
}
7477
}
7578

79+
pub fn from_table_id(_ctx: &ViewerContext<'_>, table_id: &TableId) -> Self {
80+
Self::new(table_id.as_ref(), &icons::ENTITY_RESERVED).with_tooltip(table_id.as_ref())
81+
}
82+
7683
pub fn from_store_id(ctx: &ViewerContext<'_>, store_id: &re_log_types::StoreId) -> Self {
7784
let id_str = format!("{} ID: {}", store_id.kind, store_id);
7885

crates/viewer/re_selection_panel/src/selection_panel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ fn data_section_ui(item: &Item) -> Option<Box<dyn DataUi>> {
644644
Some(Box::new(instance_path.clone()))
645645
}
646646
// Skip data ui since we don't know yet what to show for these.
647-
Item::View(_) | Item::Container(_) => None,
647+
Item::TableId(_) | Item::View(_) | Item::Container(_) => None,
648648
}
649649
}
650650

crates/viewer/re_view_spatial/src/ui_3d.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,11 @@ impl SpatialView3D {
561561
// Track focused entity if any.
562562
if let Some(focused_item) = ctx.focused_item {
563563
let focused_entity = match focused_item {
564-
Item::AppId(_) | Item::DataSource(_) | Item::StoreId(_) | Item::Container(_) => {
565-
None
566-
}
564+
Item::AppId(_)
565+
| Item::DataSource(_)
566+
| Item::StoreId(_)
567+
| Item::Container(_)
568+
| Item::TableId(_) => None,
567569

568570
Item::View(view_id) => {
569571
if view_id == &query.view_id {

crates/viewer/re_viewer/src/app.rs

+18-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use re_viewer_context::{
1616
store_hub::{BlueprintPersistence, StoreHub, StoreHubStats},
1717
AppOptions, AsyncRuntimeHandle, BlueprintUndoState, CommandReceiver, CommandSender,
1818
ComponentUiRegistry, DisplayMode, PlayState, StoreContext, SystemCommand,
19-
SystemCommandSender as _, ViewClass, ViewClassRegistry, ViewClassRegistryError,
19+
SystemCommandSender as _, TableStores, ViewClass, ViewClassRegistry, ViewClassRegistryError,
2020
};
2121

2222
use crate::{
@@ -1253,6 +1253,7 @@ impl App {
12531253
app_blueprint: &AppBlueprint<'_>,
12541254
gpu_resource_stats: &WgpuResourcePoolStatistics,
12551255
store_context: Option<&StoreContext<'_>>,
1256+
tables: Option<&TableStores>,
12561257
store_stats: Option<&StoreHubStats>,
12571258
) {
12581259
let mut main_panel_frame = egui::Frame::default();
@@ -1291,7 +1292,7 @@ impl App {
12911292
.callback_resources
12921293
.get_mut::<re_renderer::RenderContext>()
12931294
{
1294-
if let Some(store_context) = store_context {
1295+
if let (Some(store_context), Some(tables)) = (store_context, tables) {
12951296
#[cfg(target_arch = "wasm32")]
12961297
let is_history_enabled = self.startup_options.enable_history;
12971298
#[cfg(not(target_arch = "wasm32"))]
@@ -1307,6 +1308,7 @@ impl App {
13071308
ui,
13081309
render_ctx,
13091310
store_context,
1311+
tables,
13101312
&self.reflection,
13111313
&self.component_ui_registry,
13121314
&self.view_class_registry,
@@ -2083,12 +2085,12 @@ impl eframe::App for App {
20832085
BlueprintUndoState::default_query(),
20842086
|store_context| {
20852087
self.state
2086-
.blueprint_query_for_viewer(store_context.blueprint)
2088+
.blueprint_query_for_viewer(store_context.0.blueprint)
20872089
},
20882090
);
20892091

20902092
let app_blueprint = AppBlueprint::new(
2091-
store_context.as_ref(),
2093+
store_context.as_ref().map(|x| &x.0),
20922094
&blueprint_query,
20932095
egui_ctx,
20942096
self.panel_state_overrides_active
@@ -2100,7 +2102,8 @@ impl eframe::App for App {
21002102
frame,
21012103
&app_blueprint,
21022104
&gpu_resource_stats,
2103-
store_context.as_ref(),
2105+
store_context.as_ref().map(|x| &x.0),
2106+
store_context.as_ref().map(|x| x.1),
21042107
store_stats.as_ref(),
21052108
);
21062109

@@ -2113,10 +2116,18 @@ impl eframe::App for App {
21132116
self.command_sender.send_ui(cmd);
21142117
}
21152118

2116-
Self::handle_dropping_files(egui_ctx, store_context.as_ref(), &self.command_sender);
2119+
Self::handle_dropping_files(
2120+
egui_ctx,
2121+
store_context.as_ref().map(|x| &x.0),
2122+
&self.command_sender,
2123+
);
21172124

21182125
// Run pending commands last (so we don't have to wait for a repaint before they are run):
2119-
self.run_pending_ui_commands(egui_ctx, &app_blueprint, store_context.as_ref());
2126+
self.run_pending_ui_commands(
2127+
egui_ctx,
2128+
&app_blueprint,
2129+
store_context.as_ref().map(|x| &x.0),
2130+
);
21202131
}
21212132
self.run_pending_system_commands(&mut store_hub, egui_ctx);
21222133

crates/viewer/re_viewer/src/app_state.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use re_ui::{ContextExt as _, DesignTokens};
1212
use re_viewer_context::{
1313
AppOptions, ApplicationSelectionState, BlueprintUndoState, CommandSender, ComponentUiRegistry,
1414
DisplayMode, DragAndDropManager, GlobalContext, PlayState, RecordingConfig, SelectionChange,
15-
StoreContext, StoreHub, SystemCommand, SystemCommandSender as _, ViewClassExt as _,
16-
ViewClassRegistry, ViewStates, ViewerContext,
15+
StoreContext, StoreHub, SystemCommand, SystemCommandSender as _, TableStores,
16+
ViewClassExt as _, ViewClassRegistry, ViewStates, ViewerContext,
1717
};
1818
use re_viewport::ViewportUi;
1919
use re_viewport_blueprint::ui::add_view_or_container_modal_ui;
@@ -150,6 +150,7 @@ impl AppState {
150150
ui: &mut egui::Ui,
151151
render_ctx: &re_renderer::RenderContext,
152152
store_context: &StoreContext<'_>,
153+
table_stores: &TableStores,
153154
reflection: &re_types_core::reflection::Reflection,
154155
component_ui_registry: &ComponentUiRegistry,
155156
view_class_registry: &ViewClassRegistry,
@@ -290,6 +291,8 @@ impl AppState {
290291
maybe_visualizable_entities_per_visualizer: &maybe_visualizable_entities_per_visualizer,
291292
indicated_entities_per_visualizer: &indicated_entities_per_visualizer,
292293
query_results: &query_results,
294+
active_table: None, // TODO:
295+
tables: table_stores,
293296
rec_cfg,
294297
blueprint_cfg,
295298
selection_state,
@@ -370,6 +373,8 @@ impl AppState {
370373
maybe_visualizable_entities_per_visualizer: &maybe_visualizable_entities_per_visualizer,
371374
indicated_entities_per_visualizer: &indicated_entities_per_visualizer,
372375
query_results: &query_results,
376+
active_table: None, // TODO:
377+
tables: table_stores,
373378
rec_cfg,
374379
blueprint_cfg,
375380
selection_state,

crates/viewer/re_viewer/src/callback.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ impl CallbackSelectionItem {
6363
blueprint: &ViewportBlueprint,
6464
) -> Option<Self> {
6565
match item {
66-
Item::StoreId(_) | Item::AppId(_) | Item::ComponentPath(_) | Item::DataSource(_) => {
67-
None
68-
}
66+
Item::StoreId(_)
67+
| Item::AppId(_)
68+
| Item::ComponentPath(_)
69+
| Item::DataSource(_)
70+
| Item::TableId(_) => None,
6971
Item::View(view_id) => Some(Self::View {
7072
view_id: *view_id,
7173
view_name: if let Some(name) = get_view_name(blueprint, view_id) {

0 commit comments

Comments
 (0)