aboutsummaryrefslogtreecommitdiff
path: root/CruUI/ui/layout_base.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-09-16 23:48:54 +0800
committercrupest <crupest@outlook.com>2018-09-16 23:48:54 +0800
commit94c066a34900845297c41c134a9a910124a5833d (patch)
treefe717d4d80137c005ae3f2c1675ab3ba7d990b23 /CruUI/ui/layout_base.h
parent683419f2856d348436ca64cfd4b3abbfc73cda89 (diff)
downloadcru-94c066a34900845297c41c134a9a910124a5833d.tar.gz
cru-94c066a34900845297c41c134a9a910124a5833d.tar.bz2
cru-94c066a34900845297c41c134a9a910124a5833d.zip
Develop toggle button.
Diffstat (limited to 'CruUI/ui/layout_base.h')
-rw-r--r--CruUI/ui/layout_base.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/CruUI/ui/layout_base.h b/CruUI/ui/layout_base.h
index bae01949..08f36769 100644
--- a/CruUI/ui/layout_base.h
+++ b/CruUI/ui/layout_base.h
@@ -1,9 +1,18 @@
#pragma once
+#include "system_headers.h"
+#include <unordered_set>
+
+#include "base.h"
+#include "ui_base.h"
+
namespace cru
{
namespace ui
{
+ class Control;
+
+
enum class MeasureMode
{
Exactly,
@@ -66,5 +75,38 @@ namespace cru
MeasureLength width;
MeasureLength height;
};
+
+
+ class LayoutManager : public Object
+ {
+ public:
+ static LayoutManager* GetInstance();
+
+ public:
+ LayoutManager() = default;
+ LayoutManager(const LayoutManager& other) = delete;
+ LayoutManager(LayoutManager&& other) = delete;
+ LayoutManager& operator=(const LayoutManager& other) = delete;
+ LayoutManager& operator=(LayoutManager&& other) = delete;
+ ~LayoutManager() override = default;
+
+ //Mark position cache of the control and its descendants invalid,
+ //(which is saved as an auto-managed list internal)
+ //and send a message to refresh them.
+ void InvalidateControlPositionCache(Control* control);
+
+ //Refresh position cache of the control and its descendants whose cache
+ //has been marked as invalid.
+ void RefreshInvalidControlPositionCache();
+
+ //Refresh position cache of the control and its descendants immediately.
+ static void RefreshControlPositionCache(Control* control);
+
+ private:
+ static void RefreshControlPositionCacheInternal(Control* control, const Point& parent_lefttop_absolute);
+
+ private:
+ std::unordered_set<Control*> cache_invalid_controls_;
+ };
}
}