mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 02:20:04 +00:00 
			
		
		
		
	Timeline pause
This commit is contained in:
		
							parent
							
								
									41b9e25ea8
								
							
						
					
					
						commit
						ba1de683fa
					
				
					 6 changed files with 79 additions and 36 deletions
				
			
		|  | @ -42,6 +42,7 @@ public: | |||
| 
 | ||||
|    TimelineManager* self_; | ||||
| 
 | ||||
|    void Pause(); | ||||
|    void Play(); | ||||
|    void SelectTime(std::chrono::system_clock::time_point selectedTime = {}); | ||||
|    void Step(Direction direction); | ||||
|  | @ -55,6 +56,7 @@ public: | |||
|    std::chrono::minutes                  loopTime_ {30}; | ||||
|    double                                loopSpeed_ {1.0}; | ||||
| 
 | ||||
|    types::AnimationState     animationState_ {types::AnimationState::Pause}; | ||||
|    boost::asio::steady_timer animationTimer_ {scwx::util::io_context()}; | ||||
|    std::mutex                animationTimerMutex_ {}; | ||||
| 
 | ||||
|  | @ -145,6 +147,8 @@ void TimelineManager::AnimationStepBegin() | |||
| { | ||||
|    logger_->debug("AnimationStepBegin"); | ||||
| 
 | ||||
|    p->Pause(); | ||||
| 
 | ||||
|    if (p->viewType_ == types::MapTime::Live || | ||||
|        p->pinnedTime_ == std::chrono::system_clock::time_point {}) | ||||
|    { | ||||
|  | @ -162,25 +166,29 @@ void TimelineManager::AnimationStepBack() | |||
| { | ||||
|    logger_->debug("AnimationStepBack"); | ||||
| 
 | ||||
|    p->Pause(); | ||||
|    p->Step(Direction::Back); | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::AnimationPlay() | ||||
| void TimelineManager::AnimationPlayPause() | ||||
| { | ||||
|    logger_->debug("AnimationPlay"); | ||||
| 
 | ||||
|    p->Play(); | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::AnimationPause() | ||||
| { | ||||
|    logger_->debug("AnimationPause"); | ||||
|    if (p->animationState_ == types::AnimationState::Pause) | ||||
|    { | ||||
|       logger_->debug("AnimationPlay"); | ||||
|       p->Play(); | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|       logger_->debug("AnimationPause"); | ||||
|       p->Pause(); | ||||
|    } | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::AnimationStepNext() | ||||
| { | ||||
|    logger_->debug("AnimationStepNext"); | ||||
| 
 | ||||
|    p->Pause(); | ||||
|    p->Step(Direction::Next); | ||||
| } | ||||
| 
 | ||||
|  | @ -188,6 +196,8 @@ void TimelineManager::AnimationStepEnd() | |||
| { | ||||
|    logger_->debug("AnimationStepEnd"); | ||||
| 
 | ||||
|    p->Pause(); | ||||
| 
 | ||||
|    if (p->viewType_ == types::MapTime::Live) | ||||
|    { | ||||
|       // If the selected view type is live, select the current products
 | ||||
|  | @ -200,10 +210,29 @@ void TimelineManager::AnimationStepEnd() | |||
|    } | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::Impl::Pause() | ||||
| { | ||||
|    // Cancel animation
 | ||||
|    std::unique_lock animationTimerLock {animationTimerMutex_}; | ||||
|    animationTimer_.cancel(); | ||||
| 
 | ||||
|    if (animationState_ != types::AnimationState::Pause) | ||||
|    { | ||||
|       animationState_ = types::AnimationState::Pause; | ||||
|       emit self_->AnimationStateUpdated(animationState_); | ||||
|    } | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::Impl::Play() | ||||
| { | ||||
|    using namespace std::chrono_literals; | ||||
| 
 | ||||
|    if (animationState_ != types::AnimationState::Play) | ||||
|    { | ||||
|       animationState_ = types::AnimationState::Play; | ||||
|       emit self_->AnimationStateUpdated(animationState_); | ||||
|    } | ||||
| 
 | ||||
|    { | ||||
|       std::unique_lock animationTimerLock {animationTimerMutex_}; | ||||
|       animationTimer_.cancel(); | ||||
|  | @ -260,7 +289,10 @@ void TimelineManager::Impl::Play() | |||
|             { | ||||
|                if (e == boost::system::errc::success) | ||||
|                { | ||||
|                   Play(); | ||||
|                   if (animationState_ == types::AnimationState::Play) | ||||
|                   { | ||||
|                      Play(); | ||||
|                   } | ||||
|                } | ||||
|                else if (e == boost::asio::error::operation_aborted) | ||||
|                { | ||||
|  |  | |||
|  | @ -35,8 +35,7 @@ public slots: | |||
| 
 | ||||
|    void AnimationStepBegin(); | ||||
|    void AnimationStepBack(); | ||||
|    void AnimationPlay(); | ||||
|    void AnimationPause(); | ||||
|    void AnimationPlayPause(); | ||||
|    void AnimationStepNext(); | ||||
|    void AnimationStepEnd(); | ||||
| 
 | ||||
|  | @ -44,6 +43,7 @@ signals: | |||
|    void SelectedTimeUpdated(std::chrono::system_clock::time_point dateTime); | ||||
|    void VolumeTimeUpdated(std::chrono::system_clock::time_point dateTime); | ||||
| 
 | ||||
|    void AnimationStateUpdated(types::AnimationState state); | ||||
|    void ViewTypeUpdated(types::MapTime viewType); | ||||
| 
 | ||||
| private: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat