Skip to content

Commit

Permalink
More context menu 5: add context menu to streams tree (#5422)
Browse files Browse the repository at this point in the history
### What

The streams tree now supports context menu. Currently, the only
available action is to create a space view with the selected entities.

Annoyingly, this PR introduces a dependency on `re_viewport` from
`re_time_panel`. However, a refactor is in order and will enable a scope
reduction for this new (otherwise inevitable) dependency:
- #5421

<img width="510" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/a5ec0e60-5a0e-47cb-9f19-94729d96b30e">


### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using newly built examples:
[app.rerun.io](https://app.rerun.io/pr/5422/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5422/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/5422/index.html?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/5422)
- [Docs
preview](https://rerun.io/preview/a62b1d874cda0237e5a9599627d34c19c889df99/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/a62b1d874cda0237e5a9599627d34c19c889df99/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
abey79 authored Mar 8, 2024
1 parent aa92ac3 commit 4804b66
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/re_time_panel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ re_log_types.workspace = true
re_tracing.workspace = true
re_ui.workspace = true
re_viewer_context.workspace = true
re_viewport.workspace = true # TODO(#5421): remove this dependency in favor of re_viewport_blueprint when it exists

egui.workspace = true
itertools.workspace = true
Expand Down
33 changes: 32 additions & 1 deletion crates/re_time_panel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use re_ui::list_item::{ListItem, WidthAllocationMode};
use re_viewer_context::{
CollapseScope, HoverHighlight, Item, RecordingConfig, TimeControl, TimeView, ViewerContext,
};
use re_viewport::{context_menu_ui_for_item, SelectionUpdateBehavior, ViewportBlueprint};

use time_axis::TimelineAxis;
use time_control_ui::TimeControlUi;
Expand Down Expand Up @@ -133,6 +134,7 @@ impl TimePanel {
pub fn show_panel(
&mut self,
ctx: &ViewerContext<'_>,
viewport_blueprint: &ViewportBlueprint,
entity_db: &re_entity_db::EntityDb,
rec_cfg: &RecordingConfig,
ui: &mut egui::Ui,
Expand Down Expand Up @@ -223,7 +225,13 @@ impl TimePanel {
let mut streams_frame = egui::Frame::default();
streams_frame.inner_margin.left = margin.x;
streams_frame.show(ui, |ui| {
self.expanded_ui(ctx, entity_db, ui, &mut time_ctrl_after);
self.expanded_ui(
ctx,
viewport_blueprint,
entity_db,
ui,
&mut time_ctrl_after,
);
});
});
}
Expand Down Expand Up @@ -287,6 +295,7 @@ impl TimePanel {
fn expanded_ui(
&mut self,
ctx: &ViewerContext<'_>,
viewport_blueprint: &ViewportBlueprint,
entity_db: &re_entity_db::EntityDb,
ui: &mut egui::Ui,
time_ctrl: &mut TimeControl,
Expand Down Expand Up @@ -422,6 +431,7 @@ impl TimePanel {
// All the entity rows and their data density graphs:
self.tree_ui(
ctx,
viewport_blueprint,
entity_db,
time_ctrl,
&time_area_response,
Expand Down Expand Up @@ -473,6 +483,7 @@ impl TimePanel {
fn tree_ui(
&mut self,
ctx: &ViewerContext<'_>,
viewport_blueprint: &ViewportBlueprint,
entity_db: &re_entity_db::EntityDb,
time_ctrl: &mut TimeControl,
time_area_response: &egui::Response,
Expand Down Expand Up @@ -501,6 +512,7 @@ impl TimePanel {
if show_root {
self.show_tree(
ctx,
viewport_blueprint,
time_ctrl,
time_area_response,
time_area_painter,
Expand All @@ -513,6 +525,7 @@ impl TimePanel {
} else {
self.show_children(
ctx,
viewport_blueprint,
time_ctrl,
time_area_response,
time_area_painter,
Expand All @@ -528,6 +541,7 @@ impl TimePanel {
fn show_tree(
&mut self,
ctx: &ViewerContext<'_>,
viewport_blueprint: &ViewportBlueprint,
time_ctrl: &mut TimeControl,
time_area_response: &egui::Response,
time_area_painter: &egui::Painter,
Expand Down Expand Up @@ -588,6 +602,7 @@ impl TimePanel {
|_, ui| {
self.show_children(
ctx,
viewport_blueprint,
time_ctrl,
time_area_response,
time_area_painter,
Expand All @@ -610,6 +625,13 @@ impl TimePanel {
);
});

context_menu_ui_for_item(
ctx,
viewport_blueprint,
&item.to_item(),
&response,
SelectionUpdateBehavior::UseSelection,
);
ctx.select_hovered_on_click(&response, item.to_item());

let is_closed = body_response.is_none();
Expand Down Expand Up @@ -664,6 +686,7 @@ impl TimePanel {
fn show_children(
&mut self,
ctx: &ViewerContext<'_>,
viewport_blueprint: &ViewportBlueprint,
time_ctrl: &mut TimeControl,
time_area_response: &egui::Response,
time_area_painter: &egui::Painter,
Expand All @@ -674,6 +697,7 @@ impl TimePanel {
for (last_component, child) in &tree.children {
self.show_tree(
ctx,
viewport_blueprint,
time_ctrl,
time_area_response,
time_area_painter,
Expand Down Expand Up @@ -715,6 +739,13 @@ impl TimePanel {

ui.set_clip_rect(clip_rect_save);

context_menu_ui_for_item(
ctx,
viewport_blueprint,
&item.to_item(),
&response,
SelectionUpdateBehavior::UseSelection,
);
ctx.select_hovered_on_click(&response, item.to_item());

let response_rect = response.rect;
Expand Down
10 changes: 9 additions & 1 deletion crates/re_viewer/src/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,18 @@ impl AppState {
};

if app_options.inspect_blueprint_timeline {
blueprint_panel.show_panel(&ctx, ctx.store_context.blueprint, blueprint_cfg, ui, true);
blueprint_panel.show_panel(
&ctx,
&viewport_blueprint,
ctx.store_context.blueprint,
blueprint_cfg,
ui,
true,
);
}
time_panel.show_panel(
&ctx,
&viewport_blueprint,
ctx.entity_db,
ctx.rec_cfg,
ui,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@
README = """
# Context Menu - Add entity to new space view
## Blueprint tree
* Reset the blueprint.
* Expend all space views and data result.
* Right-click on the `boxes3d` entity and select "Add to new space view" -> "3D". Check a new space view is created _and selected_ with the boxes3d entity and origin set to root.
* In each space view, right-click on the leaf entity, and check that "Add to new space view" recommends at least space views of the same kind.
* Select both the `boxes3d` entity and the `text_logs` entity. Check no space view is recommended (except Dataframe if enabled).
## Streams tree
* Right-click on the `bars` entity and check that a Bar Plot space view can successfully be created.
"""


Expand Down

0 comments on commit 4804b66

Please sign in to comment.