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

ListItem 2.0 (part 5): deploy to the Visualizers and Overrides UIs #6184

Merged
merged 7 commits into from
May 3, 2024

Conversation

abey79
Copy link
Member

@abey79 abey79 commented May 1, 2024

What

This PR deploys list_item2 to the visualizer and overrides UI currently used for timeseries spaces views.

Unsurprisingly, contact with the real world required some adjustments:

  • It's useful to be able to mix and match LabelContent and PropertyContent. The following changes were needed for that to look nice:
  • Now the left column width is computed based on the total width actually allocated by ListItem (as opposed to ui.max_rect() as seen from list_item_scope). This is more correct when the list is in a horizontal scroll area and fixes related visual glitches.

This PR also fixes the ShapeMarker editor UI, but required a workaround due to ui.max_rect() behaving weird when the ComboBox menu expends due to its contents.

image

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!

To run all checks from main, comment on the PR with @rerun-bot full-check.

@abey79 abey79 added ui concerns graphical user interface include in changelog labels May 1, 2024
@abey79 abey79 force-pushed the antoine/li4-no-act-btn branch from 8bd03cc to cd0d0ab Compare May 2, 2024 14:18
Base automatically changed from antoine/li4-no-act-btn to main May 2, 2024 14:37
@abey79 abey79 force-pushed the antoine/li5-viz-ovrd-ui branch from 31f971d to f5c5132 Compare May 2, 2024 14:40
@abey79 abey79 changed the title [WIP] ListItem 2.0 (part 5): deploy to the Visualizers and Overrides UIs ListItem 2.0 (part 5): deploy to the Visualizers and Overrides UIs May 2, 2024
@abey79 abey79 marked this pull request as ready for review May 2, 2024 18:33
@abey79 abey79 marked this pull request as draft May 2, 2024 18:54
@abey79 abey79 marked this pull request as ready for review May 2, 2024 19:13
@abey79 abey79 mentioned this pull request May 2, 2024
11 tasks
Comment on lines +268 to +269
// workaround to force `ui.max_rect()` to reflect the content size
ui.allocate_space(egui::vec2(item_width, 0.0));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// workaround to force `ui.max_rect()` to reflect the content size
ui.allocate_space(egui::vec2(item_width, 0.0));
// workaround to force `ui.max_rect()` to reflect the content size
ui.set_width(item_width);

Copy link
Member

Choose a reason for hiding this comment

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

I see that the doscstring of ComboBox::width claims it sets the with of the menu… but it doesn't. We should fix that.

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 think it's slightly more complicated than that, if I understand correctly. In my code, the width of the combobox itself can shrink a lot when squeezed: .width(ui.available_width().at_most(100.0)). The menu width correctly set to that size. The issue is when the menu content is larger than the provided width. In that case, the menu visually expends to accommodate its content, but doesn't reflect that in the closure's ui.available_width(), which remains stuck to combobox.width - inner_margins.

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'll try to have a repro and open an issue in egui.

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +283 to +294
let response = ctx
.re_ui
.list_item2()
.selected(edit_marker == marker)
.show_flat(
ui,
re_ui::list_item2::LabelContent::new(marker.to_string())
.min_desired_width(item_width)
.with_icon_fn(|_re_ui, ui, rect, visuals| {
paint_marker(ui, marker.into(), rect, visuals.text_color());
}),
);
Copy link
Member

Choose a reason for hiding this comment

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

This exploded in line-count quite a bit… I wonder if there is anything we can do to improve 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 can't immediately think of one.

One area to think about is to have some DataUi like thing that would make our data objects somehow capable of producing impl ListItemContent. If MarkerShape had this behaviour, it could be passed directly (or as marker.as_content() or sth) to .show_flat. I think we do need some hindsight to be able to design such a system, though.

Comment on lines +271 to +280
let background_x_range = ui
.spacing()
.menu_margin
.expand_rect(ui.max_rect())
.x_range();

re_ui::list_item2::list_item_scope(
ui,
"marker_shape",
Some(background_x_range),
Copy link
Member

Choose a reason for hiding this comment

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

we could make a re_ui::combo_box helper that also did this

Copy link
Member Author

@abey79 abey79 May 3, 2024

Choose a reason for hiding this comment

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

Yes. I want all of our popup menu, context menu, etc. to be reimplemented and styled after list item:

I would certainly welcome your input in this area, especially around the menu logics that currently relies on custom egui::Ui function IIRC.

crates/re_ui/src/list_item2/scope.rs Show resolved Hide resolved
crates/re_viewer/src/ui/override_ui.rs Show resolved Hide resolved
crates/re_data_ui/src/editors.rs Show resolved Hide resolved
@abey79
Copy link
Member Author

abey79 commented May 3, 2024

Review comment addressed in #6211

@abey79 abey79 merged commit 0ac38a4 into main May 3, 2024
34 checks passed
@abey79 abey79 deleted the antoine/li5-viz-ovrd-ui branch May 3, 2024 14:48
abey79 added a commit that referenced this pull request May 3, 2024
abey79 added a commit that referenced this pull request May 6, 2024
…ted module (#6211)

### What

So far, the full span x coordinate rang needed for highlighting was
maintained by `LayoutInfo` and `list_item_scope`. However, other widgets
also need this mechanism. This PR splits of full-span management to a
dedicated module, and deploys it both in `re_ui_example` and where
`list_item2` is currently used.

Other changes:
- This PR also improves the sanity checks regarding both
`list_item_scope` and `full_span_scope`. When missing, debug build will
panic and release build will emit warnings.
- Both scopes are now `ui.scope()`, so it's safe to modify `ui.style()`
from the closure.
- `list_item_scope` now sets `ui.spacing().item_spacing.y = 0`, since
this is required anyway for `ListItem`s to look good.

Follow-up PR will be needed to deploy `full_span` to all relevant
widgets and their use in the viewer (#6156).

- Part of #6075 
- Part of #6156
- Follow-up to #6184

### 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 examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6211?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6211?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/6211)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include in changelog ui concerns graphical user interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MarkerShape menu has massive visual glitch ComponentOverride ListItem uses left-side "remove" buttons
2 participants