diff options
author | crupest <crupest@outlook.com> | 2020-05-23 23:50:00 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-05-23 23:50:00 +0800 |
commit | f3a8fd608a9776ef0a5f547da918a32cf6074060 (patch) | |
tree | 85b320479296ae12339ee1e28bab66ab001cb44b /include/cru/ui | |
parent | 75ff8a6a05afd02aaadf7e3049b0a0e305241182 (diff) | |
download | cru-f3a8fd608a9776ef0a5f547da918a32cf6074060.tar.gz cru-f3a8fd608a9776ef0a5f547da918a32cf6074060.tar.bz2 cru-f3a8fd608a9776ef0a5f547da918a32cf6074060.zip |
...
Diffstat (limited to 'include/cru/ui')
-rw-r--r-- | include/cru/ui/control.hpp | 6 | ||||
-rw-r--r-- | include/cru/ui/controls/text_box.hpp | 6 | ||||
-rw-r--r-- | include/cru/ui/render/scroll_render_object.hpp | 30 |
3 files changed, 36 insertions, 6 deletions
diff --git a/include/cru/ui/control.hpp b/include/cru/ui/control.hpp index 30dc589a..d66405e6 100644 --- a/include/cru/ui/control.hpp +++ b/include/cru/ui/control.hpp @@ -147,12 +147,6 @@ class Control : public Object { private: bool is_mouse_over_ = false; - struct { - bool left; - bool middle; - bool right; - } click_map_; - std::shared_ptr<platform::native::ICursor> cursor_ = nullptr; }; } // namespace cru::ui diff --git a/include/cru/ui/controls/text_box.hpp b/include/cru/ui/controls/text_box.hpp index c0160658..15fcb734 100644 --- a/include/cru/ui/controls/text_box.hpp +++ b/include/cru/ui/controls/text_box.hpp @@ -2,6 +2,8 @@ #include "../no_child_control.hpp" #include "base.hpp" +#include <memory> + namespace cru::ui::controls { template <typename TControl> class TextControlService; @@ -10,6 +12,8 @@ class TextBox : public NoChildControl { public: static constexpr std::string_view control_type = "TextBox"; + static TextBox* Create() { return new TextBox(); } + protected: TextBox(); @@ -21,6 +25,8 @@ class TextBox : public NoChildControl { std::string_view GetControlType() const final { return control_type; } + render::RenderObject* GetRenderObject() const override; + render::TextRenderObject* GetTextRenderObject(); const TextBoxBorderStyle& GetBorderStyle(); diff --git a/include/cru/ui/render/scroll_render_object.hpp b/include/cru/ui/render/scroll_render_object.hpp new file mode 100644 index 00000000..1527db6c --- /dev/null +++ b/include/cru/ui/render/scroll_render_object.hpp @@ -0,0 +1,30 @@ +#pragma once +#include "render_object.hpp" + +#include "cru/platform/graph/util/painter.hpp" + +namespace cru::ui::render { +class ScrollRenderObject : public RenderObject { + public: + ScrollRenderObject() : RenderObject(ChildMode::Single) {} + + CRU_DELETE_COPY(ScrollRenderObject) + CRU_DELETE_MOVE(ScrollRenderObject) + + ~ScrollRenderObject() override = default; + + void Draw(platform::graph::IPainter* painter) override; + + RenderObject* HitTest(const Point& point) override; + + Point GetScrollOffset() { return scroll_offset_; } + void SetScrollOffset(const Point& offset); + + protected: + void OnAddChild(RenderObject* new_child, Index position) override; + void OnRemoveChild(RenderObject* removed_child, Index position) override; + + private: + Point scroll_offset_; +}; +} // namespace cru::ui::render |