aboutsummaryrefslogtreecommitdiff
path: root/src/ui/window.cpp
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-09-16 22:11:11 +0800
committer杨宇千 <crupest@outlook.com>2019-09-16 22:11:11 +0800
commit465d89b4207cce929dc8e0b6ac93c3533ba19408 (patch)
tree157df74f42d46d9b631163c087fd126f2eed021b /src/ui/window.cpp
parentf1da8e06253748887ae769845a6e605d56d5789b (diff)
downloadcru-465d89b4207cce929dc8e0b6ac93c3533ba19408.tar.gz
cru-465d89b4207cce929dc8e0b6ac93c3533ba19408.tar.bz2
cru-465d89b4207cce929dc8e0b6ac93c3533ba19408.zip
...
Diffstat (limited to 'src/ui/window.cpp')
-rw-r--r--src/ui/window.cpp26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/ui/window.cpp b/src/ui/window.cpp
index 13784718..25dffe11 100644
--- a/src/ui/window.cpp
+++ b/src/ui/window.cpp
@@ -135,21 +135,6 @@ render::RenderObject* Window::GetRenderObject() const {
return render_object_.get();
}
-void Window::Relayout() { this->render_object_->MeasureAndLayout(); }
-
-void Window::InvalidateLayout() {
- if (!need_layout_) {
- platform::native::UiApplication::GetInstance()->InvokeLater(
- [resolver = this->CreateResolver()] {
- if (const auto window = resolver.Resolve()) {
- window->Relayout();
- window->need_layout_ = false;
- }
- });
- need_layout_ = true;
- }
-}
-
bool Window::RequestFocusFor(Control* control) {
assert(control != nullptr); // The control to request focus can't be null.
// You can set it as the window.
@@ -216,7 +201,7 @@ void Window::OnNativePaint(std::nullptr_t) {
}
void Window::OnNativeResize(const Size& size) {
- render_object_->MeasureAndLayout();
+ render_object_->GetRenderHost()->InvalidateLayout();
}
void Window::OnNativeFocus(bool focus) {
@@ -241,13 +226,16 @@ void Window::OnNativeMouseMove(const Point& point) {
mouse_hover_control_ = new_mouse_hover_control;
if (mouse_captured_control_) {
- const auto n = FindLowestCommonAncestor(new_mouse_hover_control, mouse_captured_control_);
- const auto o = FindLowestCommonAncestor(old_mouse_hover_control, mouse_captured_control_);
+ const auto n = FindLowestCommonAncestor(new_mouse_hover_control,
+ mouse_captured_control_);
+ const auto o = FindLowestCommonAncestor(old_mouse_hover_control,
+ mouse_captured_control_);
bool a = IsAncestor(o, n);
if (a) {
DispatchEvent(event_names::MouseLeave, o, &Control::MouseLeaveEvent, n);
} else {
- DispatchEvent(event_names::MouseEnter, n, &Control::MouseEnterEvent, o, point);
+ DispatchEvent(event_names::MouseEnter, n, &Control::MouseEnterEvent, o,
+ point);
}
DispatchEvent(event_names::MouseMove, mouse_captured_control_,
&Control::MouseMoveEvent, nullptr, point);