Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ListItem in Stream Tree UI #3153

Merged
merged 11 commits into from
Sep 1, 2023
76 changes: 44 additions & 32 deletions crates/re_data_ui/src/item_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//!
//! TODO(andreas): This is not a `data_ui`, can this go somewhere else, shouldn't be in `re_data_ui`.

use egui::Ui;
use re_data_store::InstancePath;
use re_log_types::{ComponentPath, EntityPath, TimeInt, Timeline};
use re_viewer_context::{
Expand Down Expand Up @@ -94,31 +95,11 @@ pub fn instance_path_button_to(
text: impl Into<egui::WidgetText>,
) -> egui::Response {
let item = Item::InstancePath(space_view_id, instance_path.clone());
let subtype_string = if instance_path.instance_key.is_splat() {
"Entity"
} else {
"Entity Instance"
};

let response = ui
.selectable_label(ctx.selection().contains(&item), text)
.on_hover_ui(|ui| {
ui.strong(subtype_string);
ui.label(format!("Path: {instance_path}"));

// TODO(emilk): give data_ui an alternate "everything on this timeline" query?
// Then we can move the size view into `data_ui`.
let query = ctx.current_query();

if instance_path.instance_key.is_splat() {
let store = &ctx.store_db.entity_db.data_store;
let stats = store.entity_stats(query.timeline, instance_path.entity_path.hash());
entity_stats_ui(ui, &query.timeline, &stats);
} else {
// TODO(emilk): per-component stats
}

instance_path.data_ui(ctx, ui, UiVerbosity::Reduced, &query);
instance_hover_card_ui(ui, ctx, instance_path);
});

cursor_interact_with_selectable(ctx, response, item)
Expand Down Expand Up @@ -245,21 +226,11 @@ pub fn data_blueprint_button_to(
let response = ui
.selectable_label(ctx.selection().contains(&item), text)
.on_hover_ui(|ui| {
data_blueprint_tooltip(ui, ctx, entity_path);
entity_hover_card_ui(ui, ctx, entity_path);
});
cursor_interact_with_selectable(ctx, response, item)
}

pub fn data_blueprint_tooltip(
ui: &mut egui::Ui,
ctx: &mut ViewerContext<'_>,
entity_path: &EntityPath,
) {
ui.strong("Space View Entity");
ui.label(format!("Path: {entity_path}"));
entity_path.data_ui(ctx, ui, UiVerbosity::Reduced, &ctx.current_query());
}

pub fn time_button(
ctx: &mut ViewerContext<'_>,
ui: &mut egui::Ui,
Expand Down Expand Up @@ -344,3 +315,44 @@ pub fn select_hovered_on_click(
}
}
}

/// Displays the "hover card" (i.e. big tooltip) for an instance or an entity.
///
/// The entity hover card is displayed the provided instance path is a splat.
pub fn instance_hover_card_ui(
ui: &mut Ui,
ctx: &mut ViewerContext<'_>,
instance_path: &InstancePath,
) {
let subtype_string = if instance_path.instance_key.is_splat() {
"Entity"
} else {
"Entity Instance"
};
ui.strong(subtype_string);
ui.label(format!("Path: {instance_path}"));

// TODO(emilk): give data_ui an alternate "everything on this timeline" query?
// Then we can move the size view into `data_ui`.
let query = ctx.current_query();

if instance_path.instance_key.is_splat() {
let store = &ctx.store_db.entity_db.data_store;
let stats = store.entity_stats(query.timeline, instance_path.entity_path.hash());
entity_stats_ui(ui, &query.timeline, &stats);
} else {
// TODO(emilk): per-component stats
}

instance_path.data_ui(ctx, ui, UiVerbosity::Reduced, &query);
}

/// Displays the "hover card" (i.e. big tooltip) for an entity.
pub fn entity_hover_card_ui(
ui: &mut egui::Ui,
ctx: &mut ViewerContext<'_>,
entity_path: &EntityPath,
) {
let instance_path = InstancePath::entity_splat(entity_path.clone());
instance_hover_card_ui(ui, ctx, &instance_path);
}
3 changes: 2 additions & 1 deletion crates/re_time_panel/src/data_density_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,9 @@ pub fn data_density_graph_ui(
fn graph_color(ctx: &mut ViewerContext<'_>, item: &Item, ui: &mut egui::Ui) -> Color32 {
let is_selected = ctx.selection().contains(item);
if is_selected {
make_brighter(ui.visuals().selection.bg_fill)
make_brighter(ui.visuals().widgets.active.fg_stroke.color)
} else {
//TODO(ab): tokenize that!
Color32::from_gray(225)
}
}
Expand Down
Loading