From 882d843083895f4905571dc273e801ee18fd5984 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 12 Jan 2022 02:30:25 +0800 Subject: ... --- src/win/graphics/direct/TextLayout.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/win/graphics/direct/TextLayout.cpp') diff --git a/src/win/graphics/direct/TextLayout.cpp b/src/win/graphics/direct/TextLayout.cpp index 0b3c68ca..6ece8ed1 100644 --- a/src/win/graphics/direct/TextLayout.cpp +++ b/src/win/graphics/direct/TextLayout.cpp @@ -9,10 +9,9 @@ #include namespace cru::platform::graphics::win::direct { -DWriteTextLayout::DWriteTextLayout(DirectGraphFactory* factory, - std::shared_ptr font, - std::u16string text) - : DirectGraphResource(factory), text_(std::move(text)) { +DWriteTextLayout::DWriteTextLayout(DirectGraphicsFactory* factory, + std::shared_ptr font, String text) + : DirectGraphicsResource(factory), text_(std::move(text)) { Expects(font); font_ = CheckPlatform(font, GetPlatformId()); @@ -24,12 +23,10 @@ DWriteTextLayout::DWriteTextLayout(DirectGraphFactory* factory, DWriteTextLayout::~DWriteTextLayout() = default; -std::u16string DWriteTextLayout::GetText() { return text_; } +String DWriteTextLayout::GetText() { return text_; } -std::u16string_view DWriteTextLayout::GetTextView() { return text_; } - -void DWriteTextLayout::SetText(std::u16string new_text) { - text_.swap(new_text); +void DWriteTextLayout::SetText(String new_text) { + text_ = std::move(new_text); ThrowIfFailed(GetDirectFactory()->GetDWriteFactory()->CreateTextLayout( reinterpret_cast(text_.c_str()), static_cast(text_.size()), font_->GetComInterface(), max_width_, @@ -100,14 +97,14 @@ std::vector DWriteTextLayout::TextRangeRect( return result; } -Point DWriteTextLayout::TextSinglePoint(Index position, bool trailing) { +Rect DWriteTextLayout::TextSinglePoint(Index position, bool trailing) { DWRITE_HIT_TEST_METRICS metrics; FLOAT left; FLOAT top; ThrowIfFailed(text_layout_->HitTestTextPosition(static_cast(position), static_cast(trailing), &left, &top, &metrics)); - return Point{left, top}; + return Rect{left, top, 0, GetFont()->GetFontSize()}; } TextHitTestResult DWriteTextLayout::HitTest(const Point& point) { @@ -121,7 +118,6 @@ TextHitTestResult DWriteTextLayout::HitTest(const Point& point) { TextHitTestResult result; result.position = metrics.textPosition; result.trailing = trailing != 0; - result.insideText = inside != 0; return result; } } // namespace cru::platform::graphics::win::direct -- cgit v1.2.3