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

Add icons for entities and components, and use them everywhere #5318

Merged
merged 4 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 35 additions & 32 deletions crates/re_data_ui/src/instance_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,42 +66,45 @@ impl DataUi for InstancePath {
}

// Now show the rest of the components:
egui::Grid::new("components").num_columns(2).show(ui, |ui| {
for component_name in normal_components {
let Some((_, _, component_data)) =
get_component_with_instances(store, query, entity_path, component_name)
else {
continue; // no need to show components that are unset at this point in time
};
egui::Grid::new("components")
.spacing(ui.spacing().item_spacing)
.num_columns(2)
.show(ui, |ui| {
for component_name in normal_components {
let Some((_, _, component_data)) =
get_component_with_instances(store, query, entity_path, component_name)
else {
continue; // no need to show components that are unset at this point in time
};

item_ui::component_path_button(
ctx,
ui,
&ComponentPath::new(entity_path.clone(), component_name),
);

if instance_key.is_splat() {
super::component::EntityComponentWithInstances {
entity_path: entity_path.clone(),
component_data,
}
.data_ui(ctx, ui, UiVerbosity::Small, query, store);
} else {
ctx.component_ui_registry.ui(
item_ui::component_path_button(
ctx,
ui,
UiVerbosity::Small,
query,
store,
entity_path,
&component_data,
instance_key,
&ComponentPath::new(entity_path.clone(), component_name),
);
}

ui.end_row();
}
Some(())
});
if instance_key.is_splat() {
super::component::EntityComponentWithInstances {
entity_path: entity_path.clone(),
component_data,
}
.data_ui(ctx, ui, UiVerbosity::Small, query, store);
} else {
ctx.component_ui_registry.ui(
ctx,
ui,
UiVerbosity::Small,
query,
store,
entity_path,
&component_data,
instance_key,
);
}

ui.end_row();
}
Some(())
});
}
}
19 changes: 16 additions & 3 deletions crates/re_data_ui/src/item_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,15 @@ pub fn instance_path_button_to(
) -> egui::Response {
let item = Item::InstancePath(space_view_id, instance_path.clone());

let response = ui
.selectable_label(ctx.selection().contains_item(&item), text)
let response = ctx
.re_ui
.selectable_label_with_icon(
ui,
&re_ui::icons::ENTITY,
text,
ctx.selection().contains_item(&item),
re_ui::LabelStyle::Normal,
)
.on_hover_ui(|ui| {
instance_hover_card_ui(ui, ctx, query, store, instance_path);
});
Expand Down Expand Up @@ -294,7 +301,13 @@ pub fn component_path_button_to(
component_path: &ComponentPath,
) -> egui::Response {
let item = Item::ComponentPath(component_path.clone());
let response = ui.selectable_label(ctx.selection().contains_item(&item), text);
let response = ctx.re_ui.selectable_label_with_icon(
ui,
&re_ui::icons::COMPONENT,
text,
ctx.selection().contains_item(&item),
re_ui::LabelStyle::Normal,
);
cursor_interact_with_selectable(ctx, response, item)
}

Expand Down
6 changes: 2 additions & 4 deletions crates/re_time_panel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ impl TimePanel {
item_response: response,
body_response,
} = ListItem::new(ctx.re_ui, text)
.with_icon(&re_ui::icons::ENTITY)
.width_allocation_mode(WidthAllocationMode::Compact)
.selected(is_selected)
.force_hovered(is_item_hovered)
Expand Down Expand Up @@ -701,10 +702,7 @@ impl TimePanel {
.highlight_for_ui_element(&item.to_item())
== HoverHighlight::Hovered,
)
.with_icon_fn(|_, ui, rect, visual| {
ui.painter()
.circle_filled(rect.center(), 2.0, visual.text_color());
})
.with_icon(&re_ui::icons::COMPONENT)
.show(ui);

ui.set_clip_rect(clip_rect_save);
Expand Down
Binary file added crates/re_ui/data/icons/component.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added crates/re_ui/data/icons/entity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions crates/re_ui/src/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ pub const SPACE_VIEW_UNKNOWN: Icon = Icon::new(
);

pub const GROUP: Icon = Icon::new("group", include_bytes!("../data/icons/group.png"));
pub const ENTITY: Icon = Icon::new("entity", include_bytes!("../data/icons/entity.png"));
pub const COMPONENT: Icon = Icon::new("component", include_bytes!("../data/icons/component.png"));

pub const STORE: Icon = Icon::new("store", include_bytes!("../data/icons/store.png"));

Expand Down
42 changes: 24 additions & 18 deletions crates/re_viewer/src/ui/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ fn what_is_selected_ui(
ctx.re_ui,
ui,
component_name.short_name(),
None,
Some(&re_ui::icons::COMPONENT),
&format!(
"Component {} of entity '{}'",
component_name.full_name(),
Expand Down Expand Up @@ -433,25 +433,27 @@ fn what_is_selected_ui(
ctx.re_ui,
ui,
name,
None,
Some(&re_ui::icons::ENTITY),
&format!(
"{typ} '{instance_path}' as shown in Space View {:?}",
space_view.display_name
),
);

if let Some(parent) = parent {
ui.horizontal(|ui| {
ui.label("path");
item_ui::entity_path_parts_buttons(
ctx,
&query,
store,
ui,
Some(*space_view_id),
&parent,
);
});
if !parent.is_root() {
ui.horizontal(|ui| {
ui.label("path");
item_ui::entity_path_parts_buttons(
ctx,
&query,
store,
ui,
Some(*space_view_id),
&parent,
);
});
}
}

ui.horizontal(|ui| {
Expand All @@ -464,15 +466,19 @@ fn what_is_selected_ui(
ctx.re_ui,
ui,
name,
None,
Some(&re_ui::icons::ENTITY),
&format!("{typ} '{instance_path}'"),
);

if let Some(parent) = parent {
ui.horizontal(|ui| {
ui.label("path");
item_ui::entity_path_parts_buttons(ctx, &query, store, ui, None, &parent);
});
if !parent.is_root() {
ui.horizontal(|ui| {
ui.label("path");
item_ui::entity_path_parts_buttons(
ctx, &query, store, ui, None, &parent,
);
});
}
}

list_existing_data_blueprints(ui, ctx, &instance_path.entity_path, viewport);
Expand Down
5 changes: 2 additions & 3 deletions crates/re_viewport/src/viewport_blueprint_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,9 @@ impl Viewport<'_, '_> {
.map_or("unknown".to_owned(), |e| e.ui_string());

let response = if child_node.children.is_empty() {
let label = format!("🔹 {name}");

ListItem::new(ctx.re_ui, label)
ListItem::new(ctx.re_ui, name)
.selected(is_selected)
.with_icon(&re_ui::icons::ENTITY)
.subdued(
!group_is_visible
|| !properties.visible
Expand Down
Loading