diff --git a/crates/re_data_ui/src/item_ui.rs b/crates/re_data_ui/src/item_ui.rs index 8ef34e51ee8ef..e22330569ee47 100644 --- a/crates/re_data_ui/src/item_ui.rs +++ b/crates/re_data_ui/src/item_ui.rs @@ -6,7 +6,7 @@ use re_entity_db::{EntityTree, InstancePath}; use re_log_types::{ComponentPath, EntityPath, TimeInt, Timeline}; use re_ui::SyntaxHighlighting; use re_viewer_context::{ - DataQueryId, HoverHighlight, Item, Selection, SpaceViewId, UiVerbosity, ViewerContext, + DataQueryId, HoverHighlight, Item, SpaceViewId, UiVerbosity, ViewerContext, }; use super::DataUi; @@ -330,7 +330,7 @@ pub fn cursor_interact_with_selectable( let is_item_hovered = ctx.selection_state().highlight_for_ui_element(&item) == HoverHighlight::Hovered; - select_hovered_on_click(ctx, &response, item); + ctx.select_hovered_on_click(&response, item); // TODO(andreas): How to deal with shift click for selecting ranges? if is_item_hovered { @@ -340,16 +340,6 @@ pub fn cursor_interact_with_selectable( } } -// TODO(andreas): Move elsewhere, this is not directly part of the item_ui. -pub fn select_hovered_on_click( - ctx: &ViewerContext<'_>, - response: &egui::Response, - selection: impl Into, -) { - // TODO: inline everywhere. - ctx.select_hovered_on_click(response, selection); -} - /// Displays the "hover card" (i.e. big tooltip) for an instance or an entity. /// /// The entity hover card is displayed the provided instance path is a splat. diff --git a/crates/re_space_view_spatial/src/ui.rs b/crates/re_space_view_spatial/src/ui.rs index 4029b5979a5b6..e252613c81164 100644 --- a/crates/re_space_view_spatial/src/ui.rs +++ b/crates/re_space_view_spatial/src/ui.rs @@ -661,7 +661,7 @@ pub fn picking( }); }; - item_ui::select_hovered_on_click(ctx, &response, re_viewer_context::Selection(hovered_items)); + ctx.select_hovered_on_click( &response, re_viewer_context::Selection(hovered_items)); Ok(response) } diff --git a/crates/re_time_panel/src/lib.rs b/crates/re_time_panel/src/lib.rs index 6b8ef70b0e734..2e764d29503dd 100644 --- a/crates/re_time_panel/src/lib.rs +++ b/crates/re_time_panel/src/lib.rs @@ -13,7 +13,6 @@ mod time_selection_ui; use egui::emath::Rangef; use egui::{pos2, Color32, CursorIcon, NumExt, Painter, PointerButton, Rect, Shape, Ui, Vec2}; -use re_data_ui::item_ui; use re_entity_db::{EntityTree, InstancePath, TimeHistogram}; use re_log_types::{ external::re_types_core::ComponentName, ComponentPath, EntityPath, EntityPathPart, TimeInt, @@ -602,7 +601,7 @@ impl TimePanel { ); }); - item_ui::select_hovered_on_click(ctx, &response, item.to_item()); + ctx.select_hovered_on_click(&response, item.to_item()); let is_closed = body_response.is_none(); let response_rect = response.rect; @@ -713,7 +712,7 @@ impl TimePanel { ui.set_clip_rect(clip_rect_save); - re_data_ui::item_ui::select_hovered_on_click(ctx, &response, item.to_item()); + ctx.select_hovered_on_click(&response, item.to_item()); let response_rect = response.rect; diff --git a/crates/re_viewer/src/ui/selection_panel.rs b/crates/re_viewer/src/ui/selection_panel.rs index d42c5b537e002..e7c453bed3ea7 100644 --- a/crates/re_viewer/src/ui/selection_panel.rs +++ b/crates/re_viewer/src/ui/selection_panel.rs @@ -776,7 +776,7 @@ fn show_list_item_for_container_child( let response = list_item.show(ui); - item_ui::select_hovered_on_click(ctx, &response, std::iter::once(item)); + ctx.select_hovered_on_click(&response, std::iter::once(item)); if remove_contents { viewport.blueprint.mark_user_interaction(ctx); diff --git a/crates/re_viewport/src/viewport.rs b/crates/re_viewport/src/viewport.rs index c73e4953ab264..3b0ca0da5c177 100644 --- a/crates/re_viewport/src/viewport.rs +++ b/crates/re_viewport/src/viewport.rs @@ -8,7 +8,6 @@ use ahash::HashMap; use egui_tiles::Behavior as _; use once_cell::sync::Lazy; -use re_data_ui::item_ui; use re_entity_db::EntityPropertyMap; use re_ui::{Icon, ReUi}; @@ -580,7 +579,8 @@ impl<'a, 'b> egui_tiles::Behavior for TabViewer<'a, 'b> { } if let Some(egui_tiles::Tile::Pane(space_view_id)) = tiles.get(tile_id) { - item_ui::select_hovered_on_click(self.ctx, &response, Item::SpaceView(*space_view_id)); + self.ctx + .select_hovered_on_click(&response, Item::SpaceView(*space_view_id)); } response diff --git a/crates/re_viewport/src/viewport_blueprint_ui.rs b/crates/re_viewport/src/viewport_blueprint_ui.rs index cad80df88867e..9e95db3707a40 100644 --- a/crates/re_viewport/src/viewport_blueprint_ui.rs +++ b/crates/re_viewport/src/viewport_blueprint_ui.rs @@ -1,7 +1,6 @@ use egui::{Response, Ui}; use itertools::Itertools; -use re_data_ui::item_ui; use re_entity_db::InstancePath; use re_log_types::{EntityPath, EntityPathRule}; use re_space_view::DataQueryBlueprint; @@ -111,7 +110,7 @@ impl Viewport<'_, '_> { }) .item_response; - item_ui::select_hovered_on_click(ctx, &response, item); + ctx.select_hovered_on_click(&response, item); if remove { self.blueprint.mark_user_interaction(ctx); @@ -208,7 +207,7 @@ impl Viewport<'_, '_> { self.blueprint.focus_tab(space_view.id); } - item_ui::select_hovered_on_click(ctx, &response, item); + ctx.select_hovered_on_click(&response, item); if visibility_changed { if self.blueprint.auto_layout { @@ -403,7 +402,7 @@ impl Viewport<'_, '_> { }; data_result.save_override(Some(properties), ctx); - item_ui::select_hovered_on_click(ctx, &response, item); + ctx.select_hovered_on_click(&response, item); } } diff --git a/examples/rust/custom_space_view/src/color_coordinates_space_view.rs b/examples/rust/custom_space_view/src/color_coordinates_space_view.rs index 306ad497e3b79..4de90457c8e44 100644 --- a/examples/rust/custom_space_view/src/color_coordinates_space_view.rs +++ b/examples/rust/custom_space_view/src/color_coordinates_space_view.rs @@ -277,8 +277,7 @@ fn color_space_ui( ctx.entity_db.store(), ); }); - item_ui::select_hovered_on_click( - ctx, + ctx.select_hovered_on_click( &interact, Item::InstancePath(Some(query.space_view_id), instance), );