diff options
Diffstat (limited to 'include/cru/ui')
| -rw-r--r-- | include/cru/ui/controls/Popup.hpp | 17 | ||||
| -rw-r--r-- | include/cru/ui/controls/RootControl.hpp | 40 | ||||
| -rw-r--r-- | include/cru/ui/controls/Window.hpp | 34 | 
3 files changed, 64 insertions, 27 deletions
diff --git a/include/cru/ui/controls/Popup.hpp b/include/cru/ui/controls/Popup.hpp index f17cd1b2..d76e1211 100644 --- a/include/cru/ui/controls/Popup.hpp +++ b/include/cru/ui/controls/Popup.hpp @@ -1,10 +1,13 @@  #pragma once -#include "LayoutControl.hpp" +#include "RootControl.hpp" + +#include "cru/ui/Base.hpp" +#include "cru/platform/gui/Base.hpp"  #include <memory>  namespace cru::ui::controls { -class Popup : public LayoutControl { +class Popup : public RootControl {   public:    explicit Popup(Control* attached_control = nullptr); @@ -13,11 +16,9 @@ class Popup : public LayoutControl {    ~Popup() override; - private: -  std::unique_ptr<host::WindowHost> window_host_; - -  std::unique_ptr<render::StackLayoutRenderObject> render_object_; - -  Control* attached_control_; + 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 new file mode 100644 index 00000000..ff1b545a --- /dev/null +++ b/include/cru/ui/controls/RootControl.hpp @@ -0,0 +1,40 @@ +#pragma once +#include "LayoutControl.hpp" + +#include "cru/common/Base.hpp" +#include "cru/platform/gui/Base.hpp" +#include "cru/ui/Base.hpp" + +namespace cru::ui::controls { +class RootControl : public LayoutControl { + protected: +  explicit RootControl(Control* attached_control); + + public: +  CRU_DELETE_COPY(RootControl) +  CRU_DELETE_MOVE(RootControl) +  ~RootControl() override; + + public: +  render::RenderObject* GetRenderObject() const override; + +  // If create is false and native window is not create, it will not be created +  // and shown. +  void Show(bool create = true); + + protected: +  virtual gsl::not_null<platform::gui::INativeWindow*> CreateNativeWindow( +      gsl::not_null<host::WindowHost*> host, +      platform::gui::INativeWindow* parent) = 0; + + private: +  platform::gui::INativeWindow* GetNativeWindow(bool create); + + private: +  std::unique_ptr<host::WindowHost> window_host_; + +  std::unique_ptr<render::StackLayoutRenderObject> render_object_; + +  Control* attached_control_; +}; +}  // namespace cru::ui::controls diff --git a/include/cru/ui/controls/Window.hpp b/include/cru/ui/controls/Window.hpp index 996bc75e..cca56b64 100644 --- a/include/cru/ui/controls/Window.hpp +++ b/include/cru/ui/controls/Window.hpp @@ -1,36 +1,32 @@  #pragma once -#include "LayoutControl.hpp" +#include "cru/platform/gui/Base.hpp" +#include "cru/ui/controls/RootControl.hpp" + +#include "cru/common/Base.hpp"  namespace cru::ui::controls { -class Window final : public LayoutControl { +class Window final : public RootControl {   public:    static constexpr std::u16string_view control_type = u"Window";   public: -  static Window* CreateOverlapped(); +  static Window* Create(Control* attached_control = nullptr);   private: -  Window(); +  explicit Window(Control* attached_control);   public: -  Window(const Window& other) = delete; -  Window(Window&& other) = delete; -  Window& operator=(const Window& other) = delete; -  Window& operator=(Window&& other) = delete; +  CRU_DELETE_COPY(Window) +  CRU_DELETE_MOVE(Window) +    ~Window() override;   public: -  std::u16string_view GetControlType() const final; - -  render::RenderObject* GetRenderObject() const 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::u16string_view GetControlType() const final { return control_type; } -  std::unique_ptr<render::StackLayoutRenderObject> render_object_; + protected: +  gsl::not_null<platform::gui::INativeWindow*> CreateNativeWindow( +      gsl::not_null<host::WindowHost*> host, +      platform::gui::INativeWindow* parent) override;  };  }  // namespace cru::ui::controls  | 
