diff options
author | crupest <crupest@outlook.com> | 2021-11-21 20:42:54 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-11-21 20:42:54 +0800 |
commit | 3f8e493423b7cfe96ab53531078b803da7beccbe (patch) | |
tree | a0a998c6b2b696eaf4f58870224fef31e65e3dbd /src/ui | |
parent | 73b90d4fe6c93a288ca6514432fe1e83ddcf4928 (diff) | |
download | cru-3f8e493423b7cfe96ab53531078b803da7beccbe.tar.gz cru-3f8e493423b7cfe96ab53531078b803da7beccbe.tar.bz2 cru-3f8e493423b7cfe96ab53531078b803da7beccbe.zip |
...
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/controls/RootControl.cpp | 2 | ||||
-rw-r--r-- | src/ui/controls/TextHostControlService.cpp | 4 | ||||
-rw-r--r-- | src/ui/render/TextRenderObject.cpp | 10 |
3 files changed, 13 insertions, 3 deletions
diff --git a/src/ui/controls/RootControl.cpp b/src/ui/controls/RootControl.cpp index d89982c5..278649de 100644 --- a/src/ui/controls/RootControl.cpp +++ b/src/ui/controls/RootControl.cpp @@ -41,7 +41,7 @@ void RootControl::SetGainFocusOnCreateAndDestroyWhenLoseFocus(bool value) { gain_focus_on_create_and_destroy_when_lose_focus_event_guard_ += native_window->FocusEvent()->AddHandler( [native_window](platform::gui::FocusChangeType type) { - if (type == platform::gui::FocusChangeType::Lost) { + if (type == platform::gui::FocusChangeType::Lose) { native_window->Close(); } }); diff --git a/src/ui/controls/TextHostControlService.cpp b/src/ui/controls/TextHostControlService.cpp index 46c02f50..870d643f 100644 --- a/src/ui/controls/TextHostControlService.cpp +++ b/src/ui/controls/TextHostControlService.cpp @@ -55,7 +55,7 @@ TextControlMovePattern TextControlMovePattern::kUp( gsl::index current_position) { auto text_render_object = service->GetTextRenderObject(); auto rect = text_render_object->TextSinglePoint(current_position, false); - rect.top -= text_render_object->GetFont()->GetFontSize(); + rect.top -= 1.f; auto result = text_render_object->TextHitTest(rect.GetLeftTop()); return result.trailing ? result.position + 1 : result.position; }); @@ -65,7 +65,7 @@ TextControlMovePattern TextControlMovePattern::kDown( gsl::index current_position) { auto text_render_object = service->GetTextRenderObject(); auto rect = text_render_object->TextSinglePoint(current_position, false); - rect.top += text_render_object->GetFont()->GetFontSize(); + rect.top += rect.height + 0.1f; auto result = text_render_object->TextHitTest(rect.GetLeftTop()); return result.trailing ? result.position + 1 : result.position; }); diff --git a/src/ui/render/TextRenderObject.cpp b/src/ui/render/TextRenderObject.cpp index e1036072..0e65da92 100644 --- a/src/ui/render/TextRenderObject.cpp +++ b/src/ui/render/TextRenderObject.cpp @@ -64,6 +64,16 @@ void TextRenderObject::SetEditMode(bool enable) { text_layout_->SetEditMode(enable); } +Index TextRenderObject::GetLineCount() { return text_layout_->GetLineCount(); } + +Index TextRenderObject::GetLineIndexFromCharIndex(Index char_index) { + return text_layout_->GetLineIndexFromCharIndex(char_index); +} + +float TextRenderObject::GetLineHeight(Index line_index) { + return text_layout_->GetLineHeight(line_index); +} + std::vector<Rect> TextRenderObject::TextRangeRect(const TextRange& text_range) { return text_layout_->TextRangeRect(text_range); } |