Handle shadow outline in gui

This commit is contained in:
kaetemi 2014-10-08 23:20:35 +02:00
parent 523761d7b7
commit a1262b71b2
6 changed files with 72 additions and 4 deletions

View file

@ -381,6 +381,7 @@ namespace NLGUI
bool _CloseSubMenuUsingPopModal; bool _CloseSubMenuUsingPopModal;
bool _Shadow; bool _Shadow;
bool _ShadowOutline;
bool _Formatted; bool _Formatted;
uint8 _Space; uint8 _Space;
sint32 _FontSize; sint32 _FontSize;

View file

@ -48,7 +48,7 @@ namespace NLGUI
/// Constructor /// Constructor
CViewText (const std::string& id, const std::string Text="", sint FontSize=12, CViewText (const std::string& id, const std::string Text="", sint FontSize=12,
NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), bool Shadow=false); NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), bool Shadow=false, bool ShadowOutline=false);
virtual ~CViewText(); virtual ~CViewText();
@ -83,6 +83,7 @@ namespace NLGUI
void setFontSize (sint nFontSize); void setFontSize (sint nFontSize);
void setColor (const NLMISC::CRGBA &color); void setColor (const NLMISC::CRGBA &color);
void setShadow (bool bShadow); void setShadow (bool bShadow);
void setShadowOutline (bool bShadowOutline);
void setShadowColor (const NLMISC::CRGBA &color); void setShadowColor (const NLMISC::CRGBA &color);
void setLineMaxW (sint nMaxW, bool invalidate=true); void setLineMaxW (sint nMaxW, bool invalidate=true);
void setMultiLine (bool bMultiLine); void setMultiLine (bool bMultiLine);
@ -102,6 +103,7 @@ namespace NLGUI
sint getFontSize() const; sint getFontSize() const;
NLMISC::CRGBA getColor() { return _Color; } NLMISC::CRGBA getColor() { return _Color; }
bool getShadow() { return _Shadow; } bool getShadow() { return _Shadow; }
bool getShadowOutline() { return _ShadowOutline; }
NLMISC::CRGBA getShadowColor() { return _ShadowColor; } NLMISC::CRGBA getShadowColor() { return _ShadowColor; }
sint getLineMaxW() const { return _LineMaxW; } sint getLineMaxW() const { return _LineMaxW; }
bool getMultiLine() const { return _MultiLine; } bool getMultiLine() const { return _MultiLine; }
@ -225,6 +227,7 @@ namespace NLGUI
NLMISC::CRGBA _Color; NLMISC::CRGBA _Color;
/// the shadow mode /// the shadow mode
bool _Shadow; bool _Shadow;
bool _ShadowOutline;
/// the case mode /// the case mode
TCaseMode _CaseMode; TCaseMode _CaseMode;
/// the text shadow color /// the text shadow color

View file

@ -3713,6 +3713,7 @@ namespace NLGUI
_TitleOpened->setParentPosRef (Hotspot_TL); _TitleOpened->setParentPosRef (Hotspot_TL);
_TitleOpened->setPosRef (Hotspot_TL); _TitleOpened->setPosRef (Hotspot_TL);
_TitleOpened->setShadow (true); _TitleOpened->setShadow (true);
_TitleOpened->setShadowOutline (false);
_TitleOpened->setColor (CRGBA(255,255,255,255)); _TitleOpened->setColor (CRGBA(255,255,255,255));
_TitleOpened->setModulateGlobalColor(getModulateGlobalColor()); _TitleOpened->setModulateGlobalColor(getModulateGlobalColor());
_TitleOpened->setOverExtendViewText(_TitleOverExtendViewText); _TitleOpened->setOverExtendViewText(_TitleOverExtendViewText);
@ -3764,6 +3765,7 @@ namespace NLGUI
_TitleClosed->setParentPosRef (Hotspot_TL); _TitleClosed->setParentPosRef (Hotspot_TL);
_TitleClosed->setPosRef (Hotspot_TL); _TitleClosed->setPosRef (Hotspot_TL);
_TitleClosed->setShadow (true); _TitleClosed->setShadow (true);
_TitleClosed->setShadowOutline (false);
_TitleClosed->setColor (CRGBA(255,255,255,255)); _TitleClosed->setColor (CRGBA(255,255,255,255));
_TitleClosed->setModulateGlobalColor(getModulateGlobalColor()); _TitleClosed->setModulateGlobalColor(getModulateGlobalColor());
_TitleClosed->setOverExtendViewText(_TitleOverExtendViewText); _TitleClosed->setOverExtendViewText(_TitleOverExtendViewText);

