Skip to content

Commit

Permalink
replace item_ui::select_hovered_on_click wit ctx.select_hovered_on_click
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Jan 30, 2024
1 parent 3433b16 commit 571c37e
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 25 deletions.
14 changes: 2 additions & 12 deletions crates/re_data_ui/src/item_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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<Selection>,
) {
// 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.
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_spatial/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions crates/re_time_panel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/ui/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions crates/re_viewport/src/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -580,7 +579,8 @@ impl<'a, 'b> egui_tiles::Behavior<SpaceViewId> 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
Expand Down
7 changes: 3 additions & 4 deletions crates/re_viewport/src/viewport_blueprint_ui.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
Expand Down

0 comments on commit 571c37e

Please sign in to comment.