aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-11-20 22:43:30 +0800
committercrupest <crupest@outlook.com>2021-11-20 22:43:30 +0800
commita60910cb3db6f47fd8f3b7f31648a9d0514d4f2c (patch)
tree32c01c22e21742ae0c9febb2cbc26339f99eec1d /include/cru/ui
parent1a53ed0791d9793ed8030d3a44e833e5e7c4542b (diff)
downloadcru-a60910cb3db6f47fd8f3b7f31648a9d0514d4f2c.tar.gz
cru-a60910cb3db6f47fd8f3b7f31648a9d0514d4f2c.tar.bz2
cru-a60910cb3db6f47fd8f3b7f31648a9d0514d4f2c.zip
...
Diffstat (limited to 'include/cru/ui')
-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
4 files changed, 7 insertions, 39 deletions
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