-
Notifications
You must be signed in to change notification settings - Fork 373
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
Limit the size of component tooltips with UiVerbosity::Reduced
#3171
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
711e3ab
Limit the size of component tooltips with `UiVerbosity::Reduced`
abey79 025fe53
Set horizontal auto shrink to true for component table
abey79 aebe480
Update crates/re_data_ui/src/component.rs
abey79 9a44dbf
PR comments
abey79 9290ba7
Lints...
abey79 1d32ac0
Comment to explain what's going on
abey79 35244cb
Fixed panic with `UiVerbosity::Small`
abey79 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,3 +1,4 @@ | ||||||||||||||||||||||||||
use egui::NumExt; | ||||||||||||||||||||||||||
use re_data_store::{EntityPath, InstancePath}; | ||||||||||||||||||||||||||
use re_query::ComponentWithInstances; | ||||||||||||||||||||||||||
use re_types::ComponentName; | ||||||||||||||||||||||||||
|
@@ -44,6 +45,20 @@ impl DataUi for EntityComponentWithInstances { | |||||||||||||||||||||||||
UiVerbosity::Reduced | UiVerbosity::All => false, | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// in some cases, we don't want to display all instances | ||||||||||||||||||||||||||
let max_row = match verbosity { | ||||||||||||||||||||||||||
UiVerbosity::Small => 0, | ||||||||||||||||||||||||||
UiVerbosity::Reduced => num_instances.at_most(4), // includes "…x more" if any | ||||||||||||||||||||||||||
UiVerbosity::All => num_instances, | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
let displayed_row = if num_instances <= max_row { | ||||||||||||||||||||||||||
num_instances | ||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||
// this accounts for the "…x more" using a row | ||||||||||||||||||||||||||
max_row - 1 | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if num_instances == 0 { | ||||||||||||||||||||||||||
ui.weak("(empty)"); | ||||||||||||||||||||||||||
} else if num_instances == 1 { | ||||||||||||||||||||||||||
|
@@ -69,7 +84,7 @@ impl DataUi for EntityComponentWithInstances { | |||||||||||||||||||||||||
egui_extras::TableBuilder::new(ui) | ||||||||||||||||||||||||||
.resizable(false) | ||||||||||||||||||||||||||
.vscroll(true) | ||||||||||||||||||||||||||
.auto_shrink([false, true]) | ||||||||||||||||||||||||||
.auto_shrink([true, true]) | ||||||||||||||||||||||||||
.max_scroll_height(100.0) | ||||||||||||||||||||||||||
.cell_layout(egui::Layout::left_to_right(egui::Align::Center)) | ||||||||||||||||||||||||||
.columns(egui_extras::Column::auto(), 2) | ||||||||||||||||||||||||||
|
@@ -85,7 +100,7 @@ impl DataUi for EntityComponentWithInstances { | |||||||||||||||||||||||||
.body(|mut body| { | ||||||||||||||||||||||||||
re_ui::ReUi::setup_table_body(&mut body); | ||||||||||||||||||||||||||
let row_height = re_ui::ReUi::table_line_height(); | ||||||||||||||||||||||||||
body.rows(row_height, num_instances, |index, mut row| { | ||||||||||||||||||||||||||
body.rows(row_height, displayed_row, |index, mut row| { | ||||||||||||||||||||||||||
if let Some(instance_key) = instance_keys.get(index) { | ||||||||||||||||||||||||||
row.col(|ui| { | ||||||||||||||||||||||||||
let instance_path = | ||||||||||||||||||||||||||
|
@@ -112,6 +127,12 @@ impl DataUi for EntityComponentWithInstances { | |||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
if num_instances > displayed_row { | ||||||||||||||||||||||||||
ui.label(format!( | ||||||||||||||||||||||||||
"…and {} more.", | ||||||||||||||||||||||||||
re_format::format_large_number((num_instances - displayed_row) as _) | ||||||||||||||||||||||||||
)); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
Comment on lines
+147
to
+152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 we can simplify this a lot:
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.
My behaviour (4 rows is strictly respected):
Your behaviour (4 rows is not respected and the "...1 more" feels weird as you might as well put the corresponding item there):
The key difference is the
max_row - 1
in my code.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.
As discussed, I updated the docs.
And luckily I just experienced the panic-inducing case of
max_row = 0
(=>max_row - 1
panics) and fixed it.