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

Track changed state in nav mode combo box #1703

Merged
merged 2 commits into from
Mar 27, 2023
Merged
Changes from 1 commit
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
19 changes: 12 additions & 7 deletions crates/re_viewer/src/ui/view_spatial/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,24 +315,29 @@ impl ViewSpatialState {
.on_hover_text("The virtual camera which controls what is shown on screen.");
ui.vertical(|ui| {
let mut nav_mode = *self.nav_mode.get();
let nav_mode_response = egui::ComboBox::from_id_source("nav_mode")
let changed = egui::ComboBox::from_id_source("nav_mode")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment with a link to an egui issue would be nice if we go that route

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ComboBox just opens a ui - it can't/shouldn't know if anything in that ui changes

.selected_text(nav_mode)
.show_ui(ui, |ui| {
ui.style_mut().wrap = Some(false);
ui.set_min_width(64.0);

ui.selectable_value(
let mut changed = false;

changed |= ui.selectable_value(
&mut nav_mode,
SpatialNavigationMode::TwoD,
SpatialNavigationMode::TwoD,
);
ui.selectable_value(
).changed();

changed |= ui.selectable_value(
&mut nav_mode,
SpatialNavigationMode::ThreeD,
SpatialNavigationMode::ThreeD,
);
}).response;
if nav_mode_response.changed() {
).changed();

changed
}).inner.unwrap_or(false);
if changed {
self.nav_mode = EditableAutoValue::UserEdited(nav_mode);
}

Expand Down