From 835ec1f25454cd14c5eda45b5bcb614c894fc948 Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 16 Nov 2021 21:02:21 +0800 Subject: ... --- include/cru/osx/graphics/quartz/TextLayout.hpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'include/cru/osx') diff --git a/include/cru/osx/graphics/quartz/TextLayout.hpp b/include/cru/osx/graphics/quartz/TextLayout.hpp index 35bcc32d..b9bf5e44 100644 --- a/include/cru/osx/graphics/quartz/TextLayout.hpp +++ b/include/cru/osx/graphics/quartz/TextLayout.hpp @@ -28,6 +28,9 @@ class OsxCTTextLayout : public OsxQuartzResource, public virtual ITextLayout { void SetMaxWidth(float max_width) override; void SetMaxHeight(float max_height) override; + bool IsEditMode() override; + void SetEditMode(bool enable) override; + Rect GetTextBounds(bool includingTrailingSpace = false) override; std::vector TextRangeRect(const TextRange& text_range) override; Rect TextSinglePoint(Index position, bool trailing) override; @@ -45,17 +48,22 @@ class OsxCTTextLayout : public OsxQuartzResource, public virtual ITextLayout { void ReleaseResource(); void RecreateFrame(); - Rect DoGetTextBounds(bool includingTrailingSpace = false); - std::vector DoTextRangeRect(const TextRange& text_range); - Rect DoTextSinglePoint(Index position, bool trailing); + CGRect DoGetTextBounds(bool includingTrailingSpace = false); + CGRect DoGetTextBoundsIncludingEmptyLines( + bool includingTrailingSpace = false); + std::vector DoTextRangeRect(const TextRange& text_range); + CGRect DoTextSinglePoint(Index position, bool trailing); private: float max_width_; float max_height_; + bool edit_mode_; + std::shared_ptr font_; String text_; + String actual_text_; CFMutableAttributedStringRef cf_attributed_text_; CTFramesetterRef ct_framesetter_ = nullptr; @@ -64,6 +72,10 @@ class OsxCTTextLayout : public OsxQuartzResource, public virtual ITextLayout { int line_count_; std::vector line_origins_; std::vector lines_; + // The empty line count in the front of the lines. + int head_empty_line_count_; + // The trailing empty line count in the back of the lines. + int tail_empty_line_count_; Matrix transform_; }; -- cgit v1.2.3