Skip to content

Commit

Permalink
Do not allow adding Horizontal/Vertical containers inside of containe…
Browse files Browse the repository at this point in the history
…rs with the same type (#5091)

### What

- Fixes #5082

*Note*: due to emilk/egui#3997, the tooltip
shows up immediately, which is slightly annoying.

<img width="1898" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/ef64fa2f-7a5b-41f0-aec5-31b2e55c8efc">

<img width="681" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/5ace80d5-eb49-4a1e-9440-6debb54d7d4f">


### 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 newly built examples:
[app.rerun.io](https://app.rerun.io/pr/5091/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5091/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/5091/index.html?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](tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/5091)
- [Docs
preview](https://rerun.io/preview/57a22b0a289369057acc1000af69df20df9e3d23/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/57a22b0a289369057acc1000af69df20df9e3d23/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
abey79 authored Feb 7, 2024
1 parent ef0557e commit 72681e1
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion crates/re_viewport/src/add_space_view_or_container_modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use itertools::Itertools;

use crate::container::blueprint_id_to_tile_id;
use crate::{icon_for_container_kind, ViewportBlueprint};
use re_log_types::{EntityPath, EntityPathFilter};
use re_space_view::{DataQueryBlueprint, SpaceViewBlueprint};
Expand Down Expand Up @@ -70,7 +71,34 @@ fn modal_ui(
];

for (title, subtitle, kind) in container_data {
if row_ui(ui, icon_for_container_kind(&kind), title, subtitle).clicked() {
let target_container_kind = target_container
.and_then(|container_id| {
viewport
.tree
.tiles
.get(blueprint_id_to_tile_id(&container_id))
})
.and_then(|tile| tile.container_kind());

// We disallow creating "linear" containers (horizontal/vertical) inside containers of the same kind, because
// it's not useful and is automatically simplified away.
let disabled = Some(kind) == target_container_kind
&& matches!(
kind,
egui_tiles::ContainerKind::Horizontal | egui_tiles::ContainerKind::Vertical
);

let resp = ui
.add_enabled_ui(!disabled, |ui| {
row_ui(ui, icon_for_container_kind(&kind), title, subtitle)
})
.inner
.on_disabled_hover_text(format!(
"Nested {title} containers in containers of the same type are disallowed and automatically simplified \
away as they are not useful."
));

if resp.clicked() {
viewport.add_container(kind, target_container);
viewport.mark_user_interaction(ctx);
*keep_open = false;
Expand Down

0 comments on commit 72681e1

Please sign in to comment.