aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/RootControl.cpp
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-11-17 12:54:55 +0800
committerYuqian Yang <crupest@crupest.life>2025-11-17 12:54:55 +0800
commit0f8f98b9005803ab154b43dcad0db1f292072a4d (patch)
tree0a43d5a9c4e3b747ad955fc30a143aa07ab5888d /src/ui/controls/RootControl.cpp
parentb68f9f52a3ecdd8e379dd60ac1c1366e76695464 (diff)
downloadcru-0f8f98b9005803ab154b43dcad0db1f292072a4d.tar.gz
cru-0f8f98b9005803ab154b43dcad0db1f292072a4d.tar.bz2
cru-0f8f98b9005803ab154b43dcad0db1f292072a4d.zip
Refactor window host.
Diffstat (limited to 'src/ui/controls/RootControl.cpp')
-rw-r--r--src/ui/controls/RootControl.cpp49
1 files changed, 0 insertions, 49 deletions
diff --git a/src/ui/controls/RootControl.cpp b/src/ui/controls/RootControl.cpp
deleted file mode 100644
index 7be1c630..00000000
--- a/src/ui/controls/RootControl.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#include "cru/ui/controls/RootControl.h"
-
-#include "cru/platform/gui/Window.h"
-#include "cru/ui/Base.h"
-#include "cru/ui/host/WindowHost.h"
-
-#include <memory>
-
-namespace cru::ui::controls {
-RootControl::RootControl(Control* attached_control)
- : attached_control_(attached_control) {
- GetContainerRenderObject()->SetDefaultHorizontalAlignment(Alignment::Stretch);
- GetContainerRenderObject()->SetDefaultVertialAlignment(Alignment::Stretch);
- window_host_ = std::make_unique<host::WindowHost>(this);
-
- Control::window_host_ = this->window_host_.get();
-
- window_host_->SetLayoutPreferToFillWindow(true);
-}
-
-RootControl::~RootControl() {}
-
-platform::gui::INativeWindow* RootControl::GetNativeWindow() {
- return window_host_->GetNativeWindow();
-}
-
-void RootControl::SetGainFocusOnCreateAndDestroyWhenLoseFocus(bool value) {
- gain_focus_on_create_and_destroy_when_lose_focus_event_guard_.Clear();
- if (value) {
- auto native_window = window_host_->GetNativeWindow();
-
- gain_focus_on_create_and_destroy_when_lose_focus_event_guard_ +=
- native_window->VisibilityChangeEvent()->AddHandler(
- [native_window](platform::gui::WindowVisibilityType type) {
- if (type == platform::gui::WindowVisibilityType::Show) {
- native_window->RequestFocus();
- }
- });
-
- gain_focus_on_create_and_destroy_when_lose_focus_event_guard_ +=
- native_window->FocusEvent()->AddHandler(
- [native_window](platform::gui::FocusChangeType type) {
- if (type == platform::gui::FocusChangeType::Lose) {
- native_window->Close();
- }
- });
- }
-}
-} // namespace cru::ui::controls