diff options
author | Yuqian Yang <crupest@outlook.com> | 2018-10-01 17:11:11 +0000 |
---|---|---|
committer | Yuqian Yang <crupest@outlook.com> | 2018-10-01 17:11:11 +0000 |
commit | 30ecda8bb354d5982978af97aa90b5f49d9ea195 (patch) | |
tree | a271bddb244fa2041f14f8d46d249457cee09e5f /src/base.h | |
parent | 398b8f3ba535bb43c4b8593e3027c14894a7a211 (diff) | |
parent | 040a6c18f18100b825a56443a73aa1de64e4518c (diff) | |
download | cru-30ecda8bb354d5982978af97aa90b5f49d9ea195.tar.gz cru-30ecda8bb354d5982978af97aa90b5f49d9ea195.tar.bz2 cru-30ecda8bb354d5982978af97aa90b5f49d9ea195.zip |
Merge branch '9-border' into 'master'
Resolve "Abstract out border control of button and border."
Closes #9
See merge request crupest/CruUI!11
Diffstat (limited to 'src/base.h')
-rw-r--r-- | src/base.h | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -20,6 +20,7 @@ #include <memory> #include <string_view> #include <chrono> +#include <list> namespace cru { @@ -60,6 +61,12 @@ namespace cru return std::make_shared<typename Type::element_type>(std::forward<Args>(args)...); } + template<typename Type> + FunctionPtr<Type> CreateFunctionPtr(Function<Type>&& function) + { + return std::make_shared<Function<Type>>(std::move(function)); + } + inline ActionPtr CreateActionPtr(Action&& action) { return std::make_shared<Action>(std::move(action)); @@ -104,4 +111,26 @@ namespace cru using CancelablePtr = std::shared_ptr<ICancelable>; MultiByteString ToUtf8String(const StringView& string); + + + class PropertyChangedNotifyObject : public Object + { + public: + PropertyChangedNotifyObject() = default; + PropertyChangedNotifyObject(const PropertyChangedNotifyObject& other) = delete; + PropertyChangedNotifyObject(PropertyChangedNotifyObject&& other) = delete; + PropertyChangedNotifyObject& operator = (const PropertyChangedNotifyObject& other) = delete; + PropertyChangedNotifyObject& operator = (PropertyChangedNotifyObject&& other) = delete; + ~PropertyChangedNotifyObject() override = default; + + void AddPropertyChangedListener(FunctionPtr<void(String)> listener); + + void RemovePropertyChangedListener(const FunctionPtr<void(String)>& listener); + + protected: + void RaisePropertyChangedEvent(String property_name); + + private: + std::list<FunctionPtr<void(String)>> listeners_; + }; } |