aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/ui')
-rw-r--r--include/cru/ui/controls/Window.hpp8
-rw-r--r--include/cru/ui/host/WindowHost.hpp13
2 files changed, 15 insertions, 6 deletions
diff --git a/include/cru/ui/controls/Window.hpp b/include/cru/ui/controls/Window.hpp
index 616e2ee7..996bc75e 100644
--- a/include/cru/ui/controls/Window.hpp
+++ b/include/cru/ui/controls/Window.hpp
@@ -24,13 +24,13 @@ class Window final : public LayoutControl {
render::RenderObject* GetRenderObject() const override;
- protected:
- void OnAddChild(Control* child, Index position) override;
- void OnRemoveChild(Control* child, Index position) override;
+ // If create is false and native window is not create, it will not be created
+ // and shown.
+ void Show(bool create = true);
private:
std::unique_ptr<host::WindowHost> window_host_;
std::unique_ptr<render::StackLayoutRenderObject> render_object_;
};
-} // namespace cru::ui
+} // namespace cru::ui::controls
diff --git a/include/cru/ui/host/WindowHost.hpp b/include/cru/ui/host/WindowHost.hpp
index 6d338df1..9fc24eb2 100644
--- a/include/cru/ui/host/WindowHost.hpp
+++ b/include/cru/ui/host/WindowHost.hpp
@@ -28,8 +28,7 @@ class WindowHost : public Object {
CRU_DEFINE_CLASS_LOG_TAG(u"cru::ui::host::WindowHost")
public:
- WindowHost(controls::Control* root_control,
- CreateWindowParams create_window_params = {});
+ WindowHost(controls::Control* root_control);
CRU_DELETE_COPY(WindowHost)
CRU_DELETE_MOVE(WindowHost)
@@ -39,6 +38,10 @@ class WindowHost : public Object {
public:
platform::gui::INativeWindow* GetNativeWindow() { return native_window_; }
+ // Do nothing if native window is already created.
+ gsl::not_null<platform::gui::INativeWindow*> CreateNativeWindow(
+ CreateWindowParams create_window_params = {});
+
// Mark the layout as invalid, and arrange a re-layout later.
// This method could be called more than one times in a message cycle. But
// layout only takes place once.
@@ -102,6 +105,10 @@ class WindowHost : public Object {
void UpdateCursor();
+ IEvent<platform::gui::INativeWindow*>* NativeWindowChangeEvent() {
+ return &native_window_change_event_;
+ }
+
private:
//*************** region: native messages ***************
void OnNativeDestroy(platform::gui::INativeWindow* window, std::nullptr_t);
@@ -152,5 +159,7 @@ class WindowHost : public Object {
controls::Control* mouse_captured_control_ = nullptr;
bool layout_prefer_to_fill_window_ = true;
+
+ Event<platform::gui::INativeWindow*> native_window_change_event_;
};
} // namespace cru::ui::host