Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing click and hover interactions for views #8495

Merged
merged 5 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/viewer/re_view_graph/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ Display a graph of nodes and edges.
}
});

if resp.hovered() {
ctx.selection_state().set_hovered(Item::View(query.view_id));
}

if resp.clicked() {
// clicked elsewhere, select the view
ctx.selection_state()
Expand Down
2 changes: 2 additions & 0 deletions crates/viewer/re_view_map/src/map_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ fn handle_ui_interactions(
// clicked elsewhere, select the view
ctx.selection_state()
.set_selection(Item::View(query.view_id));
} else if map_response.hovered() {
ctx.selection_state().set_hovered(Item::View(query.view_id));
}
}

Expand Down
22 changes: 17 additions & 5 deletions crates/viewer/re_view_text_document/src/view_class.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use egui::Label;

use egui::Sense;
use re_types::View;
use re_types::ViewClassIdentifier;
use re_ui::UiExt as _;
use re_view::suggest_view_for_each_entity;

use re_viewer_context::Item;
use re_viewer_context::{
external::re_log_types::EntityPath, ViewClass, ViewClassRegistryError, ViewId, ViewQuery,
ViewState, ViewStateExt as _, ViewSystemExecutionError, ViewerContext,
Expand Down Expand Up @@ -111,17 +113,16 @@ Displays text from a text component, as raw text or markdown."

fn ui(
&self,
_ctx: &ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
state: &mut dyn ViewState,

_query: &ViewQuery<'_>,
query: &ViewQuery<'_>,
system_output: re_viewer_context::SystemExecutionOutput,
) -> Result<(), ViewSystemExecutionError> {
let state = state.downcast_mut::<TextDocumentViewState>()?;
let text_document = system_output.view_systems.get::<TextDocumentSystem>()?;

egui::Frame {
let response = egui::Frame {
inner_margin: re_ui::DesignTokens::view_padding().into(),
..egui::Frame::default()
}
Expand Down Expand Up @@ -176,7 +177,18 @@ Displays text from a text component, as raw text or markdown."
})
})
.response
});
})
.response
.interact(Sense::click());

if response.hovered() {
ctx.selection_state().set_hovered(Item::View(query.view_id));
}

if response.clicked() {
ctx.selection_state()
.set_selection(Item::View(query.view_id));
}

Ok(())
}
Expand Down
17 changes: 17 additions & 0 deletions tests/python/release_checklist/check_hover_select_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
* If you think this is unexpected, create an issue.
* Double-click the entity and verify that it becomes selected and highlighted in the blueprint tree.

### Graph Select
Should work just as 2D/3D views.

### Text view
Clicking on a text view (what you're reading right now) should select the view.
Hovering the view should work as well.

### Reset
For each of the views:
* Zoom and/or pan the view
Expand Down Expand Up @@ -83,13 +90,23 @@ def log_points_2d() -> None:
rr.log("2D/points", rr.Points2D(positions, colors=colors, radii=radii))


def log_graph() -> None:
rr.log("graph", rr.GraphNodes(["a", "b"], labels=["A", "B"]))


def log_map() -> None:
rr.log("points", rr.GeoPoints(lat_lon=[[47.6344, 19.1397], [47.6334, 19.1399]], radii=rr.Radius.ui_points(20.0)))


def run(args: Namespace) -> None:
rr.script_setup(args, f"{os.path.basename(__file__)}", recording_id=uuid4())

log_readme()
log_plots()
log_points_3d()
log_points_2d()
log_graph()
log_map()


if __name__ == "__main__":
Expand Down
Loading