aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/controls')
-rw-r--r--src/ui/controls/Control.cpp10
-rw-r--r--src/ui/controls/ControlHost.cpp15
2 files changed, 12 insertions, 13 deletions
diff --git a/src/ui/controls/Control.cpp b/src/ui/controls/Control.cpp
index 02148b72..70a3b1f3 100644
--- a/src/ui/controls/Control.cpp
+++ b/src/ui/controls/Control.cpp
@@ -27,6 +27,7 @@ Control::~Control() {
}
RemoveFromParent();
+ RemoveAllChild();
}
std::string Control::GetDebugId() const {
@@ -89,9 +90,8 @@ void Control::InsertChildAt(Control* control, Index index) {
children_.insert(children_.cbegin() + index, control);
control->parent_ = this;
-
- TraverseDescendents([this](Control* control) { control->host_ = host_; },
- false);
+ control->TraverseDescendents(
+ [this](Control* control) { control->host_ = host_; }, true);
if (host_) {
host_->NotifyControlParentChange(control, nullptr, this);
}
@@ -111,8 +111,8 @@ void Control::RemoveChildAt(Index index) {
auto control = children_[index];
children_.erase(children_.cbegin() + index);
control->parent_ = nullptr;
- TraverseDescendents([this](Control* control) { control->host_ = nullptr; },
- false);
+ control->TraverseDescendents(
+ [this](Control* control) { control->host_ = nullptr; }, true);
if (host_) {
host_->NotifyControlParentChange(control, this, nullptr);
}
diff --git a/src/ui/controls/ControlHost.cpp b/src/ui/controls/ControlHost.cpp
index 09639465..f83aa1a2 100644
--- a/src/ui/controls/ControlHost.cpp
+++ b/src/ui/controls/ControlHost.cpp
@@ -15,11 +15,14 @@ ControlHost::ControlHost(Control* root_control)
mouse_hover_control_(nullptr),
mouse_captured_control_(nullptr),
layout_prefer_to_fill_window_(true) {
- root_control->TraverseDescendents(
+ root_control_->TraverseDescendents(
[this](Control* control) { control->host_ = this; }, true);
}
-ControlHost::~ControlHost() {}
+ControlHost::~ControlHost() {
+ root_control_->TraverseDescendents(
+ [this](Control* control) { control->host_ = nullptr; }, true);
+}
platform::gui::INativeWindow* ControlHost::GetNativeWindow() {
return native_window_.get();
@@ -121,11 +124,7 @@ ControlHost::CreateNativeWindow() {
return std::unique_ptr<platform::gui::INativeWindow>(native_window);
}
-void ControlHost::InvalidatePaint() {
- repaint_schedule_canceler_.Reset(
- platform::gui::IUiApplication::GetInstance()->SetImmediate(
- [this] { Repaint(); }));
-}
+void ControlHost::InvalidatePaint() { native_window_->RequestRepaint(); }
void ControlHost::InvalidateLayout() {
relayout_schedule_canceler_.Reset(
@@ -244,7 +243,7 @@ void ControlHost::OnNativeDestroy(platform::gui::INativeWindow* window,
void ControlHost::OnNativePaint(platform::gui::INativeWindow* window,
std::nullptr_t) {
CRU_UNUSED(window)
- InvalidatePaint();
+ Repaint();
}
void ControlHost::OnNativeResize(platform::gui::INativeWindow* window,