aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/controls/Control.h
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-11-17 13:52:52 +0800
committerYuqian Yang <crupest@crupest.life>2025-11-17 13:52:52 +0800
commitf7c4d19df66c602d74795e98ce2ee4390d06fbb4 (patch)
tree5d91dc18ae8129652d4c5b88234d0bb7b93dcf13 /include/cru/ui/controls/Control.h
parentc9f31440d65a867e2316e9a19ee3f5db2d0e53a7 (diff)
downloadcru-f7c4d19df66c602d74795e98ce2ee4390d06fbb4.tar.gz
cru-f7c4d19df66c602d74795e98ce2ee4390d06fbb4.tar.bz2
cru-f7c4d19df66c602d74795e98ce2ee4390d06fbb4.zip
Harden delete after free.
Diffstat (limited to 'include/cru/ui/controls/Control.h')
-rw-r--r--include/cru/ui/controls/Control.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/cru/ui/controls/Control.h b/include/cru/ui/controls/Control.h
index 684bc960..94de4cdc 100644
--- a/include/cru/ui/controls/Control.h
+++ b/include/cru/ui/controls/Control.h
@@ -1,12 +1,14 @@
#pragma once
#include "../Base.h"
#include "../DeleteLater.h"
+#include "../events/KeyEventArgs.h"
+#include "../events/MouseWheelEventArgs.h"
#include "../events/UiEvents.h"
+#include "../render/MeasureRequirement.h"
#include "../render/RenderObject.h"
#include "../style/StyleRuleSet.h"
-#include "cru/ui/events/KeyEventArgs.h"
-#include "cru/ui/events/MouseWheelEventArgs.h"
-#include "cru/ui/render/MeasureRequirement.h"
+
+#include <cru/base/SelfResolvable.h>
namespace cru::ui::controls {
@@ -19,7 +21,9 @@ namespace cru::ui::controls {
* - RemoveChild(Control* child)
* The last two methods are totally for convenient control tree management.
*/
-class CRU_UI_API Control : public Object, public DeleteLaterImpl {
+class CRU_UI_API Control : public Object,
+ public DeleteLaterImpl,
+ public SelfResolvable<Control> {
friend class RootControl;
CRU_DEFINE_CLASS_LOG_TAG("Control")
@@ -41,6 +45,7 @@ class CRU_UI_API Control : public Object, public DeleteLaterImpl {
Control* GetParent() const { return parent_; }
void SetParent(Control* parent);
+ bool HasAncestor(Control* control);
virtual void ForEachChild(const std::function<void(Control*)>& predicate) = 0;