Render selection in front of text instead of behind it

Makes the text selection easier to see, especially when the text selection height is lower than normal.

Change text selection color to light grey instead of blue.
This commit is contained in:
Robert Müller 2023-04-14 15:04:51 +02:00
parent ca90d83c10
commit 08b0a03ca4
2 changed files with 24 additions and 21 deletions

View file

@ -1590,14 +1590,6 @@ public:
const STextContainer &TextContainer = GetTextContainer(TextContainerIndex);
const CFont *pFont = TextContainer.m_pFont;
if(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex != -1 && TextContainer.m_HasSelection)
{
Graphics()->TextureClear();
Graphics()->SetColor(m_SelectionColor);
Graphics()->RenderQuadContainerEx(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, TextContainer.m_HasCursor ? 2 : 0, -1, 0, 0);
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
}
if(TextContainer.m_StringInfo.m_QuadNum > 0)
{
if(Graphics()->IsTextBufferingEnabled())
@ -1653,7 +1645,17 @@ public:
}
}
if(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex != -1 && TextContainer.m_HasCursor)
if(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex != -1)
{
if(TextContainer.m_HasSelection)
{
Graphics()->TextureClear();
Graphics()->SetColor(m_SelectionColor);
Graphics()->RenderQuadContainerEx(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, TextContainer.m_HasCursor ? 2 : 0, -1, 0, 0);
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
}
if(TextContainer.m_HasCursor)
{
const auto CurTime = time_get_nanoseconds();
@ -1670,6 +1672,7 @@ public:
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
}
}
}
void RenderTextContainer(int TextContainerIndex, const ColorRGBA &TextColor, const ColorRGBA &TextOutlineColor, float X, float Y) override
{

View file

@ -233,7 +233,7 @@ public:
ColorRGBA DefaultTextColor() const { return ColorRGBA(1, 1, 1, 1); }
ColorRGBA DefaultTextOutlineColor() const { return ColorRGBA(0, 0, 0, 0.3f); }
ColorRGBA DefaultTextSelectionColor() const { return ColorRGBA(0, 0, 1.0f, 1.0f); }
ColorRGBA DefaultTextSelectionColor() const { return ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f); }
//
virtual void TextEx(CTextCursor *pCursor, const char *pText, int Length = -1) = 0;