From 5561df4cdfd01234f432f8c62559b71d6c71891b Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Tue, 28 May 2024 18:16:14 +0200 Subject: [PATCH] Make re_edit_ui its own crate (#6444) ### 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`. --- ARCHITECTURE.md | 41 ++++++++++--------- Cargo.lock | 16 ++++++++ Cargo.toml | 5 ++- .../re_data_ui/src/component_ui_registry.rs | 4 -- crates/re_data_ui/src/lib.rs | 1 - crates/re_edit_ui/Cargo.toml | 33 +++++++++++++++ crates/re_edit_ui/README.md | 10 +++++ .../editors => re_edit_ui/src}/corner2d.rs | 0 .../editors/mod.rs => re_edit_ui/src/lib.rs} | 9 ++++ .../src/editors => re_edit_ui/src}/visible.rs | 0 crates/re_viewer/Cargo.toml | 1 + crates/re_viewer/src/app.rs | 3 +- 12 files changed, 95 insertions(+), 28 deletions(-) create mode 100644 crates/re_edit_ui/Cargo.toml create mode 100644 crates/re_edit_ui/README.md rename crates/{re_data_ui/src/editors => re_edit_ui/src}/corner2d.rs (100%) rename crates/{re_data_ui/src/editors/mod.rs => re_edit_ui/src/lib.rs} (96%) rename crates/{re_data_ui/src/editors => re_edit_ui/src}/visible.rs (100%) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 8c364bda6cf3..fdedf20f219a 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -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: - - - - - + + + + + @@ -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 diff --git a/Cargo.lock b/Cargo.lock index c0c559cf73ef..67b63fe47a50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" @@ -5077,6 +5092,7 @@ dependencies = [ "re_data_source", "re_data_store", "re_data_ui", + "re_edit_ui", "re_entity_db", "re_error", "re_format", diff --git a/Cargo.toml b/Cargo.toml index 42f19c710c0c..1f6f7b8112b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } @@ -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 } diff --git a/crates/re_data_ui/src/component_ui_registry.rs b/crates/re_data_ui/src/component_ui_registry.rs index 5154ec45337e..1a28068bcbe3 100644 --- a/crates/re_data_ui/src/component_ui_registry.rs +++ b/crates/re_data_ui/src/component_ui_registry.rs @@ -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 { @@ -33,8 +31,6 @@ pub fn create_component_ui_registry() -> ComponentUiRegistry { add_to_registry::(&mut registry); add_to_registry::(&mut registry); - register_editors(&mut registry); - registry } diff --git a/crates/re_data_ui/src/lib.rs b/crates/re_data_ui/src/lib.rs index 7e628df3c4e2..fa9dd93e2c37 100644 --- a/crates/re_data_ui/src/lib.rs +++ b/crates/re_data_ui/src/lib.rs @@ -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; diff --git a/crates/re_edit_ui/Cargo.toml b/crates/re_edit_ui/Cargo.toml new file mode 100644 index 000000000000..b6f6bb1f2549 --- /dev/null +++ b/crates/re_edit_ui/Cargo.toml @@ -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 diff --git a/crates/re_edit_ui/README.md b/crates/re_edit_ui/README.md new file mode 100644 index 000000000000..2db50e9584a9 --- /dev/null +++ b/crates/re_edit_ui/README.md @@ -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. diff --git a/crates/re_data_ui/src/editors/corner2d.rs b/crates/re_edit_ui/src/corner2d.rs similarity index 100% rename from crates/re_data_ui/src/editors/corner2d.rs rename to crates/re_edit_ui/src/corner2d.rs diff --git a/crates/re_data_ui/src/editors/mod.rs b/crates/re_edit_ui/src/lib.rs similarity index 96% rename from crates/re_data_ui/src/editors/mod.rs rename to crates/re_edit_ui/src/lib.rs index 8c654879761e..08c63a25f29e 100644 --- a/crates/re_data_ui/src/editors/mod.rs +++ b/crates/re_edit_ui/src/lib.rs @@ -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; @@ -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::(registry, default_color, edit_color_ui); register_editor::( diff --git a/crates/re_data_ui/src/editors/visible.rs b/crates/re_edit_ui/src/visible.rs similarity index 100% rename from crates/re_data_ui/src/editors/visible.rs rename to crates/re_edit_ui/src/visible.rs diff --git a/crates/re_viewer/Cargo.toml b/crates/re_viewer/Cargo.toml index d393e84ea6b3..7a189509afe8 100644 --- a/crates/re_viewer/Cargo.toml +++ b/crates/re_viewer/Cargo.toml @@ -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 diff --git a/crates/re_viewer/src/app.rs b/crates/re_viewer/src/app.rs index 699eb5c514a9..1ff03c4dcf76 100644 --- a/crates/re_viewer/src/app.rs +++ b/crates/re_viewer/src/app.rs @@ -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()