@@ -103,6 +103,7 @@ pub enum PlayState {
103
103
enum ActiveTimeline {
104
104
Auto ( Timeline ) ,
105
105
UserEdited ( Timeline ) ,
106
+ Pending ( Timeline ) ,
106
107
}
107
108
108
109
impl std:: ops:: Deref for ActiveTimeline {
@@ -111,7 +112,7 @@ impl std::ops::Deref for ActiveTimeline {
111
112
#[ inline]
112
113
fn deref ( & self ) -> & Self :: Target {
113
114
match self {
114
- Self :: Auto ( t) | Self :: UserEdited ( t) => t,
115
+ Self :: Auto ( t) | Self :: UserEdited ( t) | Self :: Pending ( t ) => t,
115
116
}
116
117
}
117
118
}
@@ -569,10 +570,25 @@ impl TimeControl {
569
570
false
570
571
}
571
572
572
- // If the timeline is auto refresh it every frame, otherwise only pick a new one if invalid.
573
- if matches ! ( self . timeline, ActiveTimeline :: Auto ( _) )
574
- || !is_timeline_valid ( self . timeline ( ) , times_per_timeline)
575
- {
573
+ let reset_timeline = match & self . timeline {
574
+ // If the timeline is auto refresh it every frame.
575
+ ActiveTimeline :: Auto ( _) => true ,
576
+ // If it's user edited, refresh it if it's invalid.
577
+ ActiveTimeline :: UserEdited ( timeline) => {
578
+ !is_timeline_valid ( timeline, times_per_timeline)
579
+ }
580
+ // If it's pending never automatically refresh it.
581
+ ActiveTimeline :: Pending ( timeline) => {
582
+ // If the pending timeline is valid, it shouldn't be pending anymore.
583
+ if is_timeline_valid ( timeline, times_per_timeline) {
584
+ self . set_timeline ( * timeline) ;
585
+ }
586
+
587
+ false
588
+ }
589
+ } ;
590
+
591
+ if reset_timeline {
576
592
self . timeline =
577
593
ActiveTimeline :: Auto ( default_timeline ( times_per_timeline. timelines_with_stats ( ) ) ) ;
578
594
}
@@ -593,6 +609,10 @@ impl TimeControl {
593
609
self . timeline = ActiveTimeline :: UserEdited ( timeline) ;
594
610
}
595
611
612
+ pub fn set_pending_timeline ( & mut self , timeline : Timeline ) {
613
+ self . timeline = ActiveTimeline :: Pending ( timeline) ;
614
+ }
615
+
596
616
/// The current time.
597
617
pub fn time ( & self ) -> Option < TimeReal > {
598
618
self . states
@@ -695,6 +715,11 @@ impl TimeControl {
695
715
}
696
716
}
697
717
718
+ /// Is the active timeline pending?
719
+ pub fn is_pending ( & self ) -> bool {
720
+ matches ! ( self . timeline, ActiveTimeline :: Pending ( _) )
721
+ }
722
+
698
723
pub fn set_timeline_and_time ( & mut self , timeline : Timeline , time : impl Into < TimeReal > ) {
699
724
self . timeline = ActiveTimeline :: UserEdited ( timeline) ;
700
725
self . set_time ( time) ;
0 commit comments