aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-10-29 00:16:48 +0800
committercrupest <crupest@outlook.com>2020-10-29 00:16:48 +0800
commitc5125e9034a5b05700ed41aee30f43476cb2c7f2 (patch)
tree4056188cda8cdf5e2a2c891ab32289d70d327d2d
parent52594324b302f6e9da10ac01fe803196371bb2d9 (diff)
downloadcru-c5125e9034a5b05700ed41aee30f43476cb2c7f2.tar.gz
cru-c5125e9034a5b05700ed41aee30f43476cb2c7f2.tar.bz2
cru-c5125e9034a5b05700ed41aee30f43476cb2c7f2.zip
...
-rw-r--r--include/cru/ui/WindowHost.hpp8
-rw-r--r--src/ui/RoutedEventDispatch.hpp4
-rw-r--r--src/ui/Window.cpp1
-rw-r--r--src/ui/WindowHost.cpp3
4 files changed, 9 insertions, 7 deletions
diff --git a/include/cru/ui/WindowHost.hpp b/include/cru/ui/WindowHost.hpp
index 8efb505d..c3221dcf 100644
--- a/include/cru/ui/WindowHost.hpp
+++ b/include/cru/ui/WindowHost.hpp
@@ -120,10 +120,10 @@ class WindowHost : public Object {
bool no_enter);
private:
- Control* root_control_;
- render::RenderObject* root_render_object_;
+ Control* root_control_ = nullptr;
+ render::RenderObject* root_render_object_ = nullptr;
- platform::native::INativeWindow* native_window_;
+ platform::native::INativeWindow* native_window_ = nullptr;
bool need_layout_ = false;
platform::native::TimerAutoCanceler relayout_timer_canceler_;
@@ -136,7 +136,7 @@ class WindowHost : public Object {
Control* focus_control_;
- Control* mouse_captured_control_;
+ Control* mouse_captured_control_ = nullptr;
bool layout_prefer_to_fill_window_ = true;
};
diff --git a/src/ui/RoutedEventDispatch.hpp b/src/ui/RoutedEventDispatch.hpp
index b6e0999b..de94a598 100644
--- a/src/ui/RoutedEventDispatch.hpp
+++ b/src/ui/RoutedEventDispatch.hpp
@@ -4,7 +4,7 @@
#include "cru/common/Logger.hpp"
#include "cru/ui/DebugFlags.hpp"
-#include <list>
+#include <vector>
namespace cru::ui {
// Dispatch the event.
@@ -36,7 +36,7 @@ void DispatchEvent(const std::u16string_view& event_name,
return;
}
- std::list<Control*> receive_list;
+ std::vector<Control*> receive_list;
auto parent = original_sender;
while (parent != last_receiver) {
diff --git a/src/ui/Window.cpp b/src/ui/Window.cpp
index 6d507858..051e67ef 100644
--- a/src/ui/Window.cpp
+++ b/src/ui/Window.cpp
@@ -9,6 +9,7 @@ namespace cru::ui {
Window* Window::CreateOverlapped() { return new Window(); }
Window::Window() : render_object_(new render::StackLayoutRenderObject()) {
+ render_object_->SetAttachedControl(this);
window_host_ = std::make_unique<WindowHost>(this);
}
diff --git a/src/ui/WindowHost.cpp b/src/ui/WindowHost.cpp
index 1dba4404..12eb746a 100644
--- a/src/ui/WindowHost.cpp
+++ b/src/ui/WindowHost.cpp
@@ -99,7 +99,8 @@ inline void BindNativeEvent(
}
} // namespace
-WindowHost::WindowHost(Control* root_control) : root_control_(root_control) {
+WindowHost::WindowHost(Control* root_control)
+ : root_control_(root_control), focus_control_(root_control) {
const auto ui_application = IUiApplication::GetInstance();
auto native_window = ui_application->CreateWindow(nullptr);
native_window_ = native_window;