-
Notifications
You must be signed in to change notification settings - Fork 366
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
Conversation
8bd03cc
to
cd0d0ab
Compare
31f971d
to
f5c5132
Compare
…ployment to viZ/overrides UI
ListItem
2.0 (part 5): deploy to the Visualizers and Overrides UIsListItem
2.0 (part 5): deploy to the Visualizers and Overrides UIs
// workaround to force `ui.max_rect()` to reflect the content size | ||
ui.allocate_space(egui::vec2(item_width, 0.0)); |
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.
// 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); |
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.
I see that the doscstring of ComboBox::width
claims it sets the with of the menu… but it doesn't. We should fix that.
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.
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
.
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.
I'll try to have a repro and open an issue in egui.
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.
Here: emilk/egui#4452
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()); | ||
}), | ||
); |
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 exploded in line-count quite a bit… I wonder if there is anything we can do to improve this
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.
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.
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), |
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.
we could make a re_ui::combo_box
helper that also did this
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.
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.
Review comment addressed in #6211 |
…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`.
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:
LabelContent
andPropertyContent
. The following changes were needed for that to look nice:min_desired_width
.LabelContent
now has aalways_show_buttons
option that perma-displays the buttons. This makes it easy to emulatePropertyContent
's action button. This could be improved: List item:LabelContent
should be able to have the exact same action button and behaviour asPropertyContent
#6203ListItem
(as opposed toui.max_rect()
as seen fromlist_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.ListItem
2.0 (part 4): only allocate space for property action buttons when needed #6183Checklist
main
build: rerun.io/viewernightly
build: rerun.io/viewerTo run all checks from
main
, comment on the PR with@rerun-bot full-check
.