From 85bb4d466efeb2540363065d7c0987a9d60f70e9 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 19 Sep 2018 01:15:01 +0800 Subject: finish animation!!! --- CruUI/base.h | 71 +++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 20 deletions(-) (limited to 'CruUI/base.h') diff --git a/CruUI/base.h b/CruUI/base.h index 99b493b1..542546fb 100644 --- a/CruUI/base.h +++ b/CruUI/base.h @@ -14,11 +14,19 @@ #include +#include +#include #include - +#include +#include +#include namespace cru { + template struct is_shared_ptr : std::false_type {}; + template struct is_shared_ptr> : std::true_type {}; + template constexpr bool is_shared_ptr_v = is_shared_ptr::value; + enum class FlowControl { Continue, @@ -28,17 +36,31 @@ namespace cru #ifdef CRU_DEBUG using String = std::wstring; #else - using String = folly::basic_fbstring; + using String = folly::basic_fbstring; #endif + using StringView = std::wstring_view; + template using Function = folly::Function; - template - using Action = Function; + template + using FunctionPtr = std::shared_ptr>; + + using Action = Function; + using ActionPtr = FunctionPtr; - template - using FlowControlAction = Function; + template + Type CreatePtr(Args&&... args) + { + static_assert(is_shared_ptr_v); + return std::make_shared(std::forward(args)...); + } + + inline ActionPtr CreateActionPtr(Action&& action) + { + return std::make_shared(std::move(action)); + } #ifdef CRU_DEBUG template @@ -48,24 +70,33 @@ namespace cru using Vector = folly::fbvector; #endif + using FloatSecond = std::chrono::duration; + class Object - { - public: - Object() = default; - Object(const Object&) = default; - Object& operator = (const Object&) = default; - Object(Object&&) = default; - Object& operator = (Object&&) = default; - virtual ~Object() = default; - }; - - struct Interface - { - virtual ~Interface() = default; - }; + { + public: + Object() = default; + Object(const Object&) = default; + Object& operator = (const Object&) = default; + Object(Object&&) = default; + Object& operator = (Object&&) = default; + virtual ~Object() = default; + }; + + struct Interface + { + virtual ~Interface() = default; + }; [[noreturn]] inline void UnreachableCode() { throw std::logic_error("Unreachable code."); } + + struct ICancelable : virtual Interface + { + virtual void Cancel() = 0; + }; + + using CancelablePtr = std::shared_ptr; } -- cgit v1.2.3