Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for manually adding container and space view in the hierarchy #4616

Merged
merged 22 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a152451
(WIP) Update to next egui_tiles and disable container GC
abey79 Dec 18, 2023
b1e4924
Add a "simplify hierarchy" button to containers
abey79 Dec 15, 2023
7c048b5
Blueprint tree UI: only hide a single-child container if it's a `Cont…
abey79 Dec 15, 2023
59ea714
Container selection panel: add children list
abey79 Dec 18, 2023
b2a33a7
Rebase fix to "simplify hierarchy" button
abey79 Dec 18, 2023
54c53db
Add SV/Container modal
abey79 Dec 21, 2023
2141a4e
Fix to the "simplify container" feature
abey79 Dec 21, 2023
b36328d
Gate everything in the container selection panel behind container blu…
abey79 Dec 21, 2023
1b377ac
WIP: wiring up everything via tree actions
abey79 Dec 21, 2023
e9dc8d5
Rebase fixes
abey79 Dec 22, 2023
2ca0749
Added a feature flag + various clean-ups
abey79 Dec 22, 2023
425f38c
Moved feature flag to new "Experimental" section in option menu + bun…
abey79 Dec 22, 2023
c655ae3
Improved copy in the experimental menu
abey79 Dec 22, 2023
41bf606
Rebase fix
abey79 Dec 22, 2023
8ac5e31
Get rid of unnessary mutable logic
jleibs Dec 22, 2023
91ee54d
Made the entire row clickable and fix the bad hover background on the…
abey79 Jan 3, 2024
c1064fd
Merge branch 'main' into antoine/additive-workflow
abey79 Jan 3, 2024
a1877e0
Merge branch 'main' into antoine/additive-workflow
abey79 Jan 3, 2024
7abc998
Post merge fix
abey79 Jan 3, 2024
f04e032
Merge branch 'main' into antoine/additive-workflow
abey79 Jan 3, 2024
b353f65
Show icons for containers
abey79 Jan 3, 2024
044dfdf
Fix the interact rectangle computation
abey79 Jan 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added crates/re_ui/data/icons/add_big.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions crates/re_ui/src/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ pub const VISIBLE: Icon = Icon::new("visible", include_bytes!("../data/icons/vis
pub const INVISIBLE: Icon = Icon::new("invisible", include_bytes!("../data/icons/invisible.png"));

pub const ADD: Icon = Icon::new("add", include_bytes!("../data/icons/add.png"));

pub const ADD_BIG: Icon = Icon::new("add_big", include_bytes!("../data/icons/add_big.png"));
pub const REMOVE: Icon = Icon::new("remove", include_bytes!("../data/icons/remove.png"));

pub const RESET: Icon = Icon::new("reset", include_bytes!("../data/icons/reset.png"));
Expand Down
142 changes: 142 additions & 0 deletions crates/re_viewer/src/ui/add_space_view_or_container_modal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
//! Modal for adding a new space view of container to an existing target container.

use itertools::Itertools;

use re_log_types::{EntityPath, EntityPathFilter};
use re_space_view::DataQueryBlueprint;
use re_viewer_context::ViewerContext;
use re_viewport::{SpaceViewBlueprint, Viewport};

#[derive(Default)]
pub struct AddSpaceViewOrContainerModal {
target_container: Option<egui_tiles::TileId>,
modal_handler: re_ui::modal::ModalHandler,
}

impl AddSpaceViewOrContainerModal {
pub fn open(&mut self, target_container: egui_tiles::TileId) {
self.target_container = Some(target_container);
self.modal_handler.open();
}

pub fn ui(&mut self, ui: &mut egui::Ui, ctx: &ViewerContext<'_>, viewport: &Viewport<'_, '_>) {
self.modal_handler.ui(
ctx.re_ui,
ui,
|| re_ui::modal::Modal::new("Add Space View or Container"),
|_, ui, _| modal_ui(ui, ctx, viewport, self.target_container),
);
}
}

fn modal_ui(
ui: &mut egui::Ui,
ctx: &ViewerContext<'_>,
viewport: &Viewport<'_, '_>,
target_container: Option<egui_tiles::TileId>,
) {
ui.spacing_mut().item_spacing = egui::vec2(14.0, 10.0);

let container_data = [
(
"Tabs",
"Create a new tabbed container.",
egui_tiles::ContainerKind::Tabs,
),
(
"Horizontal",
"Create a new horizontal container.",
egui_tiles::ContainerKind::Horizontal,
),
(
"Vertical",
"Create a new vertical container.",
egui_tiles::ContainerKind::Vertical,
),
(
"Grid",
"Create a new grid container.",
egui_tiles::ContainerKind::Grid,
),
];

for (title, subtitle, kind) in container_data {
if row_ui(ui, &re_ui::icons::CONTAINER, title, subtitle).clicked() {
viewport.blueprint.add_container(kind, target_container);
viewport.blueprint.mark_user_interaction(ctx);
}
}

ui.separator();

// space view of any kind
for space_view in ctx
.space_view_class_registry
.iter_registry()
.sorted_by_key(|entry| entry.class.display_name())
.map(|entry| {
SpaceViewBlueprint::new(
entry.class.identifier(),
&format!("empty {}", entry.class.display_name()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming it "empty" immediately makes the name wrong as soon as you add content.

Maybe: "New {}"?

Better yet, we could make name optional -- if it's None then we could generate the name dynamically at runtime and otherwise we could use whatever the user has provided.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This default naming is becoming annoying :) #4669

&EntityPath::root(),
DataQueryBlueprint::new(entry.class.identifier(), EntityPathFilter::default()),
)
})
{
let icon = space_view.class(ctx.space_view_class_registry).icon();
let title = space_view
.class(ctx.space_view_class_registry)
.display_name();
let subtitle = format!("Create a new Space View to display {title} content.");

if row_ui(ui, icon, title, &subtitle).clicked() {
abey79 marked this conversation as resolved.
Show resolved Hide resolved
viewport
.blueprint
.add_space_views(std::iter::once(space_view), ctx, target_container);
viewport.blueprint.mark_user_interaction(ctx);
}
}
}

fn row_ui(ui: &mut egui::Ui, icon: &re_ui::Icon, title: &str, subtitle: &str) -> egui::Response {
ui.horizontal(|ui| {
//TODO(ab): move this to re_ui
//TODO(ab): use design token
let icon_size = egui::vec2(18.0, 18.0);
egui::Frame {
inner_margin: egui::Margin::symmetric(
(62. - icon_size.x) / 2.0,
(42. - icon_size.y) / 2.0,
), // should be 62x42 when combined with icon size
rounding: egui::Rounding::same(6.0),
fill: egui::Color32::from_gray(50),
..Default::default()
}
.show(ui, |ui| {
let (rect, _) = ui.allocate_exact_size(icon_size, egui::Sense::hover());
icon.as_image()
.tint(ui.visuals().widgets.active.fg_stroke.color)
.paint_at(ui, rect);
});

ui.vertical(|ui| {
ui.strong(title);
ui.add_space(-5.0);

ui.add(egui::Label::new(subtitle).wrap(false));
});

ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
ui.add(
egui::ImageButton::new(
re_ui::icons::ADD_BIG
.as_image()
.fit_to_exact_size(egui::vec2(24.0, 24.0)),
)
.tint(ui.visuals().widgets.inactive.fg_stroke.color),
)
})
.inner
})
.inner
}
2 changes: 1 addition & 1 deletion crates/re_viewer/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ mod selection_history_ui;
mod top_panel;
mod welcome_screen;

pub(crate) mod add_space_view_or_container_modal;
pub(crate) mod memory_panel;
pub(crate) mod selection_panel;

pub(crate) mod visible_history;

pub use blueprint_panel::blueprint_panel_ui;
Expand Down
89 changes: 54 additions & 35 deletions crates/re_viewer/src/ui/rerun_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,33 +196,9 @@ impl App {
}
});

