aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/cru/ui/controls/RootControl.hpp7
-rw-r--r--src/ui/controls/RootControl.cpp9
2 files changed, 16 insertions, 0 deletions
diff --git a/include/cru/ui/controls/RootControl.hpp b/include/cru/ui/controls/RootControl.hpp
index ff1b545a..d41f02d8 100644
--- a/include/cru/ui/controls/RootControl.hpp
+++ b/include/cru/ui/controls/RootControl.hpp
@@ -18,10 +18,17 @@ class RootControl : public LayoutControl {
public:
render::RenderObject* GetRenderObject() const override;
+ void EnsureWindowCreated();
+
// If create is false and native window is not create, it will not be created
// and shown.
void Show(bool create = true);
+ // If native window does not exist, nothing will be done. It will not save it
+ // and use it when creating window. So call this after ensuring window
+ // created.
+ void SetRect(const Rect& rect);
+
protected:
virtual gsl::not_null<platform::gui::INativeWindow*> CreateNativeWindow(
gsl::not_null<host::WindowHost*> host,
diff --git a/src/ui/controls/RootControl.cpp b/src/ui/controls/RootControl.cpp
index 61d272f8..c6d9a577 100644
--- a/src/ui/controls/RootControl.cpp
+++ b/src/ui/controls/RootControl.cpp
@@ -24,6 +24,15 @@ render::RenderObject* RootControl::GetRenderObject() const {
return render_object_.get();
}
+void RootControl::EnsureWindowCreated() { this->GetNativeWindow(true); }
+
+void RootControl::SetRect(const Rect& rect) {
+ auto native_window = GetNativeWindow(false);
+ if (!native_window) return;
+
+ native_window->SetWindowRect(rect);
+}
+
void RootControl::Show(bool create) {
platform::gui::INativeWindow* native_window = GetNativeWindow(create);
if (!native_window) return;