From 977baa3a42a8b813e75a3666809155604cb6713d Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 21 Apr 2020 17:29:37 +0800 Subject: ... --- include/cru/platform/graph/text_layout.hpp | 2 +- include/cru/platform/graph_base.hpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'include/cru/platform') diff --git a/include/cru/platform/graph/text_layout.hpp b/include/cru/platform/graph/text_layout.hpp index 20009c0d..0d104742 100644 --- a/include/cru/platform/graph/text_layout.hpp +++ b/include/cru/platform/graph/text_layout.hpp @@ -17,7 +17,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 Point TextSingleRect(gsl::index position, bool trailing) = 0; virtual TextHitTestResult HitTest(const Point& point) = 0; }; } // namespace cru::platform::graph diff --git a/include/cru/platform/graph_base.hpp b/include/cru/platform/graph_base.hpp index f25a7baf..0b997770 100644 --- a/include/cru/platform/graph_base.hpp +++ b/include/cru/platform/graph_base.hpp @@ -218,6 +218,11 @@ struct TextRange final { return TextRange(start, end - start); } + constexpr static TextRange FromTwoSides(gsl::index start, gsl::index end, + gsl::index offset) { + return TextRange(start + offset, end - start); + } + constexpr TextRange() = default; constexpr TextRange(const gsl::index position, const gsl::index count = 0) : position(position), count(count) {} -- cgit v1.2.3