View file

@ -1203,6 +1203,7 @@ namespace NLGUI
pV->setColor (_GroupMenu->_Color); pV->setColor (_GroupMenu->_Color);
pV->setFontSize (_GroupMenu->_FontSize); pV->setFontSize (_GroupMenu->_FontSize);
pV->setShadow (_GroupMenu->_Shadow); pV->setShadow (_GroupMenu->_Shadow);
pV->setShadowOutline (_GroupMenu->_ShadowOutline);
pV->setCheckable(checkable); pV->setCheckable(checkable);
pV->setChecked(checked); pV->setChecked(checked);
pV->setModulateGlobalColor(_GroupMenu->_ModulateGlobalColor); pV->setModulateGlobalColor(_GroupMenu->_ModulateGlobalColor);
@ -1282,6 +1283,7 @@ namespace NLGUI
pV->setColor (_GroupMenu->_Color); pV->setColor (_GroupMenu->_Color);
pV->setFontSize (_GroupMenu->_FontSize); pV->setFontSize (_GroupMenu->_FontSize);
pV->setShadow (_GroupMenu->_Shadow); pV->setShadow (_GroupMenu->_Shadow);
pV->setShadowOutline (_GroupMenu->_ShadowOutline);
pV->setCheckable(checkable); pV->setCheckable(checkable);
pV->setChecked(checked); pV->setChecked(checked);
pV->setModulateGlobalColor(_GroupMenu->_ModulateGlobalColor); pV->setModulateGlobalColor(_GroupMenu->_ModulateGlobalColor);
@ -1922,6 +1924,7 @@ namespace NLGUI
_HighLightOver.set(128, 0, 0, 255); _HighLightOver.set(128, 0, 0, 255);
_FontSize = 12; _FontSize = 12;
_Shadow = false; _Shadow = false;
_ShadowOutline = false;
_ResizeFromChildH = _ResizeFromChildW = true; _ResizeFromChildH = _ResizeFromChildW = true;
_DisplayFrame = false; _DisplayFrame = false;
_RootMenu = NULL; _RootMenu = NULL;
@ -1998,6 +2001,11 @@ namespace NLGUI
return toString( _Shadow ); return toString( _Shadow );
} }
else else
if( name == "shadow_outline" )
{
return toString( _ShadowOutline );
}
else
if( name == "formatted" ) if( name == "formatted" )
{ {
return toString( _Formatted ); return toString( _Formatted );
@ -2110,6 +2118,14 @@ namespace NLGUI
return; return;
} }
else else
if( name == "shadow_outline" )
{
bool b;
if( fromString( value, b ) )
_ShadowOutline = b;
return;
}
else
if( name == "formatted" ) if( name == "formatted" )
{ {
bool b; bool b;
@ -2152,6 +2168,7 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "space", BAD_CAST toString( _Space ).c_str() ); xmlSetProp( node, BAD_CAST "space", BAD_CAST toString( _Space ).c_str() );
xmlSetProp( node, BAD_CAST "fontsize", BAD_CAST toString( _FontSize ).c_str() ); xmlSetProp( node, BAD_CAST "fontsize", BAD_CAST toString( _FontSize ).c_str() );
xmlSetProp( node, BAD_CAST "shadow", BAD_CAST toString( _Shadow ).c_str() ); xmlSetProp( node, BAD_CAST "shadow", BAD_CAST toString( _Shadow ).c_str() );
xmlSetProp( node, BAD_CAST "shadow_outline", BAD_CAST toString( _ShadowOutline ).c_str() );
xmlSetProp( node, BAD_CAST "formatted", BAD_CAST toString( _Formatted ).c_str() ); xmlSetProp( node, BAD_CAST "formatted", BAD_CAST toString( _Formatted ).c_str() );
if( _RootMenu == NULL ) if( _RootMenu == NULL )
@ -2197,6 +2214,7 @@ namespace NLGUI
_Color = gm->_Color; _Color = gm->_Color;
_ShadowColor = gm->_ShadowColor; _ShadowColor = gm->_ShadowColor;
_Shadow = gm->_Shadow; _Shadow = gm->_Shadow;
_ShadowOutline = gm->_ShadowOutline;
_FontSize = gm->_FontSize; _FontSize = gm->_FontSize;
_ColorOver = gm->_ColorOver; _ColorOver = gm->_ColorOver;
_ShadowColorOver = gm->_ShadowColorOver; _ShadowColorOver = gm->_ShadowColorOver;
@ -2266,6 +2284,10 @@ namespace NLGUI
if (prop) if (prop)
_Shadow = convertBool(prop); _Shadow = convertBool(prop);
prop = (char*) xmlGetProp( in, (xmlChar*)"shadow_outline" );
if (prop)
_ShadowOutline = convertBool(prop);
prop = (char*) xmlGetProp( in, (xmlChar*)"formatted" ); prop = (char*) xmlGetProp( in, (xmlChar*)"formatted" );
if (prop) if (prop)
_Formatted = convertBool(prop); _Formatted = convertBool(prop);

View file

@ -62,6 +62,7 @@ namespace NLGUI
CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32(); CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32();
_Color = CRGBA(255,255,255,255); _Color = CRGBA(255,255,255,255);
_Shadow = false; _Shadow = false;
_ShadowOutline = false;
_ShadowColor = CRGBA(0,0,0,255); _ShadowColor = CRGBA(0,0,0,255);
_MultiLine = false; _MultiLine = false;
@ -111,7 +112,7 @@ namespace NLGUI
///constructor ///constructor
// *************************************************************************** // ***************************************************************************
CViewText:: CViewText (const std::string& id, const std::string Text, sint FontSize, CViewText:: CViewText (const std::string& id, const std::string Text, sint FontSize,
NLMISC::CRGBA Color, bool Shadow) NLMISC::CRGBA Color, bool Shadow, bool ShadowOutline)
:CViewBase(TCtorParam()) :CViewBase(TCtorParam())
{ {
_Id = id; _Id = id;
@ -120,6 +121,7 @@ namespace NLGUI
_FontSize = FontSize + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); _FontSize = FontSize + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32();
_Color = Color; _Color = Color;
_Shadow = Shadow; _Shadow = Shadow;
_ShadowOutline = ShadowOutline;
setText(Text); setText(Text);
computeFontSize (); computeFontSize ();
} }
@ -159,6 +161,7 @@ namespace NLGUI
_FontSize = vt._FontSize; _FontSize = vt._FontSize;
_Color = vt._Color; _Color = vt._Color;
_Shadow = vt._Shadow; _Shadow = vt._Shadow;
_ShadowOutline = vt._ShadowOutline;
_ShadowColor = vt._ShadowColor; _ShadowColor = vt._ShadowColor;
_MultiLine = false; _MultiLine = false;
@ -225,6 +228,11 @@ namespace NLGUI
return toString( _Shadow ); return toString( _Shadow );
} }
else else
if( name == "shadow_outline" )
{
return toString( _ShadowOutline );
}
else
if( name == "shadow_color" ) if( name == "shadow_color" )
{ {
return toString( _ShadowColor ); return toString( _ShadowColor );
@ -360,6 +368,14 @@ namespace NLGUI
return true; return true;
} }
else else
if( name == "shadow_outline" )
{
bool b;
if( fromString( value, b ) )
_ShadowOutline = b;
return true;
}
else
if( name == "shadow_color" ) if( name == "shadow_color" )
{ {
CRGBA c; CRGBA c;
@ -520,6 +536,7 @@ namespace NLGUI
).c_str() ); ).c_str() );
xmlSetProp( node, BAD_CAST "shadow", BAD_CAST toString( _Shadow ).c_str() ); xmlSetProp( node, BAD_CAST "shadow", BAD_CAST toString( _Shadow ).c_str() );
xmlSetProp( node, BAD_CAST "shadow_outline", BAD_CAST toString( _ShadowOutline ).c_str() );
xmlSetProp( node, BAD_CAST "shadow_color", BAD_CAST toString( _ShadowColor ).c_str() ); xmlSetProp( node, BAD_CAST "shadow_color", BAD_CAST toString( _ShadowColor ).c_str() );
xmlSetProp( node, BAD_CAST "multi_line", BAD_CAST toString( _MultiLine ).c_str() ); xmlSetProp( node, BAD_CAST "multi_line", BAD_CAST toString( _MultiLine ).c_str() );
@ -604,6 +621,11 @@ namespace NLGUI
if (prop) if (prop)
_Shadow = convertBool(prop); _Shadow = convertBool(prop);
prop = (char*) xmlGetProp( cur, (xmlChar*)"shadow_outline" );
_ShadowOutline = false;
if (prop)
_ShadowOutline = convertBool(prop);
prop= (char*) xmlGetProp( cur, (xmlChar*)"shadow_color" ); prop= (char*) xmlGetProp( cur, (xmlChar*)"shadow_color" );
_ShadowColor = CRGBA(0,0,0,255); _ShadowColor = CRGBA(0,0,0,255);
if (prop) if (prop)
@ -864,6 +886,7 @@ namespace NLGUI
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setShadeOutline (_ShadowOutline);
TextContext->setShadeColor (shcol); TextContext->setShadeColor (shcol);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
@ -978,6 +1001,7 @@ namespace NLGUI
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setShadeOutline (_ShadowOutline);
TextContext->setShadeColor (shcol); TextContext->setShadeColor (shcol);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
@ -1146,6 +1170,14 @@ namespace NLGUI
invalidateContent(); invalidateContent();
} }
// ***************************************************************************
void CViewText::setShadowOutline (bool bShadowOutline)
{
_ShadowOutline = bShadowOutline;
computeFontSize ();
invalidateContent();
}
// *************************************************************************** // ***************************************************************************
void CViewText::setShadowColor(const NLMISC::CRGBA & color) void CViewText::setShadowColor(const NLMISC::CRGBA & color)
{ {
@ -1647,6 +1679,7 @@ namespace NLGUI
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setShadeOutline (_ShadowOutline);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
// default state // default state
@ -1958,6 +1991,7 @@ namespace NLGUI
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setShadeOutline (_ShadowOutline);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
// CViewRenderer &rVR = *CViewRenderer::getInstance(); // CViewRenderer &rVR = *CViewRenderer::getInstance();
height = getFontHeight(); height = getFontHeight();
@ -2089,6 +2123,7 @@ namespace NLGUI
// setup the text context // setup the text context
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setShadeOutline (_ShadowOutline);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
// find the line where the character is // find the line where the character is
// CViewRenderer &rVR = *CViewRenderer::getInstance(); // CViewRenderer &rVR = *CViewRenderer::getInstance();
@ -2363,6 +2398,7 @@ namespace NLGUI
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setShadeOutline (_ShadowOutline);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
TCharPos linePos = 0; TCharPos linePos = 0;
@ -2447,6 +2483,7 @@ namespace NLGUI
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setShadeOutline (_ShadowOutline);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
// Current position in text // Current position in text
@ -2498,12 +2535,13 @@ namespace NLGUI
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setShadeOutline (_ShadowOutline);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
// Letter size // Letter size
UTextContext::CStringInfo si = TextContext->getStringInfo(ucstring("|")); // for now we can't now that directly from UTextContext UTextContext::CStringInfo si = TextContext->getStringInfo(ucstring("|")); // for now we can't now that directly from UTextContext
_FontHeight = (uint) si.StringHeight + (_Shadow?1:0); _FontHeight = (uint) si.StringHeight + (_Shadow?(_ShadowOutline?2:1):0);
_FontLegHeight = (uint) si.StringLine + (_Shadow?1:0); _FontLegHeight = (uint) si.StringLine + (_Shadow?(_ShadowOutline?2:1):0);
// Space width // Space width
si = TextContext->getStringInfo(ucstring(" ")); si = TextContext->getStringInfo(ucstring(" "));
@ -2960,6 +2998,7 @@ namespace NLGUI
f.serial(_SpaceWidth); f.serial(_SpaceWidth);
f.serial(_Color); f.serial(_Color);
f.serial(_Shadow); f.serial(_Shadow);
f.serial(_ShadowOutline);
f.serialEnum(_CaseMode); f.serialEnum(_CaseMode);
f.serial(_ShadowColor); f.serial(_ShadowColor);
f.serial(_LineMaxW); f.serial(_LineMaxW);

View file

@ -1186,6 +1186,7 @@ namespace NLGUI
vtDst->setColor (vtSrc->getColor()); vtDst->setColor (vtSrc->getColor());
vtDst->setModulateGlobalColor(vtSrc->getModulateGlobalColor()); vtDst->setModulateGlobalColor(vtSrc->getModulateGlobalColor());
vtDst->setShadow(vtSrc->getShadow()); vtDst->setShadow(vtSrc->getShadow());
vtDst->setShadowOutline(vtSrc->getShadowOutline());
vtDst->setShadowColor(vtSrc->getShadowColor()); vtDst->setShadowColor(vtSrc->getShadowColor());
vtDst->setCaseMode(vtSrc->getCaseMode()); vtDst->setCaseMode(vtSrc->getCaseMode());
vtDst->setUnderlined(vtSrc->getUnderlined()); vtDst->setUnderlined(vtSrc->getUnderlined());