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

More context menu 1: refactor #5392

Merged
merged 5 commits into from
Mar 5, 2024
Merged

More context menu 1: refactor #5392

merged 5 commits into from
Mar 5, 2024

Conversation

abey79
Copy link
Member

@abey79 abey79 commented Mar 5, 2024

What

More like a rewrite actually. This PR completely reorganise the way context menu actions are written and executed with two goals:

  • Keep the complexity in check: the previous summarize_selection mechanism was exposed to combinatorial explosion of possible item subset.
  • Improve locality: every details of if/when/how an action is displayed and run is now local to the action impls, not dispatched in various functions such as summarize_selection etc.

All in all, this should ensure a O(1) effort to add new actions.

@ Reviewer: with the renames and rewrite, the diff a probably useless and this PR is best reviewed by directly looking at context_menu/*.rs.

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG
  • If applicable, add a new check to the release checklist!

@abey79 abey79 added 🚜 refactor Change the code, not the functionality include in changelog labels Mar 5, 2024
@Wumpf Wumpf self-requested a review March 5, 2024 09:30
Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

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

neat framework, was fairly easy to follow which is a good sign (:

crates/re_viewport/src/viewport_blueprint_ui.rs Outdated Show resolved Hide resolved
crates/re_viewport/src/context_menu/mod.rs Show resolved Hide resolved
///
/// The default implementation delegates to [`Self::supports_multi_selection`] and
/// [`Self::supports_item`].
fn supports_selection(&self, ctx: &ContextMenuContext<'_>) -> bool {
Copy link
Member

Choose a reason for hiding this comment

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

kinda surprised there's only support and not a disable/enabled option. I suppose this could be later extended to return an enum that distinguises this

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what you refer to by disabled/enabled? Bi-stable actions (like "Hide/Show"—which is now split into two separate actions btw)? Or actually displaying the action as disabled in the context menu (as opposed to no showing it at all)?

Copy link
Member

Choose a reason for hiding this comment

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

it looks like this hasn't come up yet, but I'd expect us to very soon have items that are displayed but disabled/greyed out because of some reason

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess. Well, it'll be easy to switch to an enum then :)

crates/re_viewport/src/context_menu/mod.rs Show resolved Hide resolved
@abey79 abey79 merged commit 9d0d2a3 into main Mar 5, 2024
34 checks passed
@abey79 abey79 deleted the antoine/mcm1-refactor branch March 5, 2024 11:50
abey79 added a commit that referenced this pull request Mar 7, 2024
…5411)

### What

As the title says ☝🏻 

* Fixes #5299

Also adds a "no action available for this selection" notice that got
lost in #5392.

Makes it very easy to bump into:
- #5410


https://github.com/rerun-io/rerun/assets/49431240/d3bafbf4-3755-4f6f-b236-bd1d022b172f


#### Design decisions

- The origin of the newly created space view is set to "/"
- Alternative 1: set it to the clicked item. Strong reject: too arcane,
different results for the same multi-selection depending on which item
is actually clicked.
- Alternative 2: set it to the common ancestor of all selected entities.
Weak reject: less predictable, occasionally wrong (but works around some
visualisable issue we have with some space views).
- We show a list of suggested space view classes.
- The list is the *intersection* of the suggested classes for each of
the selected entities.
- For each entity, the suggested classes are determined based on the
*union* of suggested classes for the entity itself, *and for every
entity of its subtree*. This enables meaningful suggestion when
selecting a pure TreePrefix.
- The newly created space view is selected.

#### Known "phenomenons"

- 2D space views are rarely suggested, because of the origin is set to
"/" and that's outside of a pinhole transform.
  - TODO: issue number?
- Text Document and Text Log are often suggested for time series scalar,
because of the `Text` document.
- Tensor is recommended but will (sometime?) display nothing, e.g.
`structure_from_motion` -> `/camera/image`
- If enabled, Dataframe is always the top-most suggested Space View,
because of the lexicographic sorting.

### 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/5411/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5411/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/5411/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/5411)
- [Docs
preview](https://rerun.io/preview/979f2768f87bd3e72b45c80ffd319b56661f138e/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/979f2768f87bd3e72b45c80ffd319b56661f138e/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
@abey79 abey79 mentioned this pull request Mar 11, 2024
5 tasks
abey79 added a commit that referenced this pull request Mar 12, 2024
### What

NOTE: review commit by commit (first commit is pure refactoring).

Final PR in the series. This PR:
- split `actions.rs` into many sub-files
- fix capitalisation in some menu item
- split the release check list in small checks

Full series:
- #5392
- #5397
- #5407
- #5411
- #5422
- #5433
- #5456

### 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/5456/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5456/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/5456/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/5456)
- [Docs
preview](https://rerun.io/preview/a36360f586494f6648fdc4bbb9d806ab12911358/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/a36360f586494f6648fdc4bbb9d806ab12911358/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include in changelog 🚜 refactor Change the code, not the functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants