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

Better integration of ListItem in tooltips and other popups #6486

Merged
merged 14 commits into from
Jun 11, 2024

Conversation

emilk
Copy link
Member

@emilk emilk commented Jun 3, 2024

What

This PR lets us put any ListItem anywhere without trouble.

This is because of two things:

  • ListItem understands the concept of an egui sizing pass, so won't expand to become huge when in a tooltip
  • LabelContent and PropertyContent can tell when it is in a tooltip, and in these cases won't truncate the contents

image

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.

@emilk emilk added blocked can't make progress right now ui concerns graphical user interface labels Jun 3, 2024
@emilk emilk force-pushed the emilk/prevent-list-item-expansion branch from d9d0781 to d8f8f2b Compare June 5, 2024 14:42
@emilk emilk force-pushed the emilk/prevent-list-item-expansion branch from c8cc940 to 805811f Compare June 5, 2024 14:45
abey79 added 2 commits June 6, 2024 10:03
# Conflicts:
#	crates/re_data_ui/src/item_ui.rs
#	crates/re_time_panel/src/lib.rs
#	crates/re_ui/src/lib.rs
#	crates/re_ui/src/list_item/label_content.rs
#	crates/re_ui/src/list_item/list_item.rs
#	crates/re_ui/src/list_item/mod.rs
@emilk emilk added the exclude from changelog PRs with this won't show up in CHANGELOG.md label Jun 10, 2024
@emilk emilk removed the blocked can't make progress right now label Jun 10, 2024
Comment on lines -148 to -151
// avoid the list item to max the tooltip width
if ui_layout == UiLayout::Tooltip {
content = content.exact_width(true);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is now detected automagically by PropertyContent

@@ -626,7 +626,7 @@ impl TimePanel {
ctx,
&InstancePath::from(tree.path.clone()),
))
.exact_width(true),
.truncate(false),
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 yet magically detect that we are in the time panel, so we still need to tell the contents not to truncate here

@@ -417,8 +417,7 @@ pub fn component_path_button_to(
} else {
"Temporal component"
})
.with_icon(icon)
.exact_width(true),
Copy link
Member Author

Choose a reason for hiding this comment

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

again, the contents magically knows not to truncate when in a tooltip

@emilk emilk marked this pull request as ready for review June 10, 2024 18:40
@emilk emilk changed the title Better integration of ListItem in tooltips Better integration of ListItem in tooltips and other popups Jun 10, 2024
Comment on lines 92 to 94
/// Used as a heuristic to figure out if it is safe to truncate text.
///
/// If this returns false, we should never truncate.
Copy link
Member

Choose a reason for hiding this comment

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

If this returns false, we should never truncate.

Double-negative. Would be easier to follow as "If this returns true, we should truncate text when necessary."

The rationale coupling this description to the name of the function still isn't totally obvious. Even if a panel is not resizable, if the text is much longer than the available (non-resizable) panel size, it seems like truncation could be necessary.

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 expanded the docstring to clarify

@emilk emilk merged commit 8a46ab7 into main Jun 11, 2024
34 checks passed
@emilk emilk deleted the emilk/prevent-list-item-expansion branch June 11, 2024 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exclude from changelog PRs with this won't show up in CHANGELOG.md ui concerns graphical user interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't truncate ListItem in tooltips
3 participants