aboutsummaryrefslogtreecommitdiff
path: root/src/base.h
diff options
context:
space:
mode:
authorYuqian Yang <crupest@outlook.com>2018-10-01 17:11:11 +0000
committerYuqian Yang <crupest@outlook.com>2018-10-01 17:11:11 +0000
commit30ecda8bb354d5982978af97aa90b5f49d9ea195 (patch)
treea271bddb244fa2041f14f8d46d249457cee09e5f /src/base.h
parent398b8f3ba535bb43c4b8593e3027c14894a7a211 (diff)
parent040a6c18f18100b825a56443a73aa1de64e4518c (diff)
downloadcru-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.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/base.h b/src/base.h
index 7ef78014..18bf9cc5 100644
--- a/src/base.h
+++ b/src/base.h
@@ -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_;
+ };
}