From ca90d83c103812427027c2098edc4e0e09ff3bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Fri, 14 Apr 2023 15:02:55 +0200 Subject: [PATCH] Allow adjusting height factor of text selection rectangle Add `CTextCursor::m_SelectionHeightFactor` setting to adjust the height of the text selection rectangle. For example a value of `0.5f` means that the selection rectangle has half its normal height while still being aligned at the same bottom position. --- src/engine/client/text.cpp | 3 ++- src/engine/textrender.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp index 47b0e3b80..fd0e8ece0 100644 --- a/src/engine/client/text.cpp +++ b/src/engine/client/text.cpp @@ -800,6 +800,7 @@ public: pCursor->m_LongestLineWidth = 0; pCursor->m_CalculateSelectionMode = TEXT_CURSOR_SELECTION_MODE_NONE; + pCursor->m_SelectionHeightFactor = 1.0f; pCursor->m_PressMouseX = 0; pCursor->m_PressMouseY = 0; pCursor->m_ReleaseMouseX = 0; @@ -1409,7 +1410,7 @@ public: if(SelectionStarted && IsRendered) { - vSelectionQuads.emplace_back(SelX, DrawY, SelWidth, Size); + vSelectionQuads.emplace_back(SelX, DrawY + (1.0f - pCursor->m_SelectionHeightFactor) * Size, SelWidth, pCursor->m_SelectionHeightFactor * Size); } LastSelX = SelX; diff --git a/src/engine/textrender.h b/src/engine/textrender.h index 23ad9d806..05ee344de 100644 --- a/src/engine/textrender.h +++ b/src/engine/textrender.h @@ -183,6 +183,7 @@ public: float m_AlignedFontSize; ETextCursorSelectionMode m_CalculateSelectionMode; + float m_SelectionHeightFactor; // these coordinates are repsected if selection mode is set to calculate @see ETextCursorSelectionMode int m_PressMouseX;