Skip to content

Commit

Permalink
Rename UiVerbosity to UiLayout and make its variants more precise (
Browse files Browse the repository at this point in the history
…rerun-io#6291)

### What

* part of rerun-io#6245 

Pure refactor. The second commit clarify the meaning of the various
`UiLayout` variants. The other commits are just renames.

### 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/6291?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/6291?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/6291)
- [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 May 13, 2024
1 parent f7ea2bb commit 24b1f18
Show file tree
Hide file tree
Showing 32 changed files with 282 additions and 261 deletions.
53 changes: 28 additions & 25 deletions crates/re_data_ui/src/annotation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ use re_types::components::AnnotationContext;
use re_types::datatypes::{
AnnotationInfo, ClassDescription, ClassDescriptionMapElem, KeypointId, KeypointPair,
};
use re_viewer_context::{auto_color, UiVerbosity, ViewerContext};
use re_viewer_context::{auto_color, UiLayout, ViewerContext};

use super::{table_for_verbosity, DataUi};
use super::{table_for_ui_layout, DataUi};

impl crate::EntityDataUi for re_types::components::ClassId {
fn entity_data_ui(
&self,
ctx: &re_viewer_context::ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: re_viewer_context::UiVerbosity,
ui_layout: UiLayout,
entity_path: &re_log_types::EntityPath,
query: &re_data_store::LatestAtQuery,
_db: &re_entity_db::EntityDb,
Expand All @@ -34,19 +34,21 @@ impl crate::EntityDataUi for re_types::components::ClassId {
});

let id = self.0;
match verbosity {
UiVerbosity::Small => {
match ui_layout {
UiLayout::List => {
if !class.keypoint_connections.is_empty()
|| !class.keypoint_annotations.is_empty()
{
response.response.on_hover_ui(|ui| {
class_description_ui(ctx, ui, verbosity, class, id);
class_description_ui(ctx, ui, ui_layout, class, id);
});
}
}
UiVerbosity::Reduced | UiVerbosity::Full | UiVerbosity::LimitHeight => {
UiLayout::Tooltip
| UiLayout::SelectionPanelFull
| UiLayout::SelectionPanelLimitHeight => {
ui.separator();
class_description_ui(ctx, ui, verbosity, class, id);
class_description_ui(ctx, ui, ui_layout, class, id);
}
}
} else {
Expand All @@ -58,9 +60,9 @@ impl crate::EntityDataUi for re_types::components::ClassId {
impl crate::EntityDataUi for re_types::components::KeypointId {
fn entity_data_ui(
&self,
ctx: &re_viewer_context::ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
_verbosity: re_viewer_context::UiVerbosity,
_ui_layout: UiLayout,
entity_path: &re_log_types::EntityPath,
query: &re_data_store::LatestAtQuery,
_db: &re_entity_db::EntityDb,
Expand Down Expand Up @@ -100,12 +102,12 @@ impl DataUi for AnnotationContext {
&self,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
ui_layout: UiLayout,
_query: &re_data_store::LatestAtQuery,
_db: &re_entity_db::EntityDb,
) {
match verbosity {
UiVerbosity::Small | UiVerbosity::Reduced => {
match ui_layout {
UiLayout::List | UiLayout::Tooltip => {
if self.0.len() == 1 {
let descr = &self.0[0].class_description;
ui.label(format!(
Expand All @@ -117,7 +119,7 @@ impl DataUi for AnnotationContext {
ui.label(format!("{} classes", self.0.len()));
}
}
UiVerbosity::LimitHeight | UiVerbosity::Full => {
UiLayout::SelectionPanelLimitHeight | UiLayout::SelectionPanelFull => {
ui.vertical(|ui| {
ctx.re_ui
.maybe_collapsing_header(ui, true, "Classes", true, |ui| {
Expand All @@ -127,15 +129,15 @@ impl DataUi for AnnotationContext {
.map(|class| &class.class_description.info)
.sorted_by_key(|info| info.id)
.collect_vec();
annotation_info_table_ui(ui, verbosity, &annotation_infos);
annotation_info_table_ui(ui, ui_layout, &annotation_infos);
});

for ClassDescriptionMapElem {
class_id,
class_description,
} in &self.0
{
class_description_ui(ctx, ui, verbosity, class_description, *class_id);
class_description_ui(ctx, ui, ui_layout, class_description, *class_id);
}
});
}
Expand All @@ -146,7 +148,7 @@ impl DataUi for AnnotationContext {
fn class_description_ui(
ctx: &re_viewer_context::ViewerContext<'_>,
ui: &mut egui::Ui,
mut verbosity: UiVerbosity,
mut ui_layout: UiLayout,
class: &ClassDescription,
id: re_types::datatypes::ClassId,
) {
Expand All @@ -156,12 +158,13 @@ fn class_description_ui(

re_tracing::profile_function!();

let use_collapsible = verbosity == UiVerbosity::LimitHeight || verbosity == UiVerbosity::Full;
let use_collapsible = ui_layout == UiLayout::SelectionPanelLimitHeight
|| ui_layout == UiLayout::SelectionPanelFull;

// We use collapsible header as a means for the user to limit the height, so the annotation info
// tables can be fully unrolled.
if verbosity == UiVerbosity::LimitHeight {
verbosity = UiVerbosity::Full;
if ui_layout == UiLayout::SelectionPanelLimitHeight {
ui_layout = UiLayout::SelectionPanelFull;
}

let row_height = re_ui::ReUi::table_line_height();
Expand All @@ -178,7 +181,7 @@ fn class_description_ui(
.sorted_by_key(|annotation| annotation.id)
.collect_vec();
ui.push_id(format!("keypoint_annotations_{}", id.0), |ui| {
annotation_info_table_ui(ui, verbosity, &annotation_infos);
annotation_info_table_ui(ui, ui_layout, &annotation_infos);
});
},
);
Expand All @@ -194,7 +197,7 @@ fn class_description_ui(
ui.push_id(format!("keypoints_connections_{}", id.0), |ui| {
use egui_extras::Column;

let table = table_for_verbosity(verbosity, ui)
let table = table_for_ui_layout(ui_layout, 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 @@ -251,7 +254,7 @@ fn class_description_ui(

fn annotation_info_table_ui(
ui: &mut egui::Ui,
verbosity: UiVerbosity,
ui_layout: UiLayout,
annotation_infos: &[&AnnotationInfo],
) {
re_tracing::profile_function!();
Expand All @@ -262,7 +265,7 @@ fn annotation_info_table_ui(

use egui_extras::Column;

let table = table_for_verbosity(verbosity, ui)
let table = table_for_ui_layout(ui_layout, 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
12 changes: 6 additions & 6 deletions crates/re_data_ui/src/app_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use itertools::Itertools as _;

use re_entity_db::EntityDb;
use re_log_types::ApplicationId;
use re_viewer_context::{SystemCommandSender as _, UiVerbosity, ViewerContext};
use re_viewer_context::{SystemCommandSender as _, UiLayout, ViewerContext};

use crate::item_ui::entity_db_button_ui;

Expand All @@ -11,9 +11,9 @@ impl crate::DataUi for ApplicationId {
&self,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
ui_layout: UiLayout,
_query: &re_data_store::LatestAtQuery,
_db: &EntityDb,
_db: &re_entity_db::EntityDb,
) {
egui::Grid::new("application_id")
.num_columns(2)
Expand All @@ -26,7 +26,7 @@ impl crate::DataUi for ApplicationId {
ui.end_row();
});

if verbosity == UiVerbosity::Small {
if ui_layout == UiLayout::List {
return;
}

Expand Down Expand Up @@ -56,7 +56,7 @@ impl crate::DataUi for ApplicationId {
ui.scope(|ui| {
// TODO(#6246): this test is needed because we're called in a context that may or may
// not have a full span defined.
if verbosity == UiVerbosity::Reduced {
if ui_layout == UiLayout::Tooltip {
// This typically happens in tooltips, so a scope is needed
//TODO(ab): in the context of tooltips, ui.max_rect() doesn't provide the correct width
re_ui::full_span::full_span_scope(ui, ui.max_rect().x_range(), content_ui);
Expand All @@ -70,7 +70,7 @@ impl crate::DataUi for ApplicationId {
// ---------------------------------------------------------------------
// do not show UI code in tooltips

if verbosity != UiVerbosity::Reduced {
if ui_layout != UiLayout::Tooltip {
ui.add_space(8.0);

// ---------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions crates/re_data_ui/src/blueprint_data.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use re_viewer_context::{BlueprintId, BlueprintIdRegistry, UiVerbosity, ViewerContext};
use re_viewer_context::{BlueprintId, BlueprintIdRegistry, UiLayout, ViewerContext};

use crate::{item_ui::entity_path_button_to, DataUi};

Expand All @@ -8,7 +8,7 @@ impl<T: BlueprintIdRegistry> DataUi for BlueprintId<T> {
&self,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
_verbosity: UiVerbosity,
_ui_layout: UiLayout,
query: &re_data_store::LatestAtQuery,
db: &re_entity_db::EntityDb,
) {
Expand Down
10 changes: 5 additions & 5 deletions crates/re_data_ui/src/blueprint_types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use re_types_blueprint::blueprint::components::{IncludedSpaceView, SpaceViewMaximized};
use re_viewer_context::{SpaceViewId, UiVerbosity, ViewerContext};
use re_viewer_context::{SpaceViewId, UiLayout, ViewerContext};

use crate::DataUi;

Expand All @@ -11,12 +11,12 @@ impl DataUi for IncludedSpaceView {
&self,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
ui_layout: UiLayout,
query: &re_data_store::LatestAtQuery,
db: &re_entity_db::EntityDb,
) {
let space_view: SpaceViewId = self.0.into();
space_view.data_ui(ctx, ui, verbosity, query, db);
space_view.data_ui(ctx, ui, ui_layout, query, db);
}
}

Expand All @@ -26,11 +26,11 @@ impl DataUi for SpaceViewMaximized {
&self,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
ui_layout: UiLayout,
query: &re_data_store::LatestAtQuery,
db: &re_entity_db::EntityDb,
) {
let space_view: SpaceViewId = self.0.into();
space_view.data_ui(ctx, ui, verbosity, query, db);
space_view.data_ui(ctx, ui, ui_layout, query, db);
}
}
30 changes: 16 additions & 14 deletions crates/re_data_ui/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use re_entity_db::{external::re_query::LatestAtComponentResults, EntityPath, Ins
use re_log_types::Instance;
use re_types::ComponentName;
use re_ui::SyntaxHighlighting as _;
use re_viewer_context::{UiVerbosity, ViewerContext};
use re_viewer_context::{UiLayout, ViewerContext};

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

/// All the values of a specific [`re_log_types::ComponentPath`].
Expand All @@ -23,7 +23,7 @@ impl DataUi for EntityLatestAtResults {
&self,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
ui_layout: UiLayout,
query: &re_data_store::LatestAtQuery,
db: &re_entity_db::EntityDb,
) {
Expand All @@ -39,20 +39,22 @@ impl DataUi for EntityLatestAtResults {
return;
};

let one_line = match verbosity {
UiVerbosity::Small => true,
UiVerbosity::Reduced | UiVerbosity::LimitHeight | UiVerbosity::Full => false,
let one_line = match ui_layout {
UiLayout::List => true,
UiLayout::Tooltip
| UiLayout::SelectionPanelLimitHeight
| UiLayout::SelectionPanelFull => 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::LimitHeight | UiVerbosity::Full => num_instances,
let max_row = match ui_layout {
UiLayout::List => 0,
UiLayout::Tooltip => num_instances.at_most(4), // includes "…x more" if any
UiLayout::SelectionPanelLimitHeight | UiLayout::SelectionPanelFull => num_instances,
};

// Display data time and additional diagnostic information for static components.
if verbosity != UiVerbosity::Small {
if ui_layout != UiLayout::List {
ui.label(format!(
"Data time: {}",
query
Expand Down Expand Up @@ -127,7 +129,7 @@ impl DataUi for EntityLatestAtResults {
ctx.component_ui_registry.ui(
ctx,
ui,
verbosity,
ui_layout,
query,
db,
&self.entity_path,
Expand All @@ -137,7 +139,7 @@ impl DataUi for EntityLatestAtResults {
} else if one_line {
ui.label(format!("{} values", re_format::format_uint(num_instances)));
} else {
table_for_verbosity(verbosity, ui)
table_for_ui_layout(ui_layout, ui)
.resizable(false)
.cell_layout(egui::Layout::left_to_right(egui::Align::Center))
.column(egui_extras::Column::auto())
Expand Down Expand Up @@ -173,7 +175,7 @@ impl DataUi for EntityLatestAtResults {
ctx.component_ui_registry.ui(
ctx,
ui,
UiVerbosity::Small,
UiLayout::List,
query,
db,
&self.entity_path,
Expand Down
6 changes: 3 additions & 3 deletions crates/re_data_ui/src/component_path.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use re_log_types::ComponentPath;
use re_viewer_context::{UiVerbosity, ViewerContext};
use re_viewer_context::{UiLayout, ViewerContext};

use super::DataUi;

Expand All @@ -10,7 +10,7 @@ impl DataUi for ComponentPath {
&self,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
ui_layout: UiLayout,
query: &re_data_store::LatestAtQuery,
db: &re_entity_db::EntityDb,
) {
Expand All @@ -33,7 +33,7 @@ impl DataUi for ComponentPath {
component_name: *component_name,
results: Arc::clone(results),
}
.data_ui(ctx, ui, verbosity, query, db);
.data_ui(ctx, ui, ui_layout, query, db);
} else if let Some(entity_tree) = ctx.recording().tree().subtree(entity_path) {
if entity_tree.entity.components.contains_key(component_name) {
ui.label("<unset>");
Expand Down
Loading

0 comments on commit 24b1f18

Please sign in to comment.