Skip to content

Commit

Permalink
Move context menu to new re_context_menu crate (rerun-io#6423)
Browse files Browse the repository at this point in the history
### What

- Fixes rerun-io#6414

Mostly pure refactor, except for moving
`determine_visualizable_entities` to a `SpaceViewClass` extension trait.

### 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 examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6423?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6423?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/6423)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
  • Loading branch information
abey79 authored May 26, 2024
1 parent 317dcda commit 2e494b3
Show file tree
Hide file tree
Showing 34 changed files with 195 additions and 127 deletions.
28 changes: 18 additions & 10 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,14 @@ Of course, this will only take us so far. In the future we plan on caching queri
Here is an overview of the crates included in the project:

<picture>
<img src="https://static.rerun.io/crates/b431e1271e48eaba8db3a38fef18f27227db9b2d/full.png" alt="">
<source media="(max-width: 480px)" srcset="https://static.rerun.io/crates/b431e1271e48eaba8db3a38fef18f27227db9b2d/480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/crates/b431e1271e48eaba8db3a38fef18f27227db9b2d/768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/crates/b431e1271e48eaba8db3a38fef18f27227db9b2d/1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/crates/b431e1271e48eaba8db3a38fef18f27227db9b2d/1200w.png">
<img src="https://static.rerun.io/crates/1681e343ee14bb8a72c32e818447cdf853683d64/full.png" alt="">
<source media="(max-width: 480px)" srcset="https://static.rerun.io/crates/1681e343ee14bb8a72c32e818447cdf853683d64/480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/crates/1681e343ee14bb8a72c32e818447cdf853683d64/768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/crates/1681e343ee14bb8a72c32e818447cdf853683d64/1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/crates/1681e343ee14bb8a72c32e818447cdf853683d64/1200w.png">
</picture>


<!-- !!! IMPORTANT!!!
This image must be updated each time a crate is added/removed/updated.
Expand Down Expand Up @@ -128,12 +129,7 @@ Update instructions:
|-----------------------------|----------------------------------------------------------------------------------------|
| re_viewer | The Rerun Viewer |
| re_viewport | The central viewport panel of the Rerun viewer. |
| re_viewport_blueprint | The data model description of the viewport panel. |
| re_time_panel | The time panel of the Rerun Viewer, allowing to control the displayed timeline & time. |
| re_data_ui | Provides ui elements for Rerun component data for the Rerun Viewer. |
| re_viewer_context | Rerun Viewer state that is shared with the viewer's code components. |
| re_ui | Rerun GUI theme and helpers, built around egui |
| re_renderer | A wgpu-based renderer for all your visualization needs. |
| re_space_view | Types & utilities for defining Space View classes and communicating with the Viewport. |
| re_space_view_bar_chart | A Space View that shows a single bar chart. |
| re_space_view_dataframe | A Space View that shows the data contained in entities in a table. |
Expand All @@ -144,6 +140,18 @@ Update instructions:
| re_space_view_time_series | A Space View that shows plots over Rerun timelines. |


##### UI support crates

| Crate | Description |
|-----------------------|----------------------------------------------------------------------|
| re_context_menu | Support crate for context menu and actions. |
| re_data_ui | Provides ui elements for Rerun component data for the Rerun Viewer. |
| re_renderer | A wgpu-based renderer for all your visualization needs. |
| re_ui | Rerun GUI theme and helpers, built around egui |
| re_viewer_context | Rerun Viewer state that is shared with the viewer's code components. |
| re_viewport_blueprint | The data model description of the viewport panel. |


### Application-level store

| Crate | Description |
Expand Down
29 changes: 24 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4170,6 +4170,27 @@ dependencies = [
"walkdir",
]

[[package]]
name = "re_context_menu"
version = "0.17.0-alpha.2"
dependencies = [
"egui",
"egui_tiles",
"itertools 0.12.0",
"nohash-hasher",
"once_cell",
"re_entity_db",
"re_log",
"re_log_types",
"re_smart_channel",
"re_tracing",
"re_types",
"re_ui",
"re_viewer_context",
"re_viewport_blueprint",
"static_assertions",
]

[[package]]
name = "re_crash_handler"
version = "0.17.0-alpha.2"
Expand Down Expand Up @@ -4647,7 +4668,6 @@ dependencies = [
"egui",
"re_data_store",
"re_entity_db",
"re_log_types",
"re_tracing",
"re_types_core",
"re_ui",
Expand Down Expand Up @@ -4827,6 +4847,7 @@ version = "0.17.0-alpha.2"
dependencies = [
"egui",
"itertools 0.12.0",
"re_context_menu",
"re_data_store",
"re_data_ui",
"re_entity_db",
Expand All @@ -4836,7 +4857,6 @@ dependencies = [
"re_types",
"re_ui",
"re_viewer_context",
"re_viewport",
"re_viewport_blueprint",
"serde",
"vec1",
Expand Down Expand Up @@ -5007,6 +5027,7 @@ dependencies = [
"re_analytics",
"re_build_info",
"re_build_tools",
"re_context_menu",
"re_data_loader",
"re_data_source",
"re_data_store",
Expand All @@ -5022,7 +5043,6 @@ dependencies = [
"re_renderer",
"re_sdk_comms",
"re_smart_channel",
"re_space_view",
"re_space_view_bar_chart",
"re_space_view_dataframe",
"re_space_view_spatial",
Expand Down Expand Up @@ -5108,12 +5128,12 @@ dependencies = [
"nohash-hasher",
"once_cell",
"rayon",
"re_context_menu",
"re_data_ui",
"re_entity_db",
"re_log",
"re_log_types",
"re_renderer",
"re_smart_channel",
"re_space_view",
"re_tracing",
"re_types",
Expand All @@ -5122,7 +5142,6 @@ dependencies = [
"re_viewer_context",
"re_viewport_blueprint",
"smallvec",
"static_assertions",
]

[[package]]
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ re_analytics = { path = "crates/re_analytics", version = "=0.17.0-alpha.2", defa
re_build_info = { path = "crates/re_build_info", version = "=0.17.0-alpha.2", default-features = false }
re_build_tools = { path = "crates/re_build_tools", version = "=0.17.0-alpha.2", default-features = false }
re_crash_handler = { path = "crates/re_crash_handler", version = "=0.17.0-alpha.2", default-features = false }
re_context_menu = { path = "crates/re_context_menu", version = "=0.17.0-alpha.2", default-features = false }
re_data_loader = { path = "crates/re_data_loader", version = "=0.17.0-alpha.2", default-features = false }
re_data_source = { path = "crates/re_data_source", version = "=0.17.0-alpha.2", default-features = false }
re_data_store = { path = "crates/re_data_store", version = "=0.17.0-alpha.2", default-features = false }
Expand Down
37 changes: 37 additions & 0 deletions crates/re_context_menu/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
authors.workspace = true
description = "Support crate for context menu and actions."
edition.workspace = true
homepage.workspace = true
license.workspace = true
name = "re_context_menu"
publish = true
readme = "README.md"
repository.workspace = true
rust-version.workspace = true
version.workspace = true
include = ["../../LICENSE-APACHE", "../../LICENSE-MIT", "**/*.rs", "Cargo.toml"]

[lints]
workspace = true

[package.metadata.docs.rs]
all-features = true

[dependencies]
re_entity_db = { workspace = true, features = ["serde"] }
re_log_types.workspace = true
re_log.workspace = true
re_smart_channel.workspace = true
re_tracing.workspace = true
re_types.workspace = true
re_ui.workspace = true
re_viewer_context.workspace = true
re_viewport_blueprint.workspace = true

egui.workspace = true
egui_tiles.workspace = true
itertools.workspace = true
nohash-hasher.workspace = true
once_cell.workspace = true
static_assertions.workspace = true
10 changes: 10 additions & 0 deletions crates/re_context_menu/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# re_context_menu

Part of the [`rerun`](https://github.com/rerun-io/rerun) family of crates.

[![Latest version](https://img.shields.io/crates/v/re_context_menu.svg)](https://crates.io/crates/re_context_menu?speculative-link)
[![Documentation](https://docs.rs/re_context_menu/badge.svg)](https://docs.rs/re_context_menu?speculative-link)
![MIT](https://img.shields.io/badge/license-MIT-blue.svg)
![Apache](https://img.shields.io/badge/license-Apache-blue.svg)

Support crate for context menu and actions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use egui_tiles::ContainerKind;
use re_ui::icons;
use re_viewer_context::{ContainerId, Item};

use crate::context_menu::{ContextMenuAction, ContextMenuContext};
use crate::{ContextMenuAction, ContextMenuContext};

/// Add a container of a specific type
pub(crate) struct AddContainerAction(pub ContainerKind);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ use itertools::Itertools;
use nohash_hasher::IntSet;

use re_log_types::{EntityPath, EntityPathFilter, EntityPathRule, RuleEffect};
use re_space_view::determine_visualizable_entities;
use re_types::SpaceViewClassIdentifier;
use re_viewer_context::{Item, RecommendedSpaceView};
use re_viewer_context::{Item, RecommendedSpaceView, SpaceViewClassExt as _};
use re_viewport_blueprint::SpaceViewBlueprint;

use crate::context_menu::{ContextMenuAction, ContextMenuContext};
use crate::{ContextMenuAction, ContextMenuContext};

/// Create a new space view containing the selected entities.
///
Expand Down Expand Up @@ -103,11 +102,10 @@ fn recommended_space_views_for_selection(
continue;
};

let visualizable_entities = determine_visualizable_entities(
let visualizable_entities = entry.class.determine_visualizable_entities(
&applicable_entities_per_visualizer,
recording,
&space_view_class_registry.new_visualizer_collection(entry.identifier),
&*entry.class,
&suggested_root,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use re_ui::Icon;
use re_viewer_context::{ContainerId, Item, RecommendedSpaceView};
use re_viewport_blueprint::SpaceViewBlueprint;

use crate::context_menu::{ContextMenuAction, ContextMenuContext};
use crate::{ContextMenuAction, ContextMenuContext};

/// Add a space view of the specific class
pub(crate) struct AddSpaceViewAction {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use re_viewer_context::{Item, SpaceViewId};

use crate::context_menu::{ContextMenuAction, ContextMenuContext};
use crate::{ContextMenuAction, ContextMenuContext};

/// Clone a single space view
pub(crate) struct CloneSpaceViewAction;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use re_entity_db::InstancePath;
use re_viewer_context::{CollapseScope, ContainerId, Contents, Item, SpaceViewId};

use crate::context_menu::{ContextMenuAction, ContextMenuContext};
use crate::{ContextMenuAction, ContextMenuContext};

/// Collapse or expand all items in the selection.
// TODO(ab): the current implementation makes strong assumptions of which CollapseScope to use based
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use egui_tiles::ContainerKind;
use re_ui::icons;
use re_viewer_context::Item;

use crate::context_menu::{ContextMenuAction, ContextMenuContext};
use crate::{ContextMenuAction, ContextMenuContext};

/// Move the selected contents to a newly created container of the given kind
pub(crate) struct MoveContentsToNewContainerAction(pub ContainerKind);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use re_entity_db::InstancePath;
use re_viewer_context::{ContainerId, Contents, Item, SpaceViewId};

use crate::context_menu::{ContextMenuAction, ContextMenuContext};
use crate::{ContextMenuAction, ContextMenuContext};

/// Remove a container, space view, or data result.
pub(crate) struct RemoveAction;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use re_entity_db::InstancePath;
use re_viewer_context::{ContainerId, Contents, Item, SpaceViewId};

use crate::context_menu::{ContextMenuAction, ContextMenuContext};
use crate::{ContextMenuAction, ContextMenuContext};

pub(crate) struct ShowAction;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Support crate for context menu and actions.
use once_cell::sync::OnceCell;

use re_entity_db::InstancePath;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use egui::{Response, Ui};

use crate::context_menu::{ContextMenuAction, ContextMenuContext};
use crate::{ContextMenuAction, ContextMenuContext};

/// Group items into a sub-menu
pub(super) struct SubMenu {
Expand Down
1 change: 0 additions & 1 deletion crates/re_space_view/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ all-features = true
default = []

[dependencies]
re_log_types.workspace = true
re_data_store.workspace = true
re_entity_db.workspace = true
re_tracing.workspace = true
Expand Down
2 changes: 0 additions & 2 deletions crates/re_space_view/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ pub mod controls;
mod heuristics;
mod screenshot;
mod view_property_ui;
mod visualizable;

pub use heuristics::suggest_space_view_for_each_entity;
pub use screenshot::ScreenshotMode;
pub use view_property_ui::view_property_ui;
pub use visualizable::determine_visualizable_entities;

pub mod external {
pub use re_entity_db::external::*;
Expand Down
38 changes: 0 additions & 38 deletions crates/re_space_view/src/visualizable.rs

This file was deleted.

2 changes: 1 addition & 1 deletion crates/re_time_panel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ workspace = true
all-features = true

[dependencies]
re_context_menu.workspace = true
re_data_store.workspace = true
re_data_ui.workspace = true
re_entity_db.workspace = true
Expand All @@ -28,7 +29,6 @@ re_tracing.workspace = true
re_types.workspace = true
re_ui.workspace = true
re_viewer_context.workspace = true
re_viewport.workspace = true # TODO(#6414): remove this dependency in favor of re_context_menu when it exists
re_viewport_blueprint.workspace = true

egui.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/re_time_panel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mod time_selection_ui;
use egui::emath::Rangef;
use egui::{pos2, Color32, CursorIcon, NumExt, Painter, PointerButton, Rect, Shape, Ui, Vec2};

use re_context_menu::{context_menu_ui_for_item, SelectionUpdateBehavior};
use re_data_ui::item_ui::guess_instance_path_icon;
use re_data_ui::DataUi as _;
use re_entity_db::{EntityTree, InstancePath, TimeHistogram};
Expand All @@ -29,7 +30,6 @@ use re_viewer_context::{
CollapseScope, HoverHighlight, Item, RecordingConfig, TimeControl, TimeView, UiLayout,
ViewerContext,
};
use re_viewport::{context_menu_ui_for_item, SelectionUpdateBehavior};
use re_viewport_blueprint::ViewportBlueprint;

use time_axis::TimelineAxis;
Expand Down
Loading

0 comments on commit 2e494b3

Please sign in to comment.