-
Notifications
You must be signed in to change notification settings - Fork 373
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
Automatically select user timeline if no timeline was explicitly selected yet #2986
Conversation
.or_insert_with(|| TimeState::new(view.min)) | ||
.view = Some(view); | ||
} | ||
|
||
/// The range of time we are currently zoomed in on. | ||
pub fn reset_time_view(&mut self) { | ||
if let Some(state) = self.states.get_mut(&self.timeline) { | ||
if let Some(state) = self.states.get_mut(self.timeline.get()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of changing all &foo
to foo.get()
, just implement Deref
for EditableAutoValue
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for those cases I still need get()
due to the way Deref works in rust: *self.timeline
gives the underlying Timeline
by value. But with Deref
in place *self.timeline.get()
becomes *self.timeline
and self.timeline.get().typ()
becomes self.timeline.typ()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could ofc also do &*self.timeline.get()
if that's preferred
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean do &*self.timeline
// If the timeline is auto refresh it every frame, otherwise only pick a new one if invalid. | ||
if self.timeline.is_auto() || !is_timeline_valid(self.timeline(), times_per_timeline) { | ||
self.timeline = EditableAutoValue::Auto( | ||
default_timeline(times_per_timeline.timelines()).map_or(Default::default(), |t| *t), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alphabetical order behavior is a bit unexpected (though I agree still a net improvement).
Since times_per_timeline
persists with the EntityDb, internally tracking insertion order as part of TimesPerTimeline::insert()
wouldn't be all that painful though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I think you're right. I'll try to go the extra step tomorrow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
poked it a bit, but changing this BTreeMap of timelines right now is a bit too annoying for the moment and then it gets less viable for a patch release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement. Seems to work for me.
…cted yet (#2986) * Fixes #2186 Slight deviation from the desired behavior from the ticket: We'll always select the user timeline which is _alphabetically first_. I deem this good enough though and an improvement in any case! Going back the the "auto select" state is not possible explicitely, but will happen if for whatever reason no user timeline is available anymore. Tested as seen in the video and then confirmed separately the described alphabetic behavior https://github.com/rerun-io/rerun/assets/1220815/0d3303d7-7b19-4854-993d-0523b3e35cbb ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2986) (if applicable) - [PR Build Summary](https://build.rerun.io/pr/2986) - [Docs preview](https://rerun.io/preview/pr%3Aandreas%2Ffix-timeline-auto-select/docs) - [Examples preview](https://rerun.io/preview/pr%3Aandreas%2Ffix-timeline-auto-select/examples)
…cted yet (#2986) * Fixes #2186 Slight deviation from the desired behavior from the ticket: We'll always select the user timeline which is _alphabetically first_. I deem this good enough though and an improvement in any case! Going back the the "auto select" state is not possible explicitely, but will happen if for whatever reason no user timeline is available anymore. Tested as seen in the video and then confirmed separately the described alphabetic behavior https://github.com/rerun-io/rerun/assets/1220815/0d3303d7-7b19-4854-993d-0523b3e35cbb ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2986) (if applicable) - [PR Build Summary](https://build.rerun.io/pr/2986) - [Docs preview](https://rerun.io/preview/pr%3Aandreas%2Ffix-timeline-auto-select/docs) - [Examples preview](https://rerun.io/preview/pr%3Aandreas%2Ffix-timeline-auto-select/examples)
Slight deviation from the desired behavior from the ticket: We'll always select the user timeline which is alphabetically first. I deem this good enough though and an improvement in any case!
Going back the the "auto select" state is not possible explicitely, but will happen if for whatever reason no user timeline is available anymore.
Tested as seen in the video and then confirmed separately the described alphabetic behavior
Screen.Recording.2023-08-15.at.16.17.20.mov
Checklist