mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 08:50:05 +00:00 
			
		
		
		
	Starting some timeline manager stubs
This commit is contained in:
		
							parent
							
								
									e1ec81e230
								
							
						
					
					
						commit
						3bee6f65e5
					
				
					 2 changed files with 123 additions and 0 deletions
				
			
		|  | @ -1,5 +1,9 @@ | |||
| #include <scwx/qt/manager/timeline_manager.hpp> | ||||
| #include <scwx/util/logger.hpp> | ||||
| #include <scwx/util/threads.hpp> | ||||
| #include <scwx/util/time.hpp> | ||||
| 
 | ||||
| #include <fmt/chrono.h> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
|  | @ -19,11 +23,109 @@ public: | |||
|    ~Impl() {} | ||||
| 
 | ||||
|    TimelineManager* self_; | ||||
| 
 | ||||
|    void SelectTime(std::chrono::system_clock::time_point selectedTime = {}); | ||||
| 
 | ||||
|    std::chrono::system_clock::time_point pinnedTime_ {}; | ||||
|    std::chrono::system_clock::time_point currentTime_ {}; | ||||
|    types::MapTime                        viewType_ {types::MapTime::Live}; | ||||
|    std::chrono::minutes                  loopTime_ {30}; | ||||
|    double                                loopSpeed_ {1.0}; | ||||
| }; | ||||
| 
 | ||||
| TimelineManager::TimelineManager() : p(std::make_unique<Impl>(this)) {} | ||||
| TimelineManager::~TimelineManager() = default; | ||||
| 
 | ||||
| void TimelineManager::SetDateTime( | ||||
|    std::chrono::system_clock::time_point dateTime) | ||||
| { | ||||
|    logger_->debug("SetDateTime: {}", scwx::util::TimeString(dateTime)); | ||||
| 
 | ||||
|    p->pinnedTime_ = dateTime; | ||||
| 
 | ||||
|    if (p->viewType_ == types::MapTime::Archive) | ||||
|    { | ||||
|       // Only select if the view type is archive
 | ||||
|       p->SelectTime(dateTime); | ||||
|    } | ||||
| 
 | ||||
|    // Ignore a date/time selection if the view type is live
 | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::SetViewType(types::MapTime viewType) | ||||
| { | ||||
|    logger_->debug("SetViewType: {}", types::GetMapTimeName(viewType)); | ||||
| 
 | ||||
|    p->viewType_ = viewType; | ||||
| 
 | ||||
|    if (p->viewType_ == types::MapTime::Live) | ||||
|    { | ||||
|       // If the selected view type is live, select the current products
 | ||||
|       p->SelectTime(); | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|       // If the selected view type is archive, select using the pinned time
 | ||||
|       p->SelectTime(p->pinnedTime_); | ||||
|    } | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::SetLoopTime(std::chrono::minutes loopTime) | ||||
| { | ||||
|    logger_->debug("SetLoopTime: {}", loopTime); | ||||
| 
 | ||||
|    p->loopTime_ = loopTime; | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::SetLoopSpeed(double loopSpeed) | ||||
| { | ||||
|    logger_->debug("SetLoopSpeed: {}", loopSpeed); | ||||
| 
 | ||||
|    p->loopSpeed_ = loopSpeed; | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::AnimationStepBegin() | ||||
| { | ||||
|    logger_->debug("AnimationStepBegin"); | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::AnimationStepBack() | ||||
| { | ||||
|    logger_->debug("AnimationStepBack"); | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::AnimationPlay() | ||||
| { | ||||
|    logger_->debug("AnimationPlay"); | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::AnimationPause() | ||||
| { | ||||
|    logger_->debug("AnimationPause"); | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::AnimationStepNext() | ||||
| { | ||||
|    logger_->debug("AnimationStepNext"); | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::AnimationStepEnd() | ||||
| { | ||||
|    logger_->debug("AnimationStepEnd"); | ||||
| } | ||||
| 
 | ||||
| void TimelineManager::Impl::SelectTime( | ||||
|    std::chrono::system_clock::time_point selectedTime) | ||||
| { | ||||
|    if (currentTime_ == selectedTime) | ||||
|    { | ||||
|       // Nothing to do
 | ||||
|       return; | ||||
|    } | ||||
| 
 | ||||
|    currentTime_ = selectedTime; | ||||
| } | ||||
| 
 | ||||
| std::shared_ptr<TimelineManager> TimelineManager::Instance() | ||||
| { | ||||
|    static std::weak_ptr<TimelineManager> timelineManagerReference_ {}; | ||||
|  |  | |||
|  | @ -1,5 +1,8 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <scwx/qt/types/map_types.hpp> | ||||
| 
 | ||||
| #include <chrono> | ||||
| #include <memory> | ||||
| 
 | ||||
| #include <QObject> | ||||
|  | @ -21,6 +24,24 @@ public: | |||
| 
 | ||||
|    static std::shared_ptr<TimelineManager> Instance(); | ||||
| 
 | ||||
| public slots: | ||||
|    void SetDateTime(std::chrono::system_clock::time_point dateTime); | ||||
|    void SetViewType(types::MapTime viewType); | ||||
| 
 | ||||
|    void SetLoopTime(std::chrono::minutes loopTime); | ||||
|    void SetLoopSpeed(double loopSpeed); | ||||
| 
 | ||||
|    void AnimationStepBegin(); | ||||
|    void AnimationStepBack(); | ||||
|    void AnimationPlay(); | ||||
|    void AnimationPause(); | ||||
|    void AnimationStepNext(); | ||||
|    void AnimationStepEnd(); | ||||
| 
 | ||||
| signals: | ||||
|    void TimeUpdated(std::chrono::system_clock::time_point dateTime); | ||||
|    void ViewTypeUpdated(types::MapTime viewType); | ||||
| 
 | ||||
| private: | ||||
|    class Impl; | ||||
|    std::unique_ptr<Impl> p; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat