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

Fix not being able to set time series y axis ranges from ui #6384

Merged
merged 1 commit into from
May 20, 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
6 changes: 3 additions & 3 deletions crates/re_space_view_time_series/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ fn axis_ui(
});

if !auto_range {
let range_edit = y_range
let mut range_edit = y_range
.unwrap_or_else(|| y_range.unwrap_or(state.saved_y_axis_range.into()));

ui.horizontal(|ui| {
Expand All @@ -718,13 +718,13 @@ fn axis_ui(
let speed = ((prev_max - prev_min) * 0.01).at_least(0.001);
ui.label("Min");
ui.add(
egui::DragValue::new(&mut range_edit.start())
egui::DragValue::new(range_edit.start_mut())
.speed(speed)
.clamp_range(std::f64::MIN..=prev_max),
);
ui.label("Max");
ui.add(
egui::DragValue::new(&mut range_edit.end())
egui::DragValue::new(range_edit.end_mut())
.speed(speed)
.clamp_range(prev_min..=std::f64::MAX),
);
Expand Down
12 changes: 12 additions & 0 deletions crates/re_types/src/components/range1d_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ impl Range1D {
pub fn end(&self) -> f64 {
self.0 .0[1]
}

/// The start of the range.
#[inline]
pub fn start_mut(&mut self) -> &mut f64 {
&mut self.0 .0[0]
}

/// The end of the range.
#[inline]
pub fn end_mut(&mut self) -> &mut f64 {
&mut self.0 .0[1]
}
}

impl From<Range1D> for emath::Rangef {
Expand Down
Loading