mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 22:18:19 +00:00
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:
parent
ca90d83c10
commit
08b0a03ca4
|
@ -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,21 +1645,32 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
if(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex != -1 && TextContainer.m_HasCursor)
|
||||
if(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex != -1)
|
||||
{
|
||||
const auto CurTime = time_get_nanoseconds();
|
||||
|
||||
Graphics()->TextureClear();
|
||||
if((CurTime - m_CursorRenderTime) > 500ms)
|
||||
if(TextContainer.m_HasSelection)
|
||||
{
|
||||
Graphics()->SetColor(TextOutlineColor);
|
||||
Graphics()->RenderQuadContainerEx(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, 0, 1, 0, 0);
|
||||
Graphics()->SetColor(TextColor);
|
||||
Graphics()->RenderQuadContainerEx(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, 1, 1, 0, 0);
|
||||
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();
|
||||
|
||||
Graphics()->TextureClear();
|
||||
if((CurTime - m_CursorRenderTime) > 500ms)
|
||||
{
|
||||
Graphics()->SetColor(TextOutlineColor);
|
||||
Graphics()->RenderQuadContainerEx(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, 0, 1, 0, 0);
|
||||
Graphics()->SetColor(TextColor);
|
||||
Graphics()->RenderQuadContainerEx(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, 1, 1, 0, 0);
|
||||
}
|
||||
if((CurTime - m_CursorRenderTime) > 1s)
|
||||
m_CursorRenderTime = time_get_nanoseconds();
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
if((CurTime - m_CursorRenderTime) > 1s)
|
||||
m_CursorRenderTime = time_get_nanoseconds();
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue