Skip to content

Commit

Permalink
Make re_edit_ui its own crate (#6444)
Browse files Browse the repository at this point in the history
### What

Adds a new leaf crate to the viewer crate ecosystem.
While working on edit/data uis I noticed that most of the things in this
crate just register ui and aren't used anywhere else. Unfortunately,
`re_data_ui` provides various non component ui (causing it to become a
more basic crate) and the orphan rule makes it fairly hard to move
things out. So far however, edit uis have been untained by this! I want
this to stay this way since:
* changing edit ui is a frequent operation
* this is an easy opportunity to have crate compilation up to
`re_viewer` itself stay wide

As we provide more and more edit ui we might end up where we prefer edit
ui over display ui when available (using a disabled edit ui) which means
that over time `re_edit_ui` will be more important. Having it be only a
dependency of `re_reviewer` ensures a clean architecture.


![image](https://github.com/rerun-io/rerun/assets/1220815/d6e46f89-e159-4409-87ca-107eb6d7fbd8)


### 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/6444?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/6444?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/6444)
- [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
Wumpf authored May 28, 2024
1 parent 68a1061 commit 5561df4
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 28 deletions.
41 changes: 21 additions & 20 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ 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/6fa2652f031b744bb2f6ba3f09e2383378e9a372/full.png" alt="">
<source media="(max-width: 480px)" srcset="https://static.rerun.io/crates/6fa2652f031b744bb2f6ba3f09e2383378e9a372/480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/crates/6fa2652f031b744bb2f6ba3f09e2383378e9a372/768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/crates/6fa2652f031b744bb2f6ba3f09e2383378e9a372/1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/crates/6fa2652f031b744bb2f6ba3f09e2383378e9a372/1200w.png">
<img src="https://static.rerun.io/architecture/3b77eee59cfef76b8312f66a637cf28edbd0f6ac/full.png" alt="">
<source media="(max-width: 480px)" srcset="https://static.rerun.io/architecture/3b77eee59cfef76b8312f66a637cf28edbd0f6ac/480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/architecture/3b77eee59cfef76b8312f66a637cf28edbd0f6ac/768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/architecture/3b77eee59cfef76b8312f66a637cf28edbd0f6ac/1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/architecture/3b77eee59cfef76b8312f66a637cf28edbd0f6ac/1200w.png">
</picture>


Expand Down Expand Up @@ -125,21 +125,22 @@ Update instructions:

##### UI crates

| Crate | Description |
|-----------------------------|----------------------------------------------------------------------------------------|
| re_blueprint_tree | The UI for the blueprint tree in the left panel. |
| re_viewer | The Rerun Viewer |
| re_viewport | The central viewport panel of the Rerun viewer. |
| re_time_panel | The time panel of the Rerun Viewer, allowing to control the displayed timeline & time. |
| re_selection_panel | The UI for the selection panel. |
| 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. |
| re_space_view_spatial | Space Views that show entities in a 2D or 3D spatial relationship. |
| re_space_view_tensor | A Space View dedicated to visualizing tensors with arbitrary dimensionality. |
| re_space_view_text_document | A simple Space View that shows a single text box. |
| re_space_view_text_log | A Space View that shows text entries in a table and scrolls with the active time. |
| re_space_view_time_series | A Space View that shows plots over Rerun timelines. |
| Crate | Description |
|-----------------------------|-------------------------------------------------------------------------------------------------------------|
| re_blueprint_tree | The UI for the blueprint tree in the left panel. |
| re_edit_ui | Provides ui editors for Rerun component data for registration with the Rerun Viewer component ui registry. |
| re_selection_panel | The UI for the selection panel. |
| 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. |
| re_space_view_spatial | Space Views that show entities in a 2D or 3D spatial relationship. |
| re_space_view_tensor | A Space View dedicated to visualizing tensors with arbitrary dimensionality. |
| re_space_view_text_document | A simple Space View that shows a single text box. |
| re_space_view_text_log | A Space View that shows text entries in a table and scrolls with the active time. |
| re_space_view_time_series | A Space View that shows plots over Rerun timelines. |
| re_time_panel | The time panel of the Rerun Viewer, allowing to control the displayed timeline & time. |
| re_viewer | The Rerun Viewer |
| re_viewport | The central viewport panel of the Rerun viewer. |


##### UI support crates
Expand Down
16 changes: 16 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4347,6 +4347,21 @@ dependencies = [
"wasm-bindgen-cli-support",
]

[[package]]
name = "re_edit_ui"
version = "0.17.0-alpha.3"
dependencies = [
"egui",
"egui_plot",
"re_data_store",
"re_entity_db",
"re_log_types",
"re_types",
"re_types_blueprint",
"re_ui",
"re_viewer_context",
]

[[package]]
name = "re_entity_db"
version = "0.17.0-alpha.3"
Expand Down Expand Up @@ -5077,6 +5092,7 @@ dependencies = [
"re_data_source",
"re_data_store",
"re_data_ui",
"re_edit_ui",
"re_entity_db",
"re_error",
"re_format",
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ re_analytics = { path = "crates/re_analytics", version = "=0.17.0-alpha.3", defa
re_blueprint_tree = { path = "crates/re_blueprint_tree", version = "=0.17.0-alpha.3", default-features = false }
re_build_info = { path = "crates/re_build_info", version = "=0.17.0-alpha.3", default-features = false }
re_build_tools = { path = "crates/re_build_tools", version = "=0.17.0-alpha.3", default-features = false }
re_crash_handler = { path = "crates/re_crash_handler", version = "=0.17.0-alpha.3", default-features = false }
re_context_menu = { path = "crates/re_context_menu", version = "=0.17.0-alpha.3", default-features = false }
re_crash_handler = { path = "crates/re_crash_handler", version = "=0.17.0-alpha.3", default-features = false }
re_data_loader = { path = "crates/re_data_loader", version = "=0.17.0-alpha.3", default-features = false }
re_data_source = { path = "crates/re_data_source", version = "=0.17.0-alpha.3", default-features = false }
re_data_store = { path = "crates/re_data_store", version = "=0.17.0-alpha.3", default-features = false }
re_data_ui = { path = "crates/re_data_ui", version = "=0.17.0-alpha.3", default-features = false }
re_dev_tools = { path = "crates/re_dev_tools", version = "=0.17.0-alpha.3", default-features = false }
re_edit_ui = { path = "crates/re_edit_ui", version = "=0.17.0-alpha.3", default-features = false }
re_entity_db = { path = "crates/re_entity_db", version = "=0.17.0-alpha.3", default-features = false }
re_error = { path = "crates/re_error", version = "=0.17.0-alpha.3", default-features = false }
re_format = { path = "crates/re_format", version = "=0.17.0-alpha.3", default-features = false }
Expand All @@ -50,9 +51,9 @@ re_log_types = { path = "crates/re_log_types", version = "=0.17.0-alpha.3", defa
re_memory = { path = "crates/re_memory", version = "=0.17.0-alpha.3", default-features = false }
re_query = { path = "crates/re_query", version = "=0.17.0-alpha.3", default-features = false }
re_renderer = { path = "crates/re_renderer", version = "=0.17.0-alpha.3", default-features = false }
re_selection_panel = { path = "crates/re_selection_panel", version = "=0.17.0-alpha.3", default-features = false }
re_sdk = { path = "crates/re_sdk", version = "=0.17.0-alpha.3", default-features = false }
re_sdk_comms = { path = "crates/re_sdk_comms", version = "=0.17.0-alpha.3", default-features = false }
re_selection_panel = { path = "crates/re_selection_panel", version = "=0.17.0-alpha.3", default-features = false }
re_smart_channel = { path = "crates/re_smart_channel", version = "=0.17.0-alpha.3", default-features = false }
re_space_view = { path = "crates/re_space_view", version = "=0.17.0-alpha.3", default-features = false }
re_space_view_bar_chart = { path = "crates/re_space_view_bar_chart", version = "=0.17.0-alpha.3", default-features = false }
Expand Down
4 changes: 0 additions & 4 deletions crates/re_data_ui/src/component_ui_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use re_log_types::{external::arrow2, EntityPath, Instance};
use re_types::external::arrow2::array::Utf8Array;
use re_viewer_context::{ComponentUiRegistry, UiLayout, ViewerContext};

use crate::editors::register_editors;

use super::{data_label_for_ui_layout, EntityDataUi};

pub fn create_component_ui_registry() -> ComponentUiRegistry {
Expand Down Expand Up @@ -33,8 +31,6 @@ pub fn create_component_ui_registry() -> ComponentUiRegistry {
add_to_registry::<re_types_blueprint::blueprint::components::SpaceViewMaximized>(&mut registry);
add_to_registry::<re_types_blueprint::blueprint::components::VisualBounds2D>(&mut registry);

register_editors(&mut registry);

registry
}

Expand Down
1 change: 0 additions & 1 deletion crates/re_data_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ mod component_path;
mod component_ui_registry;
mod data;
mod data_source;
mod editors;
mod entity_db;
mod entity_path;
mod image;
Expand Down
33 changes: 33 additions & 0 deletions crates/re_edit_ui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
description = "Provides ui editors for Rerun component data for registration with the Rerun Viewer component ui registry."
authors.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
name = "re_edit_ui"
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_data_store.workspace = true
re_entity_db.workspace = true
re_log_types.workspace = true
re_types = { workspace = true, features = [
"egui_plot", # Needed to draw marker shapes.
] }
re_types_blueprint.workspace = true
re_ui.workspace = true
re_viewer_context.workspace = true

egui_plot.workspace = true
egui.workspace = true
10 changes: 10 additions & 0 deletions crates/re_edit_ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# re_data_ui

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

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

Provides ui editors for Rerun component data for registration with the Rerun Viewer component ui registry.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
//! This crate implements various component editors.
//!
//! The only entry point is [`register_editors`], which registers all editors in the component UI registry.
//! This should be called by `re_viewer` on startup.
// TODO(jleibs): Turn these methods into a trait.

mod corner2d;
Expand Down Expand Up @@ -464,6 +469,10 @@ fn register_editor<'a, C>(
);
}

/// Registers all editors of this crate in the component UI registry.
///
/// ⚠️ This is supposed to be the only export of this crate.
/// This crate is meant to be a leaf crate in the viewer ecosystem and should only be used by the `re_viewer` crate itself.
pub fn register_editors(registry: &mut re_viewer_context::ComponentUiRegistry) {
register_editor::<Color>(registry, default_color, edit_color_ui);
register_editor::<Corner2D>(
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions crates/re_viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ re_data_loader.workspace = true
re_data_source.workspace = true
re_data_store.workspace = true
re_data_ui.workspace = true
re_edit_ui.workspace = true
re_entity_db = { workspace = true, features = ["serde"] }
re_error.workspace = true
re_format.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ impl App {

let (command_sender, command_receiver) = command_channel();

let component_ui_registry = re_data_ui::create_component_ui_registry();
let mut component_ui_registry = re_data_ui::create_component_ui_registry();
re_edit_ui::register_editors(&mut component_ui_registry);

// TODO(emilk): `Instant::MIN` when we have our own `Instant` that supports it.;
let long_time_ago = web_time::Instant::now()
Expand Down

0 comments on commit 5561df4

Please sign in to comment.