diff --git a/crates/re_time_panel/src/lib.rs b/crates/re_time_panel/src/lib.rs index 9521a2f911a0..64a4ffd9d262 100644 --- a/crates/re_time_panel/src/lib.rs +++ b/crates/re_time_panel/src/lib.rs @@ -584,6 +584,18 @@ impl TimePanel { clip_rect.max.x = tree_max_y; ui.set_clip_rect(clip_rect); + // expand if children is focused + let focused_entity_path = ctx + .focused_item + .as_ref() + .and_then(|item| item.entity_path()); + + if focused_entity_path.is_some_and(|entity_path| entity_path.is_descendant_of(&tree.path)) { + CollapseScope::StreamsTree + .entity(tree.path.clone()) + .set_open(ui.ctx(), true); + } + let re_ui::list_item::ShowCollapsingResponse { item_response: response, body_response, @@ -625,6 +637,15 @@ impl TimePanel { ); }); + if Some(&tree.path) == focused_entity_path { + // Scroll only if the entity isn't already visible. This is important because that's what + // happens when double-clicking an entity _in the blueprint tree_. In such case, it would be + // annoying to induce a scroll motion. + if !ui.clip_rect().contains_rect(response.rect) { + response.scroll_to_me(Some(egui::Align::Center)); + } + } + context_menu_ui_for_item( ctx, viewport_blueprint, diff --git a/crates/re_viewport/src/viewport_blueprint_ui.rs b/crates/re_viewport/src/viewport_blueprint_ui.rs index 588fefd8c047..382e62c8880e 100644 --- a/crates/re_viewport/src/viewport_blueprint_ui.rs +++ b/crates/re_viewport/src/viewport_blueprint_ui.rs @@ -64,7 +64,10 @@ impl Viewport<'_, '_> { .auto_shrink([true, false]) .show(ui, |ui| { ctx.re_ui.panel_content(ui, |_, ui| { - self.state.blueprint_tree_scroll_to_item = self.handle_focused_item(ctx, ui); + self.state.blueprint_tree_scroll_to_item = ctx + .focused_item + .as_ref() + .and_then(|item| self.handle_focused_item(ctx, ui, item)); self.root_container_tree_ui(ctx, ui); @@ -86,8 +89,12 @@ impl Viewport<'_, '_> { } /// Expend all required items and compute which item we should scroll to. - fn handle_focused_item(&self, ctx: &ViewerContext<'_>, ui: &egui::Ui) -> Option { - let focused_item = ctx.focused_item.as_ref()?; + fn handle_focused_item( + &self, + ctx: &ViewerContext<'_>, + ui: &egui::Ui, + focused_item: &Item, + ) -> Option { match focused_item { Item::Container(container_id) => { self.expand_all_contents_until(ui.ctx(), &Contents::Container(*container_id)); @@ -129,8 +136,15 @@ impl Viewport<'_, '_> { res } + Item::ComponentPath(component_path) => self.handle_focused_item( + ctx, + ui, + &Item::InstancePath(InstancePath::entity_splat( + component_path.entity_path.clone(), + )), + ), - Item::StoreId(_) | Item::ComponentPath(_) => None, + Item::StoreId(_) => None, } } diff --git a/tests/python/release_checklist/check_focus.py b/tests/python/release_checklist/check_focus.py index f2d1bf5a34cd..2f4a711e957e 100644 --- a/tests/python/release_checklist/check_focus.py +++ b/tests/python/release_checklist/check_focus.py @@ -19,8 +19,10 @@ ## Checks -- Collapse all in the blueprint tree. -- Double-click on the box in the first space view, check corresponding space view expands. +- Collapse all in the blueprint tree and the streams view +- Double-click on the box in the first space view + - check corresponding space view expands and scrolls + - check the streams view expands and scrolls - Collapse all in the blueprint tree. - Double-click on the leaf "boxes3d" entity in the streams view, check both space views expand. """