-
Notifications
You must be signed in to change notification settings - Fork 376
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
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 b1e4924
Add a "simplify hierarchy" button to containers
abey79 7c048b5
Blueprint tree UI: only hide a single-child container if it's a `Cont…
abey79 59ea714
Container selection panel: add children list
abey79 b2a33a7
Rebase fix to "simplify hierarchy" button
abey79 54c53db
Add SV/Container modal
abey79 2141a4e
Fix to the "simplify container" feature
abey79 b36328d
Gate everything in the container selection panel behind container blu…
abey79 1b377ac
WIP: wiring up everything via tree actions
abey79 e9dc8d5
Rebase fixes
abey79 2ca0749
Added a feature flag + various clean-ups
abey79 425f38c
Moved feature flag to new "Experimental" section in option menu + bun…
abey79 c655ae3
Improved copy in the experimental menu
abey79 41bf606
Rebase fix
abey79 8ac5e31
Get rid of unnessary mutable logic
jleibs 91ee54d
Made the entire row clickable and fix the bad hover background on the…
abey79 c1064fd
Merge branch 'main' into antoine/additive-workflow
abey79 a1877e0
Merge branch 'main' into antoine/additive-workflow
abey79 7abc998
Post merge fix
abey79 f04e032
Merge branch 'main' into antoine/additive-workflow
abey79 b353f65
Show icons for containers
abey79 044dfdf
Fix the interact rectangle computation
abey79 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
crates/re_viewer/src/ui/add_space_view_or_container_modal.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()), | ||
&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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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