-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More compact selection panel when multiple items selected (#8351)
### Related * Closes #8336 ### What When you have more than one item selected at once, you get a list of all items. Clicking one will select just that. <img width="308" alt="multiple-selected-entities" src="https://github.com/user-attachments/assets/67174eed-373a-486c-a2b1-b97a08136805"> ### Implementation A bit messy, to be honest. I leveraged the existing `ItemTitle` for some items, and hand-rolled others. It would be nice with something similar to `DataUi`, but for titles (with or without breadcrumbs). But the amount of messy code is low and low-impact, so unless someone has a good suggestion or strongly objects, I suggestion calling this "good enough for now".
- Loading branch information
Showing
20 changed files
with
261 additions
and
123 deletions.
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
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
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
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
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
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
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
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
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
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
113 changes: 113 additions & 0 deletions
113
crates/viewer/re_selection_panel/src/item_heading_no_breadcrumbs.rs
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 |
---|---|---|
@@ -0,0 +1,113 @@ | ||
use egui::WidgetText; | ||
|
||
use re_data_ui::item_ui::{cursor_interact_with_selectable, guess_instance_path_icon}; | ||
use re_log_types::ComponentPath; | ||
use re_ui::{icons, list_item, Icon, SyntaxHighlighting, UiExt as _}; | ||
use re_viewer_context::{Item, ViewerContext}; | ||
use re_viewport_blueprint::ViewportBlueprint; | ||
|
||
use crate::{ | ||
item_heading_with_breadcrumbs::separator_icon_ui, | ||
item_title::{is_component_static, ItemTitle}, | ||
}; | ||
|
||
/// Just the title of the item; for when multiple items are selected | ||
pub fn item_title_list_item( | ||
ctx: &ViewerContext<'_>, | ||
viewport: &ViewportBlueprint, | ||
ui: &mut egui::Ui, | ||
item: &Item, | ||
) { | ||
let response = ui | ||
.list_item() | ||
.with_height(re_ui::DesignTokens::list_item_height()) | ||
.interactive(true) | ||
.show_flat( | ||
ui, | ||
list_item::CustomContent::new(|ui, context| { | ||
ui.allocate_new_ui( | ||
egui::UiBuilder::new() | ||
.max_rect(context.rect) | ||
.layout(egui::Layout::left_to_right(egui::Align::Center)), | ||
|ui| { | ||
ui.spacing_mut().item_spacing.x = 4.0; | ||
ui.style_mut().interaction.selectable_labels = false; | ||
item_heading_no_breadcrumbs(ctx, viewport, ui, item); | ||
}, | ||
); | ||
}), | ||
); | ||
cursor_interact_with_selectable(ctx, response, item.clone()); | ||
} | ||
|
||
/// Fully descriptive heading for an item, without any breadcrumbs. | ||
fn item_heading_no_breadcrumbs( | ||
ctx: &ViewerContext<'_>, | ||
viewport: &ViewportBlueprint, | ||
ui: &mut egui::Ui, | ||
item: &Item, | ||
) { | ||
match item { | ||
Item::AppId(_) | ||
| Item::DataSource(_) | ||
| Item::StoreId(_) | ||
| Item::Container(_) | ||
| Item::SpaceView(_) => { | ||
let ItemTitle { | ||
icon, | ||
label, | ||
label_style: _, // no label | ||
tooltip: _, | ||
} = ItemTitle::from_item(ctx, viewport, ui.style(), item); | ||
|
||
icon_and_title(ui, icon, label); | ||
} | ||
Item::InstancePath(instance_path) => { | ||
icon_and_title( | ||
ui, | ||
guess_instance_path_icon(ctx, instance_path), | ||
instance_path.syntax_highlighted(ui.style()), | ||
); | ||
} | ||
Item::ComponentPath(component_path) => { | ||
let is_component_static = is_component_static(ctx, component_path); | ||
|
||
// Break up into entity path and component name: | ||
let ComponentPath { | ||
entity_path, | ||
component_name, | ||
} = component_path; | ||
|
||
item_heading_no_breadcrumbs(ctx, viewport, ui, &Item::from(entity_path.clone())); | ||
|
||
separator_icon_ui(ui); | ||
|
||
let component_icon = if is_component_static { | ||
&icons::COMPONENT_STATIC | ||
} else { | ||
&icons::COMPONENT_TEMPORAL | ||
}; | ||
icon_and_title( | ||
ui, | ||
component_icon, | ||
component_name.syntax_highlighted(ui.style()), | ||
); | ||
} | ||
Item::DataResult(view_id, instance_path) => { | ||
// Break up into view and instance path: | ||
item_heading_no_breadcrumbs(ctx, viewport, ui, &Item::SpaceView(*view_id)); | ||
separator_icon_ui(ui); | ||
item_heading_no_breadcrumbs( | ||
ctx, | ||
viewport, | ||
ui, | ||
&Item::InstancePath(instance_path.clone()), | ||
); | ||
} | ||
} | ||
} | ||
|
||
fn icon_and_title(ui: &mut egui::Ui, icon: &Icon, title: impl Into<WidgetText>) { | ||
ui.add(icon.as_image()); | ||
ui.label(title); | ||
} |
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
Oops, something went wrong.