From f13c49219eaafb56c214de53eaa07c1469c8f884 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 16 Dec 2021 15:24:42 +0200 Subject: [PATCH] Disable text shadow on selection text (closes ryzom/ryzomcore#214 --- nel/include/nel/gui/view_text.h | 3 +++ nel/src/gui/group_editbox.cpp | 3 +++ nel/src/gui/view_text.cpp | 11 +++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/nel/include/nel/gui/view_text.h b/nel/include/nel/gui/view_text.h index cc92cf47d..c5b4ba197 100644 --- a/nel/include/nel/gui/view_text.h +++ b/nel/include/nel/gui/view_text.h @@ -118,6 +118,8 @@ namespace NLGUI // Force only a subset of letter to be displayed. Default is 0/0xFFFFFFFF void enableStringSelection(uint start, uint end); void disableStringSelection(); + void setShadowInSelection(bool s) { m_DisableShadowInSelection = !s; } + bool getShadowInSelection() const { return !m_DisableShadowInSelection; } /// Get std::string getText() const { return _HardText.empty() ? _Text : _HardText; } @@ -448,6 +450,7 @@ namespace NLGUI bool _StrikeThrough : 1; bool _ContinuousUpdate : 1; bool _Setuped : 1; + bool m_DisableShadowInSelection : 1; uint _TextSelectionStart; uint _TextSelectionEnd; diff --git a/nel/src/gui/group_editbox.cpp b/nel/src/gui/group_editbox.cpp index 1410e2cb1..5aa5f104a 100644 --- a/nel/src/gui/group_editbox.cpp +++ b/nel/src/gui/group_editbox.cpp @@ -755,6 +755,9 @@ namespace NLGUI // Display the selection if needed if (_CurrSelection == this && _SelectCursorPos!=_CursorPos) { + // flush so that selection quad is covering text + rVR.flush(); + sint32 blankTextId= rVR.getBlankTextureId(); CRGBA col= _BackSelectColor; col.A= CWidgetManager::getInstance()->getGlobalColorForContent().A; diff --git a/nel/src/gui/view_text.cpp b/nel/src/gui/view_text.cpp index d9b60d794..4ac79f9a8 100644 --- a/nel/src/gui/view_text.cpp +++ b/nel/src/gui/view_text.cpp @@ -99,6 +99,7 @@ namespace NLGUI _TextSelection= false; _TextSelectionStart= 0; _TextSelectionEnd= std::numeric_limits::max(); + m_DisableShadowInSelection = true; _InvalidTextContext= true; _FirstLineX = 0; @@ -1188,9 +1189,10 @@ namespace NLGUI { if (_Lines.empty()) return; + bool drawShadow = !(_TextSelection && m_DisableShadowInSelection); TextContext->setHotSpot (UTextContext::BottomLeft); - TextContext->setShaded (_Shadow); - TextContext->setShadeOutline (_ShadowOutline); + TextContext->setShaded (_Shadow && drawShadow); + TextContext->setShadeOutline (_ShadowOutline && drawShadow); TextContext->setShadeColor (shcol); TextContext->setShadeExtent (_ShadowX*oow, _ShadowY*ooh); TextContext->setFontSize (_FontSize*_Scale); @@ -1320,9 +1322,10 @@ namespace NLGUI { nlassert(_Index != 0xFFFFFFFF); + bool drawShadow = !(_TextSelection && m_DisableShadowInSelection); TextContext->setHotSpot (UTextContext::BottomLeft); - TextContext->setShaded (_Shadow); - TextContext->setShadeOutline (_ShadowOutline); + TextContext->setShaded (_Shadow && drawShadow); + TextContext->setShadeOutline (_ShadowOutline && drawShadow); TextContext->setShadeColor (shcol); TextContext->setShadeExtent (_ShadowX*oow, _ShadowY*ooh); TextContext->setFontSize (_FontSize*_Scale);