aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/cru/osx/gui/InputMethod.hpp4
-rw-r--r--include/cru/osx/gui/Window.hpp7
-rw-r--r--include/cru/platform/gui/Window.hpp4
-rw-r--r--include/cru/ui/controls/Popup.hpp5
-rw-r--r--include/cru/ui/controls/RootControl.hpp17
-rw-r--r--include/cru/ui/controls/Window.hpp5
-rw-r--r--include/cru/ui/host/WindowHost.hpp19
7 files changed, 18 insertions, 43 deletions
diff --git a/include/cru/osx/gui/InputMethod.hpp b/include/cru/osx/gui/InputMethod.hpp
index aa013338..d184a722 100644
--- a/include/cru/osx/gui/InputMethod.hpp
+++ b/include/cru/osx/gui/InputMethod.hpp
@@ -7,12 +7,14 @@ namespace cru::platform::gui::osx {
class OsxWindow;
namespace details {
+class OsxWindowPrivate;
class OsxInputMethodContextPrivate;
-}
+} // namespace details
class OsxInputMethodContext : public OsxGuiResource,
public virtual IInputMethodContext {
friend OsxWindow;
+ friend details::OsxWindowPrivate;
friend details::OsxInputMethodContextPrivate;
public:
diff --git a/include/cru/osx/gui/Window.hpp b/include/cru/osx/gui/Window.hpp
index 406c133f..7ea21926 100644
--- a/include/cru/osx/gui/Window.hpp
+++ b/include/cru/osx/gui/Window.hpp
@@ -39,6 +39,9 @@ class OsxWindow : public OsxGuiResource, public INativeWindow {
Size GetClientSize() override;
void SetClientSize(const Size& size) override;
+ Rect GetClientRect() override;
+ void SetClientRect(const Rect& rect) override;
+
Rect GetWindowRect() override;
void SetWindowRect(const Rect& rect) override;
@@ -55,6 +58,7 @@ class OsxWindow : public OsxGuiResource, public INativeWindow {
std::unique_ptr<graphics::IPainter> BeginPaint() override;
+ IEvent<std::nullptr_t>* CreateEvent() override;
IEvent<std::nullptr_t>* DestroyEvent() override;
IEvent<std::nullptr_t>* PaintEvent() override;
IEvent<Size>* ResizeEvent() override;
@@ -70,9 +74,6 @@ class OsxWindow : public OsxGuiResource, public INativeWindow {
IInputMethodContext* GetInputMethodContext() override;
private:
- void CreateWindow();
-
- private:
std::unique_ptr<details::OsxWindowPrivate> p_;
};
} // namespace cru::platform::gui::osx
diff --git a/include/cru/platform/gui/Window.hpp b/include/cru/platform/gui/Window.hpp
index 49cbe1a0..a1816e4a 100644
--- a/include/cru/platform/gui/Window.hpp
+++ b/include/cru/platform/gui/Window.hpp
@@ -43,6 +43,9 @@ struct INativeWindow : virtual IPlatformResource {
virtual Size GetClientSize() = 0;
virtual void SetClientSize(const Size& size) = 0;
+ virtual Rect GetClientRect() = 0;
+ virtual void SetClientRect(const Rect& rect) = 0;
+
// Get the rect of the window containing frame.
// The lefttop of the rect is relative to screen lefttop.
virtual Rect GetWindowRect() = 0;
@@ -67,6 +70,7 @@ struct INativeWindow : virtual IPlatformResource {
virtual std::unique_ptr<graphics::IPainter> BeginPaint() = 0;
// Don't use this instance after receive this event.
+ virtual IEvent<std::nullptr_t>* CreateEvent() = 0;
virtual IEvent<std::nullptr_t>* DestroyEvent() = 0;
virtual IEvent<std::nullptr_t>* PaintEvent() = 0;
virtual IEvent<Size>* ResizeEvent() = 0;
diff --git a/include/cru/ui/controls/Popup.hpp b/include/cru/ui/controls/Popup.hpp
index cd5e1813..2e40bb5b 100644
--- a/include/cru/ui/controls/Popup.hpp
+++ b/include/cru/ui/controls/Popup.hpp
@@ -22,10 +22,5 @@ class Popup : public RootControl {
~Popup() override;
String GetControlType() const override { return kControlType.ToString(); }
-
- protected:
- gsl::not_null<platform::gui::INativeWindow*> CreateNativeWindow(
- gsl::not_null<host::WindowHost*> host,
- platform::gui::INativeWindow* parent) override;
};
} // namespace cru::ui::controls
diff --git a/include/cru/ui/controls/RootControl.hpp b/include/cru/ui/controls/RootControl.hpp
index a795f322..44722cef 100644
--- a/include/cru/ui/controls/RootControl.hpp
+++ b/include/cru/ui/controls/RootControl.hpp
@@ -4,11 +4,13 @@
#include "cru/common/Base.hpp"
#include "cru/platform/gui/Base.hpp"
#include "cru/ui/Base.hpp"
+#include "cru/ui/host/WindowHost.hpp"
namespace cru::ui::controls {
class RootControl : public LayoutControl {
protected:
- explicit RootControl(Control* attached_control);
+ explicit RootControl(Control* attached_control,
+ host::CreateWindowParams params);
public:
CRU_DELETE_COPY(RootControl)
@@ -18,20 +20,7 @@ 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);
-
- Rect GetRect();
- void SetRect(const Rect& rect);
-
protected:
- virtual gsl::not_null<platform::gui::INativeWindow*> CreateNativeWindow(
- gsl::not_null<host::WindowHost*> host,
- platform::gui::INativeWindow* parent) = 0;
-
void SetGainFocusOnCreateAndDestroyWhenLoseFocus(bool value);
private:
diff --git a/include/cru/ui/controls/Window.hpp b/include/cru/ui/controls/Window.hpp
index 63b4d1e3..b0828f70 100644
--- a/include/cru/ui/controls/Window.hpp
+++ b/include/cru/ui/controls/Window.hpp
@@ -23,10 +23,5 @@ class Window final : public RootControl {
public:
String GetControlType() const final { return control_type.ToString(); }
-
- protected:
- gsl::not_null<platform::gui::INativeWindow*> CreateNativeWindow(
- gsl::not_null<host::WindowHost*> host,
- platform::gui::INativeWindow* parent) override;
};
} // namespace cru::ui::controls
diff --git a/include/cru/ui/host/WindowHost.hpp b/include/cru/ui/host/WindowHost.hpp
index f3caeeef..6fb853b6 100644
--- a/include/cru/ui/host/WindowHost.hpp
+++ b/include/cru/ui/host/WindowHost.hpp
@@ -30,7 +30,7 @@ class WindowHost : public Object {
CRU_DEFINE_CLASS_LOG_TAG(u"cru::ui::host::WindowHost")
public:
- WindowHost(controls::Control* root_control);
+ WindowHost(controls::Control* root_control, CreateWindowParams params);
CRU_DELETE_COPY(WindowHost)
CRU_DELETE_MOVE(WindowHost)
@@ -40,10 +40,6 @@ 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.
@@ -112,18 +108,13 @@ class WindowHost : public Object {
return &native_window_change_event_;
}
- // If window exist, return window actual size. Otherwise if saved rect exists,
- // return it. Otherwise return 0.
- Rect GetWindowRect();
-
- void SetSavedWindowRect(std::optional<Rect> rect);
-
- void SetWindowRect(const Rect& rect);
-
std::shared_ptr<platform::gui::ICursor> GetOverrideCursor();
void SetOverrideCursor(std::shared_ptr<platform::gui::ICursor> cursor);
private:
+ gsl::not_null<platform::gui::INativeWindow*> CreateNativeWindow(
+ CreateWindowParams params);
+
//*************** region: native messages ***************
void OnNativeDestroy(platform::gui::INativeWindow* window, std::nullptr_t);
void OnNativePaint(platform::gui::INativeWindow* window, std::nullptr_t);
@@ -178,8 +169,6 @@ class WindowHost : public Object {
Event<platform::gui::INativeWindow*> native_window_change_event_;
- std::optional<Rect> saved_rect_;
-
std::shared_ptr<platform::gui::ICursor> override_cursor_;
};
} // namespace cru::ui::host