-
Notifications
You must be signed in to change notification settings - Fork 373
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
Context Menu 1: Basic scaffolding and simple actions #5163
Conversation
d9bf94b
to
6379750
Compare
75be468
to
6440ed8
Compare
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.
The context menu allows you now to hide the top level container, something that isn't possible via a button and has no visual feedback.
More shockingly, you can also remove it and then not add a new one anymore 😱
🤦🏻 |
9309f41
to
4b5e470
Compare
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.
Great start for context menus! I like the overall structure; left only a few thoughts, can go in as-is imho :)
|
||
/// Trait for things that can populate a context menu | ||
trait ContextMenuItem { | ||
//TODO(ab): should probably return `egui::WidgetText` instead |
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.
so.. why not? :)
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.
That comment is actually wrong. The end-game is to return a ListItem
(with all the fanciness that comes with it: nicer look, icon, etc.). Both ListItem
and the egui context menu code needs a bit of a overhaul for this to work though, so it'll come as a follow-up.
} | ||
|
||
// ================================================================================================ | ||
// Utility items |
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.
guess it's a matter of taste but I would have started a subfolder for context menu with modules for each of these item categories
It looks pretty much like this gonna be another thing where one dynamically registers elements, so might as well already structure it like one
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.
Good point. I'll do that in a follow up PR to avoid too many rebasing annoying with my existing follow-up.
/// Trait for things that can populate a context menu | ||
trait ContextMenuItem { | ||
//TODO(ab): should probably return `egui::WidgetText` instead | ||
fn label(&self, _ctx: &ViewerContext<'_>, _viewport_blueprint: &ViewportBlueprint) -> String { |
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.
Just a label is a bit little though? Should add icons in a follow-up pr so we can show the familiar space view and layout icons - they are much faster to parse than text
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.
Yup—see my other comment.
### What * Follow up to #5163 * Part of #4823 <img width="260" alt="image" src="https://github.com/rerun-io/rerun/assets/49431240/f911f4ca-a33e-4e7a-85a9-80f126148be4"> <br/> <br/> This PR adds support for multiple selection with context menus in blueprint view. The selection logic is as follows: - If the (right-)clicked item is part of the selection, the context menu actions apply to the entire selection. - Otherwise, the selection is set to the clicked item, and the context menu actions apply to that item only. This PR doesn't introduce any new action, but adjust the existing ones to handle multi-selection: - If only space views and/or containers are selected, the visibility toggle and Remove actions are offered. The visible toggle will offer to show if one or more items are currently hidden, and hide if all are currently visible. If the root container is part of the multi-selection, its is ignored by those actions. - The "Add SV/Container" actions are offered only if exactly one container item is selected. TODO in future PR: - additional actions - entity level manipulations - use ListItem instead of label/WidgetText - better folder structure - release checklist update ### 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/5205/index.html) * Using examples from latest `main` build: [app.rerun.io](https://app.rerun.io/pr/5205/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/5205/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](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! - [PR Build Summary](https://build.rerun.io/pr/5205) - [Docs preview](https://rerun.io/preview/291a52d41703e7e70f1de7d905754ff6ac46cdcb/docs) <!--DOCS-PREVIEW--> - [Examples preview](https://rerun.io/preview/291a52d41703e7e70f1de7d905754ff6ac46cdcb/examples) <!--EXAMPLES-PREVIEW--> - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
What
This PR is the first of a series to implement context menus in the Blueprint Tree. Here we setup the basic scaffolding and implement some basic actions:
The selection is currently ignore and the actions only apply to the clicked item. TODO in future PRs:
Checklist
main
build: app.rerun.ionightly
build: app.rerun.io