Skip to content

Commit

Permalink
Less rightward drift
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Dec 9, 2024
1 parent 367cb28 commit bb84634
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use egui::WidgetText;

use re_data_ui::item_ui::guess_instance_path_icon;
use re_data_ui::item_ui::{cursor_interact_with_selectable, guess_instance_path_icon};
use re_log_types::ComponentPath;
use re_ui::{icons, Icon, SyntaxHighlighting};
use re_ui::{icons, list_item, Icon, SyntaxHighlighting, UiExt as _};
use re_viewer_context::{Item, ViewerContext};
use re_viewport_blueprint::ViewportBlueprint;

Expand All @@ -11,8 +11,37 @@ use crate::{
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.
pub fn item_heading_no_breadcrumbs(
fn item_heading_no_breadcrumbs(
ctx: &ViewerContext<'_>,
viewport: &ViewportBlueprint,
ui: &mut egui::Ui,
Expand Down
24 changes: 2 additions & 22 deletions crates/viewer/re_selection_panel/src/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use re_viewport_blueprint::{ui::show_add_space_view_or_container_modal, Viewport

use crate::{
defaults_ui::view_components_defaults_section_ui,
item_heading_no_breadcrumbs::item_heading_no_breadcrumbs,
item_heading_no_breadcrumbs::item_title_list_item,
item_heading_with_breadcrumbs::item_heading_with_breadcrumbs,
space_view_entity_picker::SpaceViewEntityPicker,
visible_time_range_ui::{
Expand Down Expand Up @@ -145,27 +145,7 @@ impl SelectionPanel {

for item in selection.iter_items() {
ui.add_space(4.0);

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());
item_title_list_item(ctx, viewport, ui, item);
}
});
}
Expand Down

0 comments on commit bb84634

Please sign in to comment.