aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/render
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-03-03 23:36:45 +0800
committercrupest <crupest@outlook.com>2020-03-03 23:36:45 +0800
commit0dcf8e686b93cca54a424affe0455d0a97d6c2ef (patch)
tree744897a3b6a29f6142f1943dab5d9957e670919b /include/cru/ui/render
parent47053829c322c43032244937cb63f9da178b852d (diff)
downloadcru-0dcf8e686b93cca54a424affe0455d0a97d6c2ef.tar.gz
cru-0dcf8e686b93cca54a424affe0455d0a97d6c2ef.tar.bz2
cru-0dcf8e686b93cca54a424affe0455d0a97d6c2ef.zip
...
Diffstat (limited to 'include/cru/ui/render')
-rw-r--r--include/cru/ui/render/layout_utility.hpp7
-rw-r--r--include/cru/ui/render/render_object.hpp9
-rw-r--r--include/cru/ui/render/text_render_object.hpp7
3 files changed, 16 insertions, 7 deletions
diff --git a/include/cru/ui/render/layout_utility.hpp b/include/cru/ui/render/layout_utility.hpp
index 38191ad5..5cf74e71 100644
--- a/include/cru/ui/render/layout_utility.hpp
+++ b/include/cru/ui/render/layout_utility.hpp
@@ -1,6 +1,7 @@
+#pragma once
#include "../base.hpp"
namespace cru::ui::render {
- Size Min(const Size& left, const Size& right);
- Size Max(const Size& left, const Size& right);
-}
+Size Min(const Size& left, const Size& right);
+Size Max(const Size& left, const Size& right);
+} // namespace cru::ui::render
diff --git a/include/cru/ui/render/render_object.hpp b/include/cru/ui/render/render_object.hpp
index 0f0cb8df..d9851757 100644
--- a/include/cru/ui/render/render_object.hpp
+++ b/include/cru/ui/render/render_object.hpp
@@ -70,6 +70,8 @@ class RenderObject : public Object {
Point GetOffset() const { return offset_; }
void SetOffset(const Point& offset) { offset_ = offset; }
+ Point GetTotalOffset() const;
+ Point FromRootToContent(const Point& point) const;
Size GetSize() const { return size_; }
void SetSize(const Size& size) { size_ = size; }
@@ -91,9 +93,7 @@ class RenderObject : public Object {
virtual RenderObject* HitTest(const Point& point) = 0;
- protected:
- void SetChildMode(ChildMode mode) { child_mode_ = mode; }
-
+ public:
void InvalidateLayout() const {
if (render_host_ != nullptr) render_host_->InvalidateLayout();
}
@@ -103,6 +103,9 @@ class RenderObject : public Object {
}
protected:
+ void SetChildMode(ChildMode mode) { child_mode_ = mode; }
+
+ protected:
virtual void OnParentChanged(RenderObject* old_parent,
RenderObject* new_parent);
diff --git a/include/cru/ui/render/text_render_object.hpp b/include/cru/ui/render/text_render_object.hpp
index 5394ee0a..33d34f78 100644
--- a/include/cru/ui/render/text_render_object.hpp
+++ b/include/cru/ui/render/text_render_object.hpp
@@ -1,6 +1,8 @@
#pragma once
#include "render_object.hpp"
+#include "cru/platform/graph/text_layout.hpp"
+
#include <memory>
#include <string>
@@ -8,7 +10,6 @@
namespace cru::platform::graph {
struct IBrush;
struct IFont;
-struct ITextLayout;
} // namespace cru::platform::graph
namespace cru::ui::render {
@@ -34,6 +35,10 @@ class TextRenderObject : public RenderObject {
std::shared_ptr<platform::graph::IFont> GetFont() const;
void SetFont(std::shared_ptr<platform::graph::IFont> font);
+ std::vector<Rect> TextRangeRect(const TextRange& text_range);
+ Point TextSingleRect(int position, bool trailing);
+ platform::graph::TextHitTestResult TextHitTest(const Point& point);
+
std::optional<TextRange> GetSelectionRange() const {
return selection_range_;
}