Skip to content

Commit 571c37e

Browse files
committed
replace item_ui::select_hovered_on_click wit ctx.select_hovered_on_click
1 parent 3433b16 commit 571c37e

7 files changed

Lines changed: 12 additions & 25 deletions

File tree

crates/re_data_ui/src/item_ui.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use re_entity_db::{EntityTree, InstancePath};
66
use re_log_types::{ComponentPath, EntityPath, TimeInt, Timeline};
77
use re_ui::SyntaxHighlighting;
88
use re_viewer_context::{
9-
DataQueryId, HoverHighlight, Item, Selection, SpaceViewId, UiVerbosity, ViewerContext,
9+
DataQueryId, HoverHighlight, Item, SpaceViewId, UiVerbosity, ViewerContext,
1010
};
1111

1212
use super::DataUi;
@@ -330,7 +330,7 @@ pub fn cursor_interact_with_selectable(
330330
let is_item_hovered =
331331
ctx.selection_state().highlight_for_ui_element(&item) == HoverHighlight::Hovered;
332332

333-
select_hovered_on_click(ctx, &response, item);
333+
ctx.select_hovered_on_click(&response, item);
334334
// TODO(andreas): How to deal with shift click for selecting ranges?
335335

336336
if is_item_hovered {
@@ -340,16 +340,6 @@ pub fn cursor_interact_with_selectable(
340340
}
341341
}
342342

343-
// TODO(andreas): Move elsewhere, this is not directly part of the item_ui.
344-
pub fn select_hovered_on_click(
345-
ctx: &ViewerContext<'_>,
346-
response: &egui::Response,
347-
selection: impl Into<Selection>,
348-
) {
349-
// TODO: inline everywhere.
350-
ctx.select_hovered_on_click(response, selection);
351-
}
352-
353343
/// Displays the "hover card" (i.e. big tooltip) for an instance or an entity.
354344
///
355345
/// The entity hover card is displayed the provided instance path is a splat.

crates/re_space_view_spatial/src/ui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ pub fn picking(
661661
});
662662
};
663663

664-
item_ui::select_hovered_on_click(ctx, &response, re_viewer_context::Selection(hovered_items));
664+
ctx.select_hovered_on_click( &response, re_viewer_context::Selection(hovered_items));
665665

666666
Ok(response)
667667
}

crates/re_time_panel/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ mod time_selection_ui;
1313
use egui::emath::Rangef;
1414
use egui::{pos2, Color32, CursorIcon, NumExt, Painter, PointerButton, Rect, Shape, Ui, Vec2};
1515

16-
use re_data_ui::item_ui;
1716
use re_entity_db::{EntityTree, InstancePath, TimeHistogram};
1817
use re_log_types::{
1918
external::re_types_core::ComponentName, ComponentPath, EntityPath, EntityPathPart, TimeInt,
@@ -602,7 +601,7 @@ impl TimePanel {
602601
);
603602
});
604603

605-
item_ui::select_hovered_on_click(ctx, &response, item.to_item());
604+
ctx.select_hovered_on_click(&response, item.to_item());
606605

607606
let is_closed = body_response.is_none();
608607
let response_rect = response.rect;
@@ -713,7 +712,7 @@ impl TimePanel {
713712

714713
ui.set_clip_rect(clip_rect_save);
715714

716-
re_data_ui::item_ui::select_hovered_on_click(ctx, &response, item.to_item());
715+
ctx.select_hovered_on_click(&response, item.to_item());
717716

718717
let response_rect = response.rect;
719718

crates/re_viewer/src/ui/selection_panel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ fn show_list_item_for_container_child(
776776

777777
let response = list_item.show(ui);
778778

779-
item_ui::select_hovered_on_click(ctx, &response, std::iter::once(item));
779+
ctx.select_hovered_on_click(&response, std::iter::once(item));
780780

781781
if remove_contents {
782782
viewport.blueprint.mark_user_interaction(ctx);

crates/re_viewport/src/viewport.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use ahash::HashMap;
88

99
use egui_tiles::Behavior as _;
1010
use once_cell::sync::Lazy;
11-
use re_data_ui::item_ui;
1211
use re_entity_db::EntityPropertyMap;
1312

1413
use re_ui::{Icon, ReUi};
@@ -580,7 +579,8 @@ impl<'a, 'b> egui_tiles::Behavior<SpaceViewId> for TabViewer<'a, 'b> {
580579
}
581580

582581
if let Some(egui_tiles::Tile::Pane(space_view_id)) = tiles.get(tile_id) {
583-
item_ui::select_hovered_on_click(self.ctx, &response, Item::SpaceView(*space_view_id));
582+
self.ctx
583+
.select_hovered_on_click(&response, Item::SpaceView(*space_view_id));
584584
}
585585

586586
response

crates/re_viewport/src/viewport_blueprint_ui.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use egui::{Response, Ui};
22
use itertools::Itertools;
33

4-
use re_data_ui::item_ui;
54
use re_entity_db::InstancePath;
65
use re_log_types::{EntityPath, EntityPathRule};
76
use re_space_view::DataQueryBlueprint;
@@ -111,7 +110,7 @@ impl Viewport<'_, '_> {
111110
})
112111
.item_response;
113112

114-
item_ui::select_hovered_on_click(ctx, &response, item);
113+
ctx.select_hovered_on_click(&response, item);
115114

116115
if remove {
117116
self.blueprint.mark_user_interaction(ctx);
@@ -208,7 +207,7 @@ impl Viewport<'_, '_> {
208207
self.blueprint.focus_tab(space_view.id);
209208
}
210209

211-
item_ui::select_hovered_on_click(ctx, &response, item);
210+
ctx.select_hovered_on_click(&response, item);
212211

213212
if visibility_changed {
214213
if self.blueprint.auto_layout {
@@ -403,7 +402,7 @@ impl Viewport<'_, '_> {
403402
};
404403
data_result.save_override(Some(properties), ctx);
405404

406-
item_ui::select_hovered_on_click(ctx, &response, item);
405+
ctx.select_hovered_on_click(&response, item);
407406
}
408407
}
409408

examples/rust/custom_space_view/src/color_coordinates_space_view.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,7 @@ fn color_space_ui(
277277
ctx.entity_db.store(),
278278
);
279279
});
280-
item_ui::select_hovered_on_click(
281-
ctx,
280+
ctx.select_hovered_on_click(
282281
&interact,
283282
Item::InstancePath(Some(query.space_view_id), instance),
284283
);

0 commit comments

Comments
 (0)