#[cfg(not(target_arch = "wasm32"))]
{
if self.re_ui
.checkbox(ui, &mut self.state.app_options.experimental_space_view_screenshots, "(experimental) Space View screenshots")
.on_hover_text("Allow taking screenshots of 2D and 3D Space Views via their context menu. Does not contain labels.")
.clicked()
{
ui.close_menu();
}
}

if self
.re_ui
.checkbox(
ui,
&mut self.state.app_options.experimental_dataframe_space_view,
"(experimental) Dataframe Space View",
)
.on_hover_text("Enable the experimental dataframe space view.")
.clicked()
{
self.command_sender
.send_system(SystemCommand::EnableExperimentalDataframeSpaceView(
self.state.app_options.experimental_dataframe_space_view,
));
ui.close_menu();
}
ui.separator();
ui.label("Experimental:");
self.experimental_menu_options_ui(ui);

#[cfg(debug_assertions)]
{
Expand Down Expand Up @@ -331,6 +307,57 @@ impl App {
}
}

fn experimental_menu_options_ui(&mut self, ui: &mut egui::Ui) {
#[cfg(not(target_arch = "wasm32"))]
{
if self.re_ui
.checkbox(ui, &mut self.state.app_options.experimental_space_view_screenshots, "Enable Space View screenshots")
.on_hover_text("Allow taking screenshots of 2D and 3D Space Views via their context menu. Does not contain labels.")
.clicked()
{
ui.close_menu();
}
}

if self
.re_ui
.checkbox(
ui,
&mut self.state.app_options.experimental_dataframe_space_view,
"Enable the Dataframe Space View",
)
.on_hover_text("Enable the experimental dataframe space view.")
.clicked()
{
self.command_sender
.send_system(SystemCommand::EnableExperimentalDataframeSpaceView(
self.state.app_options.experimental_dataframe_space_view,
));
ui.close_menu();
}

self.re_ui
.checkbox(
ui,
&mut self.state.app_options.experimental_container_blueprints,
"Use container blueprints",
)
.on_hover_text("Load and save the container state using new container archetypes");

self.re_ui
.checkbox(
ui,
&mut self.state.app_options.experimental_additive_workflow,
"Enable the container addition workflow",
)
.on_hover_text(
"This flag enables the experimental container addition workflow, including:\n\
- Remove the automatic simplification of the container tree.\n\
- Add a 'Content' list in the selection panel when a container is selected.\n\
- Add the 'Add space view/container' modal, accessible from the selection panel.",
);
}

#[cfg(debug_assertions)]
fn debug_menu_options_ui(&mut self, ui: &mut egui::Ui) {
#[cfg(not(target_arch = "wasm32"))]
Expand Down Expand Up @@ -363,14 +390,6 @@ impl App {
)
.on_hover_text("Show the Blueprint data in the Time Panel tree view. This is useful for debugging the internal blueprint state.");

self.re_ui
.checkbox(
ui,
&mut self.state.app_options.experimental_container_blueprints,
"Use experimental container blueprints",
)
.on_hover_text("Load and save the container state using new container archetypes");

ui.menu_button("Crash", |ui| {
#[allow(clippy::manual_assert)]
if ui.button("panic!").clicked() {
Expand Down
Loading
Loading