mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 22:18:19 +00:00
Add text cursor setting to always render caret (disable blinking)
Add flag to temporarily cause the caret to not blink, so the caret can be rendered without blinking after it has been moved, which greatly improves usability.
This commit is contained in:
parent
08b0a03ca4
commit
f77af29094
|
@ -167,6 +167,7 @@ struct STextContainer
|
||||||
unsigned m_RenderFlags;
|
unsigned m_RenderFlags;
|
||||||
|
|
||||||
bool m_HasCursor;
|
bool m_HasCursor;
|
||||||
|
bool m_ForceCursorRendering;
|
||||||
bool m_HasSelection;
|
bool m_HasSelection;
|
||||||
|
|
||||||
bool m_SingleTimeUse;
|
bool m_SingleTimeUse;
|
||||||
|
@ -193,6 +194,7 @@ struct STextContainer
|
||||||
|
|
||||||
m_HasCursor = false;
|
m_HasCursor = false;
|
||||||
m_HasSelection = false;
|
m_HasSelection = false;
|
||||||
|
m_ForceCursorRendering = false;
|
||||||
|
|
||||||
m_SingleTimeUse = false;
|
m_SingleTimeUse = false;
|
||||||
|
|
||||||
|
@ -809,6 +811,7 @@ public:
|
||||||
pCursor->m_SelectionEnd = 0;
|
pCursor->m_SelectionEnd = 0;
|
||||||
|
|
||||||
pCursor->m_CursorMode = TEXT_CURSOR_CURSOR_MODE_NONE;
|
pCursor->m_CursorMode = TEXT_CURSOR_CURSOR_MODE_NONE;
|
||||||
|
pCursor->m_ForceCursorRendering = false;
|
||||||
pCursor->m_CursorCharacter = -1;
|
pCursor->m_CursorCharacter = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1505,6 +1508,7 @@ public:
|
||||||
|
|
||||||
TextContainer.m_HasCursor = HasCursor;
|
TextContainer.m_HasCursor = HasCursor;
|
||||||
TextContainer.m_HasSelection = HasSelection;
|
TextContainer.m_HasSelection = HasSelection;
|
||||||
|
TextContainer.m_ForceCursorRendering = pCursor->m_ForceCursorRendering;
|
||||||
|
|
||||||
if(HasSelection)
|
if(HasSelection)
|
||||||
{
|
{
|
||||||
|
@ -1660,14 +1664,16 @@ public:
|
||||||
const auto CurTime = time_get_nanoseconds();
|
const auto CurTime = time_get_nanoseconds();
|
||||||
|
|
||||||
Graphics()->TextureClear();
|
Graphics()->TextureClear();
|
||||||
if((CurTime - m_CursorRenderTime) > 500ms)
|
if(TextContainer.m_ForceCursorRendering || (CurTime - m_CursorRenderTime) > 500ms)
|
||||||
{
|
{
|
||||||
Graphics()->SetColor(TextOutlineColor);
|
Graphics()->SetColor(TextOutlineColor);
|
||||||
Graphics()->RenderQuadContainerEx(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, 0, 1, 0, 0);
|
Graphics()->RenderQuadContainerEx(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, 0, 1, 0, 0);
|
||||||
Graphics()->SetColor(TextColor);
|
Graphics()->SetColor(TextColor);
|
||||||
Graphics()->RenderQuadContainerEx(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, 1, 1, 0, 0);
|
Graphics()->RenderQuadContainerEx(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, 1, 1, 0, 0);
|
||||||
}
|
}
|
||||||
if((CurTime - m_CursorRenderTime) > 1s)
|
if(TextContainer.m_ForceCursorRendering)
|
||||||
|
m_CursorRenderTime = CurTime - 501ms;
|
||||||
|
else if((CurTime - m_CursorRenderTime) > 1s)
|
||||||
m_CursorRenderTime = time_get_nanoseconds();
|
m_CursorRenderTime = time_get_nanoseconds();
|
||||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,6 +198,7 @@ public:
|
||||||
int m_SelectionEnd;
|
int m_SelectionEnd;
|
||||||
|
|
||||||
ETextCursorCursorMode m_CursorMode;
|
ETextCursorCursorMode m_CursorMode;
|
||||||
|
bool m_ForceCursorRendering;
|
||||||
// note this is the decoded character offset
|
// note this is the decoded character offset
|
||||||
int m_CursorCharacter;
|
int m_CursorCharacter;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue