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.
This commit is contained in:
Robert Müller 2023-04-14 15:02:55 +02:00
parent facbcfc391
commit ca90d83c10
2 changed files with 3 additions and 1 deletions

View file

@ -800,6 +800,7 @@ public:
pCursor->m_LongestLineWidth = 0; pCursor->m_LongestLineWidth = 0;
pCursor->m_CalculateSelectionMode = TEXT_CURSOR_SELECTION_MODE_NONE; pCursor->m_CalculateSelectionMode = TEXT_CURSOR_SELECTION_MODE_NONE;
pCursor->m_SelectionHeightFactor = 1.0f;
pCursor->m_PressMouseX = 0; pCursor->m_PressMouseX = 0;
pCursor->m_PressMouseY = 0; pCursor->m_PressMouseY = 0;
pCursor->m_ReleaseMouseX = 0; pCursor->m_ReleaseMouseX = 0;
@ -1409,7 +1410,7 @@ public:
if(SelectionStarted && IsRendered) 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; LastSelX = SelX;

View file

@ -183,6 +183,7 @@ public:
float m_AlignedFontSize; float m_AlignedFontSize;
ETextCursorSelectionMode m_CalculateSelectionMode; ETextCursorSelectionMode m_CalculateSelectionMode;
float m_SelectionHeightFactor;
// these coordinates are repsected if selection mode is set to calculate @see ETextCursorSelectionMode // these coordinates are repsected if selection mode is set to calculate @see ETextCursorSelectionMode
int m_PressMouseX; int m_PressMouseX;