aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-11-19 02:59:30 +0800
committerYuqian Yang <crupest@crupest.life>2025-11-19 02:59:30 +0800
commit2eb34dfc3dd3ca718da6ebf049886b4ae140b332 (patch)
treec43dbca6e6898fd474ca9b976b4bf21b3419e512 /include
parentdf2dadbd0f0ace6e02281c84218537ec2ce5c47f (diff)
downloadcru-2eb34dfc3dd3ca718da6ebf049886b4ae140b332.tar.gz
cru-2eb34dfc3dd3ca718da6ebf049886b4ae140b332.tar.bz2
cru-2eb34dfc3dd3ca718da6ebf049886b4ae140b332.zip
Remove all children when control destroyed.
Diffstat (limited to 'include')
-rw-r--r--include/cru/ui/components/Menu.h4
-rw-r--r--include/cru/ui/controls/ControlHost.h4
-rw-r--r--include/cru/ui/controls/Window.h5
3 files changed, 8 insertions, 5 deletions
diff --git a/include/cru/ui/components/Menu.h b/include/cru/ui/components/Menu.h
index 92731f2e..a8a90ed7 100644
--- a/include/cru/ui/components/Menu.h
+++ b/include/cru/ui/components/Menu.h
@@ -70,7 +70,7 @@ class CRU_UI_API PopupMenu : public Component {
public:
controls::Control* GetRootControl() override;
- controls::Window* GetPopup() { return popup_; }
+ controls::Window* GetPopup() { return popup_.get(); }
Menu* GetMenu() { return &menu_; }
// position relative to screen left top.
@@ -86,7 +86,7 @@ class CRU_UI_API PopupMenu : public Component {
private:
controls::Control* attached_control_;
- controls::Window* popup_;
+ std::unique_ptr<controls::Window> popup_;
Menu menu_;
};
} // namespace cru::ui::components
diff --git a/include/cru/ui/controls/ControlHost.h b/include/cru/ui/controls/ControlHost.h
index c67e8a72..a27be835 100644
--- a/include/cru/ui/controls/ControlHost.h
+++ b/include/cru/ui/controls/ControlHost.h
@@ -169,7 +169,8 @@ class CRU_UI_API ControlHost : public Object {
}
void UpdateCursor();
- void NotifyControlParentChange(Control* control, Control* old_parent, Control* new_parent);
+ void NotifyControlParentChange(Control* control, Control* old_parent,
+ Control* new_parent);
private:
int event_handling_count_;
@@ -185,7 +186,6 @@ class CRU_UI_API ControlHost : public Object {
bool layout_prefer_to_fill_window_;
- platform::gui::TimerAutoCanceler repaint_schedule_canceler_;
platform::gui::TimerAutoCanceler relayout_schedule_canceler_;
};
} // namespace cru::ui::controls
diff --git a/include/cru/ui/controls/Window.h b/include/cru/ui/controls/Window.h
index a2ae01f9..3d3ff0b0 100644
--- a/include/cru/ui/controls/Window.h
+++ b/include/cru/ui/controls/Window.h
@@ -1,5 +1,6 @@
#pragma once
#include "../render/StackLayoutRenderObject.h"
+#include "ControlHost.h"
#include "LayoutControl.h"
#include <cru/base/Base.h>
@@ -9,6 +10,8 @@
#include <cru/platform/gui/UiApplication.h>
#include <cru/platform/gui/Window.h>
+#include <memory>
+
namespace cru::ui::controls {
class CRU_UI_API Window
: public LayoutControl<render::StackLayoutRenderObject> {
@@ -31,7 +34,7 @@ class CRU_UI_API Window
void SetGainFocusOnCreateAndDestroyWhenLoseFocus(bool value);
private:
- std::shared_ptr<ControlHost> control_host_;
+ std::unique_ptr<ControlHost> control_host_;
Control* attached_control_;