From f23077eb0ddff77b7e114994f967189ea7607600 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 1 Mar 2020 22:32:58 +0800 Subject: Complete hit test in text layout. --- include/cru/platform/graph/text_layout.hpp | 8 ++++++++ include/cru/win/graph/direct/text_layout.hpp | 2 ++ 2 files changed, 10 insertions(+) (limited to 'include') diff --git a/include/cru/platform/graph/text_layout.hpp b/include/cru/platform/graph/text_layout.hpp index 4f6e81e1..d1cfb44b 100644 --- a/include/cru/platform/graph/text_layout.hpp +++ b/include/cru/platform/graph/text_layout.hpp @@ -8,6 +8,12 @@ namespace cru::platform::graph { struct IFont; +struct TextHitTestResult { + int position; + bool trailing; + bool insideText; +}; + struct ITextLayout : virtual IGraphResource { virtual std::string GetText() = 0; virtual void SetText(std::string new_text) = 0; @@ -20,5 +26,7 @@ struct ITextLayout : virtual IGraphResource { virtual Rect GetTextBounds() = 0; virtual std::vector TextRangeRect(const TextRange& text_range) = 0; + virtual Point TextSingleRect(int position, bool trailing) = 0; + virtual TextHitTestResult HitTest(const Point& point) = 0; }; } // namespace cru::platform::graph diff --git a/include/cru/win/graph/direct/text_layout.hpp b/include/cru/win/graph/direct/text_layout.hpp index 5a8f3f9c..5f7be9f3 100644 --- a/include/cru/win/graph/direct/text_layout.hpp +++ b/include/cru/win/graph/direct/text_layout.hpp @@ -38,6 +38,8 @@ class DWriteTextLayout : public DirectGraphResource, Rect GetTextBounds() override; std::vector TextRangeRect(const TextRange& text_range) override; + Point TextSingleRect(int position, bool trailing) override; + TextHitTestResult HitTest(const Point& point) override; private: std::string text_; -- cgit v1.2.3