diff options
author | crupest <crupest@outlook.com> | 2018-09-25 13:08:40 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2018-09-25 13:08:40 +0800 |
commit | 4b86554a0354d78efeb40e551eaccaac0fecd1d1 (patch) | |
tree | c8a73d848401f523ff91fe8ed1b0887aa88bbfb8 /CruUI/ui/animations/animation.h | |
parent | cea138417c54d6cf8043b6334c22e3af957d26f8 (diff) | |
download | cru-4b86554a0354d78efeb40e551eaccaac0fecd1d1.tar.gz cru-4b86554a0354d78efeb40e551eaccaac0fecd1d1.tar.bz2 cru-4b86554a0354d78efeb40e551eaccaac0fecd1d1.zip |
Change the structure of project.
Diffstat (limited to 'CruUI/ui/animations/animation.h')
-rw-r--r-- | CruUI/ui/animations/animation.h | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/CruUI/ui/animations/animation.h b/CruUI/ui/animations/animation.h deleted file mode 100644 index 69b08b0c..00000000 --- a/CruUI/ui/animations/animation.h +++ /dev/null @@ -1,107 +0,0 @@ -#pragma once - -#include <unordered_map> - -#include "base.h" -#include "application.h" -#include "timer.h" - -namespace cru::ui::animations -{ - using AnimationTimeUnit = FloatSecond; - - - using IAnimationDelegate = ICancelable; - using AnimationDelegatePtr = CancelablePtr; - - using AnimationStepHandlerPtr = FunctionPtr<void(AnimationDelegatePtr, double)>; - using AnimationStartHandlerPtr = FunctionPtr<void(AnimationDelegatePtr)>; - - - namespace details - { - class Animation; - using AnimationPtr = std::unique_ptr<Animation>; - - class AnimationManager : public Object - { - public: - static AnimationManager* GetInstance() - { - return Application::GetInstance()->GetAnimationManager(); - } - - public: - AnimationManager(); - AnimationManager(const AnimationManager& other) = delete; - AnimationManager(AnimationManager&& other) = delete; - AnimationManager& operator=(const AnimationManager& other) = delete; - AnimationManager& operator=(AnimationManager&& other) = delete; - ~AnimationManager() override; - - AnimationDelegatePtr CreateAnimation( - String tag, - AnimationTimeUnit duration, - Vector<AnimationStepHandlerPtr> step_handlers, - Vector<AnimationStartHandlerPtr> start_handlers, - Vector<ActionPtr> finish_handlers, - Vector<ActionPtr> cancel_handlers - ); - void RemoveAnimation(const String& tag); - - private: - void SetTimer(); - void KillTimer(); - - private: - std::unordered_map<String, AnimationPtr> animations_; - std::shared_ptr<ICancelable> timer_; - ActionPtr timer_action_; - }; - } - - class AnimationBuilder : public Object - { - public: - AnimationBuilder(String tag, const AnimationTimeUnit duration) - : tag(std::move(tag)), duration(duration) - { - - } - - String tag; - AnimationTimeUnit duration; - - AnimationBuilder& AddStepHandler(AnimationStepHandlerPtr handler) - { - step_handlers_.push_back(std::move(handler)); - return *this; - } - - AnimationBuilder& AddStartHandler(AnimationStartHandlerPtr handler) - { - start_handlers_.push_back(std::move(handler)); - return *this; - } - - AnimationBuilder& AddFinishHandler(ActionPtr handler) - { - finish_handlers_.push_back(std::move(handler)); - return *this; - } - - AnimationBuilder& AddCancelHandler(ActionPtr handler) - { - cancel_handlers_.push_back(std::move(handler)); - return *this; - } - - AnimationDelegatePtr Start() const; - - private: - Vector<AnimationStepHandlerPtr> step_handlers_; - Vector<AnimationStartHandlerPtr> start_handlers_; - Vector<ActionPtr> finish_handlers_; - Vector<ActionPtr> cancel_handlers_; - }; -} |