From d86a71f79afe0e4dac768f61d6bff690567aca5b Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 24 May 2020 01:40:02 +0800 Subject: ... --- include/cru/ui/controls/FlexLayout.hpp | 41 ++++++++++++++++++++++++++ include/cru/ui/controls/StackLayout.hpp | 31 ++++++++++++++++++++ include/cru/ui/controls/TextBlock.hpp | 38 +++++++++++++++++++++++++ include/cru/ui/controls/TextBox.hpp | 49 ++++++++++++++++++++++++++++++++ include/cru/ui/controls/base.hpp | 2 +- include/cru/ui/controls/button.hpp | 6 ++-- include/cru/ui/controls/container.hpp | 2 +- include/cru/ui/controls/flex_layout.hpp | 41 -------------------------- include/cru/ui/controls/stack_layout.hpp | 31 -------------------- include/cru/ui/controls/text_block.hpp | 38 ------------------------- include/cru/ui/controls/text_box.hpp | 49 -------------------------------- 11 files changed, 164 insertions(+), 164 deletions(-) create mode 100644 include/cru/ui/controls/FlexLayout.hpp create mode 100644 include/cru/ui/controls/StackLayout.hpp create mode 100644 include/cru/ui/controls/TextBlock.hpp create mode 100644 include/cru/ui/controls/TextBox.hpp delete mode 100644 include/cru/ui/controls/flex_layout.hpp delete mode 100644 include/cru/ui/controls/stack_layout.hpp delete mode 100644 include/cru/ui/controls/text_block.hpp delete mode 100644 include/cru/ui/controls/text_box.hpp (limited to 'include/cru/ui/controls') diff --git a/include/cru/ui/controls/FlexLayout.hpp b/include/cru/ui/controls/FlexLayout.hpp new file mode 100644 index 00000000..beacd1f9 --- /dev/null +++ b/include/cru/ui/controls/FlexLayout.hpp @@ -0,0 +1,41 @@ +#pragma once +#include "../LayoutControl.hpp" + +namespace cru::ui::controls { +class FlexLayout : public LayoutControl { + public: + static constexpr std::string_view control_type = "FlexLayout"; + + static FlexLayout* Create() { return new FlexLayout(); } + + protected: + FlexLayout(); + + public: + FlexLayout(const FlexLayout& other) = delete; + FlexLayout(FlexLayout&& other) = delete; + FlexLayout& operator=(const FlexLayout& other) = delete; + FlexLayout& operator=(FlexLayout&& other) = delete; + ~FlexLayout() override; + + std::string_view GetControlType() const final { return control_type; } + + render::RenderObject* GetRenderObject() const override; + + FlexMainAlignment GetContentMainAlign() const; + void SetContentMainAlign(FlexMainAlignment value); + + FlexDirection GetFlexDirection() const; + void SetFlexDirection(FlexDirection direction); + + FlexChildLayoutData GetChildLayoutData(Control* control); + void SetChildLayoutData(Control* control, const FlexChildLayoutData& data); + + protected: + void OnAddChild(Control* child, Index position) override; + void OnRemoveChild(Control* child, Index position) override; + + private: + std::shared_ptr render_object_; +}; +} // namespace cru::ui::controls diff --git a/include/cru/ui/controls/StackLayout.hpp b/include/cru/ui/controls/StackLayout.hpp new file mode 100644 index 00000000..d5998cc4 --- /dev/null +++ b/include/cru/ui/controls/StackLayout.hpp @@ -0,0 +1,31 @@ +#pragma once +#include "../LayoutControl.hpp" + +namespace cru::ui::controls { +class StackLayout : public LayoutControl { + public: + static constexpr std::string_view control_type = "StackLayout"; + + static StackLayout* Create() { return new StackLayout(); } + + protected: + StackLayout(); + + public: + CRU_DELETE_COPY(StackLayout) + CRU_DELETE_MOVE(StackLayout) + + ~StackLayout() override; + + std::string_view GetControlType() const final { return control_type; } + + render::RenderObject* GetRenderObject() const override; + + protected: + void OnAddChild(Control* child, Index position) override; + void OnRemoveChild(Control* child, Index position) override; + + private: + std::shared_ptr render_object_; +}; +} // namespace cru::ui::controls diff --git a/include/cru/ui/controls/TextBlock.hpp b/include/cru/ui/controls/TextBlock.hpp new file mode 100644 index 00000000..dd8b40b4 --- /dev/null +++ b/include/cru/ui/controls/TextBlock.hpp @@ -0,0 +1,38 @@ +#pragma once +#include "../NoChildControl.hpp" + +namespace cru::ui::controls { +template +class TextControlService; + +class TextBlock : public NoChildControl { + public: + static constexpr std::string_view control_type = "TextBlock"; + + static TextBlock* Create() { return new TextBlock(); } + + protected: + TextBlock(); + + public: + TextBlock(const TextBlock& other) = delete; + TextBlock(TextBlock&& other) = delete; + TextBlock& operator=(const TextBlock& other) = delete; + TextBlock& operator=(TextBlock&& other) = delete; + ~TextBlock() override; + + std::string_view GetControlType() const final { return control_type; } + + render::RenderObject* GetRenderObject() const override; + + std::string GetText() const; + void SetText(std::string text); + + render::TextRenderObject* GetTextRenderObject(); + + private: + std::unique_ptr text_render_object_; + + std::unique_ptr> service_; +}; +} // namespace cru::ui::controls diff --git a/include/cru/ui/controls/TextBox.hpp b/include/cru/ui/controls/TextBox.hpp new file mode 100644 index 00000000..2f7a12b6 --- /dev/null +++ b/include/cru/ui/controls/TextBox.hpp @@ -0,0 +1,49 @@ +#pragma once +#include "../NoChildControl.hpp" +#include "Base.hpp" + +#include + +namespace cru::ui::controls { +template +class TextControlService; + +class TextBox : public NoChildControl { + public: + static constexpr std::string_view control_type = "TextBox"; + + static TextBox* Create() { return new TextBox(); } + + protected: + TextBox(); + + public: + CRU_DELETE_COPY(TextBox) + CRU_DELETE_MOVE(TextBox) + + ~TextBox() override; + + std::string_view GetControlType() const final { return control_type; } + + render::RenderObject* GetRenderObject() const override; + + render::TextRenderObject* GetTextRenderObject(); + + const TextBoxBorderStyle& GetBorderStyle(); + void SetBorderStyle(TextBoxBorderStyle border_style); + + protected: + void OnMouseHoverChange(bool newHover) override; + + private: + void UpdateBorderStyle(); + + private: + std::unique_ptr border_render_object_; + std::unique_ptr text_render_object_; + + TextBoxBorderStyle border_style_; + + std::unique_ptr> service_; +}; +} // namespace cru::ui::controls diff --git a/include/cru/ui/controls/base.hpp b/include/cru/ui/controls/base.hpp index ebe9cdda..b550601b 100644 --- a/include/cru/ui/controls/base.hpp +++ b/include/cru/ui/controls/base.hpp @@ -1,5 +1,5 @@ #pragma once -#include "../base.hpp" +#include "../Base.hpp" namespace cru::ui::controls { using ButtonStateStyle = BorderStyle; diff --git a/include/cru/ui/controls/button.hpp b/include/cru/ui/controls/button.hpp index fb636a33..8a11409c 100644 --- a/include/cru/ui/controls/button.hpp +++ b/include/cru/ui/controls/button.hpp @@ -1,8 +1,8 @@ #pragma once -#include "../content_control.hpp" -#include "base.hpp" +#include "../ContentControl.hpp" +#include "Base.hpp" -#include "../click_detector.hpp" +#include "../ClickDetector.hpp" namespace cru::ui::controls { class Button : public ContentControl { diff --git a/include/cru/ui/controls/container.hpp b/include/cru/ui/controls/container.hpp index 7d4c0d23..e3d78365 100644 --- a/include/cru/ui/controls/container.hpp +++ b/include/cru/ui/controls/container.hpp @@ -1,5 +1,5 @@ #pragma once -#include "../content_control.hpp" +#include "../ContentControl.hpp" namespace cru::ui::controls { class Container : public ContentControl { diff --git a/include/cru/ui/controls/flex_layout.hpp b/include/cru/ui/controls/flex_layout.hpp deleted file mode 100644 index ab08a80b..00000000 --- a/include/cru/ui/controls/flex_layout.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -#include "../layout_control.hpp" - -namespace cru::ui::controls { -class FlexLayout : public LayoutControl { - public: - static constexpr std::string_view control_type = "FlexLayout"; - - static FlexLayout* Create() { return new FlexLayout(); } - - protected: - FlexLayout(); - - public: - FlexLayout(const FlexLayout& other) = delete; - FlexLayout(FlexLayout&& other) = delete; - FlexLayout& operator=(const FlexLayout& other) = delete; - FlexLayout& operator=(FlexLayout&& other) = delete; - ~FlexLayout() override; - - std::string_view GetControlType() const final { return control_type; } - - render::RenderObject* GetRenderObject() const override; - - FlexMainAlignment GetContentMainAlign() const; - void SetContentMainAlign(FlexMainAlignment value); - - FlexDirection GetFlexDirection() const; - void SetFlexDirection(FlexDirection direction); - - FlexChildLayoutData GetChildLayoutData(Control* control); - void SetChildLayoutData(Control* control, const FlexChildLayoutData& data); - - protected: - void OnAddChild(Control* child, Index position) override; - void OnRemoveChild(Control* child, Index position) override; - - private: - std::shared_ptr render_object_; -}; -} // namespace cru::ui::controls diff --git a/include/cru/ui/controls/stack_layout.hpp b/include/cru/ui/controls/stack_layout.hpp deleted file mode 100644 index 20da0e82..00000000 --- a/include/cru/ui/controls/stack_layout.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -#include "../layout_control.hpp" - -namespace cru::ui::controls { -class StackLayout : public LayoutControl { - public: - static constexpr std::string_view control_type = "StackLayout"; - - static StackLayout* Create() { return new StackLayout(); } - - protected: - StackLayout(); - - public: - CRU_DELETE_COPY(StackLayout) - CRU_DELETE_MOVE(StackLayout) - - ~StackLayout() override; - - std::string_view GetControlType() const final { return control_type; } - - render::RenderObject* GetRenderObject() const override; - - protected: - void OnAddChild(Control* child, Index position) override; - void OnRemoveChild(Control* child, Index position) override; - - private: - std::shared_ptr render_object_; -}; -} // namespace cru::ui::controls diff --git a/include/cru/ui/controls/text_block.hpp b/include/cru/ui/controls/text_block.hpp deleted file mode 100644 index 61f568c4..00000000 --- a/include/cru/ui/controls/text_block.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -#include "../no_child_control.hpp" - -namespace cru::ui::controls { -template -class TextControlService; - -class TextBlock : public NoChildControl { - public: - static constexpr std::string_view control_type = "TextBlock"; - - static TextBlock* Create() { return new TextBlock(); } - - protected: - TextBlock(); - - public: - TextBlock(const TextBlock& other) = delete; - TextBlock(TextBlock&& other) = delete; - TextBlock& operator=(const TextBlock& other) = delete; - TextBlock& operator=(TextBlock&& other) = delete; - ~TextBlock() override; - - std::string_view GetControlType() const final { return control_type; } - - render::RenderObject* GetRenderObject() const override; - - std::string GetText() const; - void SetText(std::string text); - - render::TextRenderObject* GetTextRenderObject(); - - private: - std::unique_ptr text_render_object_; - - std::unique_ptr> service_; -}; -} // namespace cru::ui::controls diff --git a/include/cru/ui/controls/text_box.hpp b/include/cru/ui/controls/text_box.hpp deleted file mode 100644 index 15fcb734..00000000 --- a/include/cru/ui/controls/text_box.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once -#include "../no_child_control.hpp" -#include "base.hpp" - -#include - -namespace cru::ui::controls { -template -class TextControlService; - -class TextBox : public NoChildControl { - public: - static constexpr std::string_view control_type = "TextBox"; - - static TextBox* Create() { return new TextBox(); } - - protected: - TextBox(); - - public: - CRU_DELETE_COPY(TextBox) - CRU_DELETE_MOVE(TextBox) - - ~TextBox() override; - - std::string_view GetControlType() const final { return control_type; } - - render::RenderObject* GetRenderObject() const override; - - render::TextRenderObject* GetTextRenderObject(); - - const TextBoxBorderStyle& GetBorderStyle(); - void SetBorderStyle(TextBoxBorderStyle border_style); - - protected: - void OnMouseHoverChange(bool newHover) override; - - private: - void UpdateBorderStyle(); - - private: - std::unique_ptr border_render_object_; - std::unique_ptr text_render_object_; - - TextBoxBorderStyle border_style_; - - std::unique_ptr> service_; -}; -} // namespace cru::ui::controls -- cgit v1.2.3