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 2): introduce PropertyContent for two-column, property-like list items #6174

Merged
merged 2 commits into from
May 2, 2024

Conversation

abey79
Copy link
Member

@abey79 abey79 commented Apr 30, 2024

What

This PR introduced the PropertyContent, an implementation of ListItemContent for two-column list item, with a label and flexible "values". Currently only demonstrated in re_ui_example.

What the "value" displays is delegated to a user-provided closure. However, PropertyContent provides helper for a few basic types: bool, text, color (both read-only and editable).

Export-1714484618553.mp4

Limitations and todo

  • Columns are fixed size at 50%. They will be made smart in the next PR.
  • More helpers are needed for various kinds of values.
  • There can be only 0 or 1 action button. This should be extended by using a button with some kind of popup with all available actions in a future PR.
  • Right gutter space is reserved for the action button even if no list item in scope use them. The list_item_scope could track this and skip reserving that space if it's never used (e.g. component list in entity path selection panel): PropertyContent: do not allocate space for acton button if no action button is ever used in the scope #6179

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 include in changelog ui concerns graphical user interface labels Apr 30, 2024
@abey79 abey79 force-pushed the antoine/li1-basic branch from d00fcd8 to 413bf46 Compare May 1, 2024 06:55
@abey79 abey79 force-pushed the antoine/li2-prop branch from a5d545a to 6705aef Compare May 1, 2024 06:55
Comment on lines +271 to +276
// Make a union of all (possibly) interactive elements
match (value_response, button_response) {
(Some(a), Some(b)) => Some(a | b),
(Some(a), None) | (None, Some(a)) => Some(a),
(None, None) => None,
}
Copy link
Member Author

@abey79 abey79 May 1, 2024

Choose a reason for hiding this comment

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

#6182 removes the return value entirely.

Comment on lines +11 to +12
type PropertyValueFn<'a> =
dyn FnOnce(&ReUi, &mut egui::Ui, egui::style::WidgetVisuals) -> Option<egui::Response> + 'a;
Copy link
Member Author

@abey79 abey79 May 1, 2024

Choose a reason for hiding this comment

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

#6182 removes the return value as well, as its used was only to be forwarded to ListItemContent::ui(), which no longer needs it.

let visual_size = egui::vec2(12.0, 8.0); // 12x7 in figma, but 12x8 looks _much_ better in epaint
let visual_rect =
egui::Align2::CENTER_CENTER.align_size_within_rect(visual_size, interact_rect);
fn toggle_switch_ui(ui: &mut egui::Ui, height: f32, on: &mut bool) -> egui::Response {
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't all our toggle switches have the same height, everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't use it at all in rerun yet, but at least in re_ui_example I used it twice in contexts that very specifically call for a different size:

image image

@abey79
Copy link
Member Author

abey79 commented May 2, 2024

All review comment (except toggle size) addressed in #6183

abey79 added a commit that referenced this pull request May 2, 2024
Base automatically changed from antoine/li1-basic to main May 2, 2024 13:38
@abey79 abey79 force-pushed the antoine/li2-prop branch from 6705aef to 75d14f8 Compare May 2, 2024 13:40
@abey79 abey79 merged commit 9f6add2 into main May 2, 2024
34 checks passed
@abey79 abey79 deleted the antoine/li2-prop branch May 2, 2024 14:07
abey79 added a commit that referenced this pull request May 2, 2024
### What

This PR:
- Implements column auto-sizing for `PropertyContent`. The current
heuristics is rather simple and will likely need improvement when it's
battle tested. Currently, the content requests a minimum width of 200px
(there really isn't a way to properly deal with two-column-plus-button
neatly all the way to 0 width), and allocate a maximum of 70% of the
available width to the label column.
- Improves the way `ListItem` handles content capturing the hover state
(which happen for interactive content). There is no longer a requirement
for `ListItemContent::ui()` to return an `Option<Response>`, which
simplifies a bunch of things.
- Updates `re_ui_example` accordingly

Note: still no change applied to the actual viewer code base so far.

- Part of #6075 
- Follow-up to #6174

<img width="502" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/28322870-997c-4bf4-997f-d0e7c8da2da9">

### Limitations and todo

- Improved heuristics for column sizing, when we have a better idea of
the need.
- More helpers are needed for various kinds of values.
- There can be only 0 or 1 action button. This should be extended by
using a `…` button with some kind of popup with all available actions in
a future PR.
- Right gutter space is reserved for the action button even if no list
item in scope use them. The `list_item_scope` could track this and skip
reserving that space if it's never used (e.g. component list in entity
path selection panel): #6179


### 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/6182?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/6182?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/6182)
- [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`.
abey79 added a commit that referenced this pull request May 2, 2024
abey79 added a commit that referenced this pull request May 2, 2024
…ons when needed (#6183)

### What

☝🏻 

This PR also slightly adjust the semantics of the `id` parameter of
`list_item_scope()`. Now it just needs to be unique within the current
UI. It also addresses review comments from #6161, #6174, and #6182.

- Part of #6075
- Follow-up to #6182
- Fixes #6179


![Export-1714577757563](https://github.com/rerun-io/rerun/assets/49431240/45cb8284-15a9-4100-8057-bd7fd994d008)
<br/>

Note: the upper group of (nested) items (which makes use of action
buttons) has no impact on the lower group, because both sub-groups are
in a distinct `list_item_scope`.

### 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/6183?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/6183?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/6183)
- [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.

2 participants