aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-04-04 23:08:22 +0800
committercrupest <crupest@outlook.com>2019-04-04 23:08:22 +0800
commit6268f3ca09afef812cf288f323cacff22fbfcffc (patch)
tree86e89d3b4212ae069075f799a5278c120e258e73 /src/ui/controls
parentdbda5a8e4f0d59ad95be8fc3ee7b21e9122cc474 (diff)
downloadcru-6268f3ca09afef812cf288f323cacff22fbfcffc.tar.gz
cru-6268f3ca09afef812cf288f323cacff22fbfcffc.tar.bz2
cru-6268f3ca09afef812cf288f323cacff22fbfcffc.zip
Finish refactor!!!
Diffstat (limited to 'src/ui/controls')
-rw-r--r--src/ui/controls/button.cpp10
-rw-r--r--src/ui/controls/button.hpp39
-rw-r--r--src/ui/controls/flex_layout.cpp4
-rw-r--r--src/ui/controls/flex_layout.hpp41
-rw-r--r--src/ui/controls/text_block.cpp14
-rw-r--r--src/ui/controls/text_block.hpp39
6 files changed, 16 insertions, 131 deletions
diff --git a/src/ui/controls/button.cpp b/src/ui/controls/button.cpp
index a6578251..0ac65d26 100644
--- a/src/ui/controls/button.cpp
+++ b/src/ui/controls/button.cpp
@@ -1,7 +1,7 @@
-#include "button.hpp"
+#include "cru/ui/controls/button.hpp"
-#include "ui/render/border_render_object.hpp"
-#include "ui/ui_manager.hpp"
+#include "cru/ui/render/border_render_object.hpp"
+#include "cru/ui/ui_manager.hpp"
namespace cru::ui::controls {
Button::Button() {
@@ -14,7 +14,9 @@ Button::Button() {
render_object_->SetCornerRadius(render::CornerRadius{Point{10, 5}});
}
-render::RenderObject* Button::GetRenderObject() const { return render_object_.get(); }
+render::RenderObject* Button::GetRenderObject() const {
+ return render_object_.get();
+}
void Button::OnChildChanged(Control* old_child, Control* new_child) {
if (old_child != nullptr) render_object_->RemoveChild(0);
diff --git a/src/ui/controls/button.hpp b/src/ui/controls/button.hpp
deleted file mode 100644
index 3f313dfc..00000000
--- a/src/ui/controls/button.hpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#pragma once
-#include "pre.hpp"
-
-#include <memory>
-
-#include "ui/content_control.hpp"
-
-namespace cru::ui::render {
-class BorderRenderObject;
-}
-
-namespace cru::ui::controls {
-class Button : public ContentControl {
- public:
- static constexpr auto control_type = L"Button";
-
- static Button* Create() { return new Button(); }
-
- protected:
- Button();
-
- public:
- Button(const Button& other) = delete;
- Button(Button&& other) = delete;
- Button& operator=(const Button& other) = delete;
- Button& operator=(Button&& other) = delete;
- ~Button() override = default;
-
- StringView GetControlType() const override final { return control_type; }
-
- render::RenderObject* GetRenderObject() const override;
-
- protected:
- void OnChildChanged(Control* old_child, Control* new_child) override;
-
- private:
- std::shared_ptr<render::BorderRenderObject> render_object_{};
-};
-} // namespace cru::ui::controls
diff --git a/src/ui/controls/flex_layout.cpp b/src/ui/controls/flex_layout.cpp
index bdbe2d73..3b70c98c 100644
--- a/src/ui/controls/flex_layout.cpp
+++ b/src/ui/controls/flex_layout.cpp
@@ -1,6 +1,6 @@
-#include "flex_layout.hpp"
+#include "cru/ui/controls/flex_layout.hpp"
-#include "ui/render/flex_layout_render_object.hpp"
+#include "cru/ui/render/flex_layout_render_object.hpp"
namespace cru::ui::controls {
using render::FlexLayoutRenderObject;
diff --git a/src/ui/controls/flex_layout.hpp b/src/ui/controls/flex_layout.hpp
deleted file mode 100644
index 9ceef1f6..00000000
--- a/src/ui/controls/flex_layout.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#pragma once
-#include "pre.hpp"
-
-#include <memory>
-
-#include "ui/layout_control.hpp"
-
-namespace cru::ui::render {
-class FlexLayoutRenderObject;
-}
-
-namespace cru::ui::controls {
-
-class FlexLayout : public LayoutControl {
- public:
- static constexpr auto control_type = L"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 = default;
-
- StringView GetControlType() const override final { return control_type; }
-
- render::RenderObject* GetRenderObject() const override;
-
- protected:
- void OnAddChild(Control* child, int position) override;
- void OnRemoveChild(Control* child, int position) override;
-
- private:
- std::shared_ptr<render::FlexLayoutRenderObject> render_object_;
-};
-} // namespace cru::ui::controls
diff --git a/src/ui/controls/text_block.cpp b/src/ui/controls/text_block.cpp
index c2f8cd8e..55d83acc 100644
--- a/src/ui/controls/text_block.cpp
+++ b/src/ui/controls/text_block.cpp
@@ -1,7 +1,7 @@
-#include "text_block.hpp"
+#include "cru/ui/controls/text_block.hpp"
-#include "ui/render/text_render_object.hpp"
-#include "ui/ui_manager.hpp"
+#include "cru/ui/render/text_render_object.hpp"
+#include "cru/ui/ui_manager.hpp"
namespace cru::ui::controls {
using render::TextRenderObject;
@@ -11,7 +11,7 @@ TextBlock::TextBlock() {
UiManager::GetInstance()->GetPredefineResources();
render_object_.reset(
new TextRenderObject(predefined_resources->text_block_text_brush,
- predefined_resources->text_block_text_format,
+ predefined_resources->text_block_font,
predefined_resources->text_block_selection_brush));
}
@@ -19,7 +19,9 @@ render::RenderObject* TextBlock::GetRenderObject() const {
return render_object_.get();
}
-String TextBlock::GetText() const { return render_object_->GetText(); }
+std::wstring TextBlock::GetText() const { return render_object_->GetText(); }
-void TextBlock::SetText(const String& text) { render_object_->SetText(text); }
+void TextBlock::SetText(std::wstring text) {
+ render_object_->SetText(std::move(text));
+}
} // namespace cru::ui::controls
diff --git a/src/ui/controls/text_block.hpp b/src/ui/controls/text_block.hpp
deleted file mode 100644
index 0d65dd67..00000000
--- a/src/ui/controls/text_block.hpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#pragma once
-#include "pre.hpp"
-
-#include <memory>
-
-#include "ui/no_child_control.hpp"
-
-namespace cru::ui::render {
-class TextRenderObject;
-}
-
-namespace cru::ui::controls {
-class TextBlock : public NoChildControl {
- public:
- static constexpr auto control_type = L"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 = default;
-
- StringView GetControlType() const override final { return control_type; }
-
- render::RenderObject* GetRenderObject() const override;
-
- String GetText() const;
- void SetText(const String& text);
-
- private:
- std::shared_ptr<render::TextRenderObject> render_object_;
-};
-} // namespace cru::ui::controls