Skip to content

Commit

Permalink
Subdue container labels to distinguish them from space views
Browse files Browse the repository at this point in the history
  • Loading branch information
abey79 committed Jan 18, 2024
1 parent 91bee81 commit 454ca10
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion crates/re_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ pub enum LabelStyle {

/// Label displaying the placeholder text for a yet unnamed item (e.g. an unnamed space view).
Unnamed,

/// Label for containers, which are subdued compared to space views to make them distinctive
Container,
}

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -925,7 +928,7 @@ impl ReUi {

let mut text: egui::WidgetText = text.into();
match style {
LabelStyle::Normal => {}
LabelStyle::Normal | LabelStyle::Container => {}
LabelStyle::Unnamed => {
// TODO(ab): use design tokens
text = text.italics();
Expand Down Expand Up @@ -991,6 +994,10 @@ impl ReUi {
// TODO(ab): use design tokens
text_color = text_color.gamma_multiply(0.5);
}
LabelStyle::Container => {
// TODO(ab): use design tokens
text_color = ui.visuals().widgets.noninteractive.text_color();
}
}
ui.painter()
.galley_with_override_text_color(text_pos, galley, text_color);
Expand Down
7 changes: 6 additions & 1 deletion crates/re_ui/src/list_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ impl<'a> ListItem<'a> {
LabelStyle::Unnamed => {
self.italics = true;
}
LabelStyle::Container => {
self.text = self
.text
.color(ui.visuals().widgets.noninteractive.text_color());
}
}

if self.italics {
Expand Down Expand Up @@ -455,7 +460,7 @@ impl<'a> ListItem<'a> {
}

match self.label_style {
LabelStyle::Normal => {}
LabelStyle::Normal | LabelStyle::Container => {}
LabelStyle::Unnamed => {
self.text = self.text.color(visuals.fg_stroke.color.gamma_multiply(0.5));
}
Expand Down
1 change: 1 addition & 0 deletions crates/re_viewer/src/ui/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ fn show_list_item_for_container_child(
(
Item::Container(child_tile_id),
ListItem::new(ctx.re_ui, format!("{:?}", container.kind()))
.label_style(re_ui::LabelStyle::Container)
.with_icon(icon_for_container_kind(&container.kind())),
)
}
Expand Down
1 change: 1 addition & 0 deletions crates/re_viewport/src/viewport_blueprint_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ impl Viewport<'_, '_> {
let response = ListItem::new(ctx.re_ui, format!("{:?}", container.kind()))
.subdued(!container_visible)
.selected(ctx.selection().contains_item(&item))
.label_style(re_ui::LabelStyle::Container)
.with_icon(crate::icon_for_container_kind(&container.kind()))
.with_buttons(|re_ui, ui| {
let vis_response = visibility_button_ui(re_ui, ui, parent_visible, &mut visible);
Expand Down

0 comments on commit 454ca10

Please sign in to comment.