Skip to content

Commit

Permalink
Use list_item for the component list in InstancePath::data_ui (#6309
Browse files Browse the repository at this point in the history
)

### What

- Fixes #4161
- Follow up to #6297
- Follow up to #6325

This PR uses `list_item` for the component list in the entity path
selection panel and tooltip.

~~Blocked by emilk/egui#4471 to resolve the
tooltip "first frame flicker"~~

TODO:
- [x] ⚠️ full_span_scope panic on hover on spatial space view:
#6246


#### selection panel

before:

<img width="519" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/afa51449-d7bf-4c0c-9d57-0ac25fedcf9f">


after:

<img width="345" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/1b524065-f5c0-4834-83ab-bc6b5f83ec37">


*Note*: the hover behaviour is the biggest change here: now full span,
previously just on the left-column button

#### tooltip

before:

<img width="511" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/cecb2337-4124-43ed-8b24-b895e71c3b26">

after:
<img width="510" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/4adb5113-898d-4585-be56-876d83b7694a">


### 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/6309?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/6309?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/6309)
- [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`.
  • Loading branch information
abey79 authored Jun 4, 2024
1 parent d7c7237 commit aaf9d5e
Show file tree
Hide file tree
Showing 15 changed files with 246 additions and 205 deletions.
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5274,6 +5274,7 @@ dependencies = [
"bytemuck",
"egui",
"egui-wgpu",
"egui_extras",
"egui_tiles",
"glam",
"half 2.3.1",
Expand Down
18 changes: 10 additions & 8 deletions crates/re_data_ui/src/annotation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use re_types::datatypes::{
};
use re_viewer_context::{auto_color, UiLayout, ViewerContext};

use super::{data_label_for_ui_layout, label_for_ui_layout, table_for_ui_layout, DataUi};
use super::DataUi;

impl crate::EntityDataUi for re_types::components::ClassId {
fn entity_data_ui(
Expand All @@ -32,7 +32,7 @@ impl crate::EntityDataUi for re_types::components::ClassId {
text.push(' ');
text.push_str(label.as_str());
}
label_for_ui_layout(ui, ui_layout, text);
ui_layout.label(ui, text);
});

let id = self.0;
Expand All @@ -54,7 +54,7 @@ impl crate::EntityDataUi for re_types::components::ClassId {
}
}
} else {
label_for_ui_layout(ui, ui_layout, format!("{}", self.0));
ui_layout.label(ui, format!("{}", self.0));
}
}
}
Expand All @@ -79,10 +79,10 @@ impl crate::EntityDataUi for re_types::components::KeypointId {
text.push_str(label.as_str());
}

data_label_for_ui_layout(ui, ui_layout, text);
ui_layout.data_label(ui, text);
});
} else {
data_label_for_ui_layout(ui, ui_layout, format!("{}", self.0));
ui_layout.data_label(ui, format!("{}", self.0));
}
}
}
Expand Down Expand Up @@ -128,7 +128,7 @@ impl DataUi for AnnotationContext {
} else {
format!("{} classes", self.0.len())
};
label_for_ui_layout(ui, ui_layout, text);
ui_layout.label(ui, text);
}
UiLayout::SelectionPanelLimitHeight | UiLayout::SelectionPanelFull => {
ui.vertical(|ui| {
Expand Down Expand Up @@ -208,7 +208,8 @@ fn class_description_ui(
ui.push_id(format!("keypoints_connections_{}", id.0), |ui| {
use egui_extras::Column;

let table = table_for_ui_layout(ui_layout, ui)
let table = ui_layout
.table(ui)
.cell_layout(egui::Layout::left_to_right(egui::Align::Center))
.column(Column::auto().clip(true).at_least(40.0))
.column(Column::auto().clip(true).at_least(40.0));
Expand Down Expand Up @@ -276,7 +277,8 @@ fn annotation_info_table_ui(

use egui_extras::Column;

let table = table_for_ui_layout(ui_layout, ui)
let table = ui_layout
.table(ui)
.cell_layout(egui::Layout::left_to_right(egui::Align::Center))
.column(Column::auto()) // id
.column(Column::auto().clip(true).at_least(40.0)) // label
Expand Down
5 changes: 3 additions & 2 deletions crates/re_data_ui/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use re_types::ComponentName;
use re_ui::SyntaxHighlighting as _;
use re_viewer_context::{UiLayout, ViewerContext};

use super::{table_for_ui_layout, DataUi};
use super::DataUi;
use crate::item_ui;

/// All the values of a specific [`re_log_types::ComponentPath`].
Expand Down Expand Up @@ -145,7 +145,8 @@ impl DataUi for EntityLatestAtResults {
} else if one_line {
ui.label(format!("{} values", re_format::format_uint(num_instances)));
} else {
table_for_ui_layout(ui_layout, ui)
ui_layout
.table(ui)
.resizable(false)
.cell_layout(egui::Layout::left_to_right(egui::Align::Center))
.column(egui_extras::Column::auto())
Expand Down
10 changes: 5 additions & 5 deletions crates/re_data_ui/src/component_ui_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use re_log_types::{external::arrow2, EntityPath, Instance};
use re_types::external::arrow2::array::Utf8Array;
use re_viewer_context::{ComponentUiRegistry, UiLayout, ViewerContext};

use super::{data_label_for_ui_layout, EntityDataUi};
use super::EntityDataUi;

pub fn create_component_ui_registry() -> ComponentUiRegistry {
re_tracing::profile_function!();
Expand Down Expand Up @@ -86,14 +86,14 @@ fn arrow_ui(ui: &mut egui::Ui, ui_layout: UiLayout, array: &dyn arrow2::array::A
if let Some(utf8) = array.as_any().downcast_ref::<Utf8Array<i32>>() {
if utf8.len() == 1 {
let string = utf8.value(0);
data_label_for_ui_layout(ui, ui_layout, string);
ui_layout.data_label(ui, string);
return;
}
}
if let Some(utf8) = array.as_any().downcast_ref::<Utf8Array<i64>>() {
if utf8.len() == 1 {
let string = utf8.value(0);
data_label_for_ui_layout(ui, ui_layout, string);
ui_layout.data_label(ui, string);
return;
}
}
Expand All @@ -104,7 +104,7 @@ fn arrow_ui(ui: &mut egui::Ui, ui_layout: UiLayout, array: &dyn arrow2::array::A
let mut string = String::new();
let display = arrow2::array::get_display(array, "null");
if display(&mut string, 0).is_ok() {
data_label_for_ui_layout(ui, ui_layout, &string);
ui_layout.data_label(ui, &string);
return;
}
}
Expand All @@ -117,7 +117,7 @@ fn arrow_ui(ui: &mut egui::Ui, ui_layout: UiLayout, array: &dyn arrow2::array::A

if data_type_formatted.len() < 20 {
// e.g. "4.2 KiB of Float32"
data_label_for_ui_layout(ui, ui_layout, &format!("{bytes} of {data_type_formatted}"));
ui_layout.data_label(ui, &format!("{bytes} of {data_type_formatted}"));
} else {
// Huge datatype, probably a union horror show
ui.label(format!("{bytes} of data"));
Expand Down
33 changes: 18 additions & 15 deletions crates/re_data_ui/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use re_types::blueprint::components::VisualBounds2D;
use re_types::components::{Color, LineStrip2D, LineStrip3D, Range1D, ViewCoordinates};
use re_viewer_context::{UiLayout, ViewerContext};

use super::{data_label_for_ui_layout, label_for_ui_layout, table_for_ui_layout, DataUi};
use super::DataUi;

/// Default number of ui points to show a number.
const DEFAULT_NUMBER_WIDTH: f32 = 52.0;
Expand Down Expand Up @@ -65,13 +65,14 @@ impl DataUi for ViewCoordinates {
) {
match ui_layout {
UiLayout::List => {
label_for_ui_layout(ui, ui_layout, self.describe_short())
ui_layout
.label(ui, self.describe_short())
.on_hover_text(self.describe());
}
UiLayout::SelectionPanelFull
| UiLayout::SelectionPanelLimitHeight
| UiLayout::Tooltip => {
label_for_ui_layout(ui, ui_layout, self.describe());
ui_layout.label(ui, self.describe());
}
}
}
Expand Down Expand Up @@ -114,7 +115,7 @@ impl DataUi for re_types::datatypes::Vec2D {
_query: &re_data_store::LatestAtQuery,
_db: &re_entity_db::EntityDb,
) {
data_label_for_ui_layout(ui, ui_layout, self.to_string());
ui_layout.data_label(ui, self.to_string());
}
}

Expand All @@ -127,7 +128,7 @@ impl DataUi for re_types::datatypes::Vec3D {
_query: &re_data_store::LatestAtQuery,
_db: &re_entity_db::EntityDb,
) {
data_label_for_ui_layout(ui, ui_layout, self.to_string());
ui_layout.data_label(ui, self.to_string());
}
}

Expand All @@ -140,7 +141,7 @@ impl DataUi for re_types::datatypes::Vec4D {
_query: &re_data_store::LatestAtQuery,
_db: &re_entity_db::EntityDb,
) {
data_label_for_ui_layout(ui, ui_layout, self.to_string());
ui_layout.data_label(ui, self.to_string());
}
}

Expand All @@ -153,7 +154,7 @@ impl DataUi for re_types::datatypes::UVec2D {
_query: &re_data_store::LatestAtQuery,
_db: &re_entity_db::EntityDb,
) {
data_label_for_ui_layout(ui, ui_layout, self.to_string());
ui_layout.data_label(ui, self.to_string());
}
}

Expand All @@ -166,7 +167,7 @@ impl DataUi for re_types::datatypes::UVec3D {
_query: &re_data_store::LatestAtQuery,
_db: &re_entity_db::EntityDb,
) {
data_label_for_ui_layout(ui, ui_layout, self.to_string());
ui_layout.data_label(ui, self.to_string());
}
}

Expand All @@ -179,7 +180,7 @@ impl DataUi for re_types::datatypes::UVec4D {
_query: &re_data_store::LatestAtQuery,
_db: &re_entity_db::EntityDb,
) {
data_label_for_ui_layout(ui, ui_layout, self.to_string());
ui_layout.data_label(ui, self.to_string());
}
}

Expand All @@ -192,7 +193,7 @@ impl DataUi for Range1D {
_query: &LatestAtQuery,
_db: &EntityDb,
) {
data_label_for_ui_layout(ui, ui_layout, self.to_string());
ui_layout.data_label(ui, self.to_string());
}
}

Expand All @@ -205,7 +206,7 @@ impl DataUi for VisualBounds2D {
_query: &LatestAtQuery,
_db: &EntityDb,
) {
data_label_for_ui_layout(ui, ui_layout, self.to_string());
ui_layout.data_label(ui, self.to_string());
}
}

Expand All @@ -220,11 +221,12 @@ impl DataUi for LineStrip2D {
) {
match ui_layout {
UiLayout::List | UiLayout::Tooltip => {
label_for_ui_layout(ui, ui_layout, format!("{} positions", self.0.len()));
ui_layout.label(ui, format!("{} positions", self.0.len()));
}
UiLayout::SelectionPanelLimitHeight | UiLayout::SelectionPanelFull => {
use egui_extras::Column;
table_for_ui_layout(ui_layout, ui)
ui_layout
.table(ui)
.resizable(true)
.cell_layout(egui::Layout::left_to_right(egui::Align::Center))
.columns(Column::initial(DEFAULT_NUMBER_WIDTH).clip(true), 2)
Expand Down Expand Up @@ -267,11 +269,12 @@ impl DataUi for LineStrip3D {
) {
match ui_layout {
UiLayout::List | UiLayout::Tooltip => {
label_for_ui_layout(ui, ui_layout, format!("{} positions", self.0.len()));
ui_layout.label(ui, format!("{} positions", self.0.len()));
}
UiLayout::SelectionPanelFull | UiLayout::SelectionPanelLimitHeight => {
use egui_extras::Column;
table_for_ui_layout(ui_layout, ui)
ui_layout
.table(ui)
.resizable(true)
.cell_layout(egui::Layout::left_to_right(egui::Align::Center))
.columns(Column::initial(DEFAULT_NUMBER_WIDTH).clip(true), 3)
Expand Down
6 changes: 3 additions & 3 deletions crates/re_data_ui/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use re_viewer_context::{
ViewerContext,
};

use crate::{image_meaning_for_entity, label_for_ui_layout};
use crate::image_meaning_for_entity;

use super::EntityDataUi;

Expand Down Expand Up @@ -84,7 +84,7 @@ impl EntityDataUi for re_types::components::TensorData {
);
}
Err(err) => {
label_for_ui_layout(ui, ui_layout, ctx.re_ui.error_text(err.to_string()));
ui_layout.label(ui, ctx.re_ui.error_text(err.to_string()));
}
}
}
Expand Down Expand Up @@ -187,7 +187,7 @@ pub fn tensor_ui(
original_tensor.dtype(),
format_tensor_shape_single_line(&shape)
);
label_for_ui_layout(ui, ui_layout, text).on_hover_ui(|ui| {
ui_layout.label(ui, text).on_hover_ui(|ui| {
tensor_summary_ui(
ctx.re_ui,
ui,
Expand Down
Loading

0 comments on commit aaf9d5e

Please sign in to comment.