aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/model
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-03-13 18:51:19 +0800
committercrupest <crupest@outlook.com>2022-03-13 18:51:19 +0800
commit7320f082c4bce5939cfa7c9a23765249dac55d07 (patch)
treef51d8684d04c1d78e45f391be7965b618186231f /include/cru/ui/model
parent1d14ce416bb4e5651b956790b621308acf73b64c (diff)
downloadcru-7320f082c4bce5939cfa7c9a23765249dac55d07.tar.gz
cru-7320f082c4bce5939cfa7c9a23765249dac55d07.tar.bz2
cru-7320f082c4bce5939cfa7c9a23765249dac55d07.zip
...
Diffstat (limited to 'include/cru/ui/model')
-rw-r--r--include/cru/ui/model/IListChangeNotify.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/include/cru/ui/model/IListChangeNotify.h b/include/cru/ui/model/IListChangeNotify.h
new file mode 100644
index 00000000..a9fcd65b
--- /dev/null
+++ b/include/cru/ui/model/IListChangeNotify.h
@@ -0,0 +1,47 @@
+#pragma once
+#include "../Base.h"
+#include "cru/common/Base.h"
+#include "cru/common/Event.h"
+
+namespace cru::ui::model {
+enum ListChangeType {
+ kItemAdd,
+ kItemRemove,
+ kItemSet,
+ kItemMove,
+ kClear,
+};
+
+struct CRU_UI_API ListChange {
+ ListChangeType type;
+ union {
+ Index position;
+ };
+ union {
+ Index count;
+ Index new_position;
+ };
+
+ constexpr static ListChange ItemAdd(Index index, Index count = 1) {
+ return {ListChangeType::kItemAdd, index, count};
+ }
+
+ constexpr static ListChange ItemRemove(Index index, Index count = 1) {
+ return {ListChangeType::kItemRemove, index, count};
+ }
+
+ constexpr static ListChange ItemSet(Index index, Index count = 1) {
+ return {ListChangeType::kItemSet, index, count};
+ }
+
+ constexpr static ListChange ItemMove(Index position, Index new_position) {
+ return {ListChangeType::kItemMove, position, new_position};
+ }
+
+ constexpr static ListChange Clear() { return {ListChangeType::kClear}; }
+};
+
+struct CRU_UI_API IListChangeNotify : virtual Interface {
+ virtual IEvent<ListChange>* ListChangeEvent() = 0;
+};
+} // namespace cru::ui::model