Parse background style into own class

develop
Nimetu 3 years ago
parent 285cfb163f
commit 12c515c264

@ -21,6 +21,8 @@
#include "nel/misc/rgba.h"
#include "nel/gui/css_selector.h"
#include "nel/gui/css_types.h"
#include "nel/gui/css_length.h"
#include "nel/gui/css_background.h"
namespace NLGUI
{
@ -70,7 +72,6 @@ namespace NLGUI
BorderTopStyle = BorderRightStyle = BorderBottomStyle = BorderLeftStyle = CSS_LINE_STYLE_NONE;
BorderTopColor = BorderRightColor = BorderBottomColor = BorderLeftColor = NLMISC::CRGBA::Transparent;
// background
BackgroundColor=NLMISC::CRGBA::Black;
BackgroundColorOver=NLMISC::CRGBA::Black;
MarginTop = MarginRight = MarginBottom = MarginLeft = 0;
PaddingTop = PaddingRight = PaddingBottom = PaddingLeft = 0;
@ -105,7 +106,7 @@ namespace NLGUI
uint32 BorderTopWidth, BorderRightWidth, BorderBottomWidth, BorderLeftWidth;
CSSLineStyle BorderTopStyle, BorderRightStyle, BorderBottomStyle, BorderLeftStyle;
NLMISC::CRGBA BorderTopColor, BorderRightColor, BorderBottomColor, BorderLeftColor;
NLMISC::CRGBA BackgroundColor;
CSSBackground Background;
NLMISC::CRGBA BackgroundColorOver;
uint32 MarginTop, MarginRight, MarginBottom, MarginLeft;
uint32 PaddingTop, PaddingRight, PaddingBottom, PaddingLeft;
@ -229,7 +230,7 @@ namespace NLGUI
Current.BorderTopStyle = Current.BorderRightStyle = Current.BorderBottomStyle = Current.BorderLeftStyle = CSS_LINE_STYLE_NONE;
Current.BorderTopColor = Current.BorderRightColor = Current.BorderBottomColor = Current.BorderLeftColor = Current.TextColor;
Current.BackgroundColor = NLMISC::CRGBA::Transparent;
Current.Background = CSSBackground();
Current.BackgroundColorOver = NLMISC::CRGBA::Transparent;
Current.MarginTop = Current.MarginRight = Current.MarginBottom = Current.MarginLeft = 0;

@ -957,13 +957,13 @@ namespace NLGUI
if (it->first == "background-color")
{
if (it->second == "inherit")
style.BackgroundColor = current.BackgroundColor;
style.Background.color = current.Background.color;
else if (it->second == "transparent")
style.BackgroundColor = CRGBA(0, 0, 0, 0);
style.Background.color = CRGBA(0, 0, 0, 0);
else if (it->second == "currentcolor")
style.BackgroundColorOver = style.TextColor;
style.Background.color = style.TextColor;
else
scanHTMLColor(it->second.c_str(), style.BackgroundColor);
scanHTMLColor(it->second.c_str(), style.Background.color);
}
else
if (it->first == "-ryzom-background-color-over")
@ -987,10 +987,13 @@ namespace NLGUI
image = image.substr(4, image.size()-5);
}
style.StyleRules[it->first] = trimQuotes(image);
style.Background.setImage(style.StyleRules[it->first]);
}
else
if (it->first == "background-repeat")
{
style.Background.setRepeat(it->second);
// TODO: remove after removing old code that depends on this
// normalize
std::string val = toLowerAscii(trim(it->second));
std::vector<std::string> parts;
@ -1004,6 +1007,8 @@ namespace NLGUI
else
if (it->first == "background-size")
{
style.Background.setSize(it->second);
// TODO: remove after removing old code that depends on this
// normalize
std::string val = toLowerAscii(trim(it->second));
std::vector<std::string> parts;
@ -1013,6 +1018,27 @@ namespace NLGUI
style.StyleRules[it->first] = val;
}
else
if (it->first == "background-position")
{
// TODO: background-position-x, background-position-y
style.Background.setPosition(it->second);
}
else
if (it->first == "background-origin")
{
style.Background.setOrigin(it->second);
}
else
if (it->first == "background-clip")
{
style.Background.setClip(it->second);
}
else
if (it->first == "background-attachment")
{
style.Background.setAttachment(it->second);
}
}
// if outer element has underline set, then inner element cannot remove it
@ -1348,10 +1374,10 @@ namespace NLGUI
}
else
{
// fill in default if one is set
// fill in default if one is not set
if (props[i] == "background-image")
{
style[props[i]] = "none";
style[props[i]] = "";
}
else if (props[i] == "background-position")
{

@ -538,14 +538,14 @@ namespace NLGUI
if (style.hasStyle("background-color"))
{
ctrlButton->setColor(style.BackgroundColor);
ctrlButton->setColor(style.Background.color);
if (style.hasStyle("-ryzom-background-color-over"))
{
ctrlButton->setColorOver(style.BackgroundColorOver);
}
else
{
ctrlButton->setColorOver(style.BackgroundColor);
ctrlButton->setColorOver(style.Background.color);
}
ctrlButton->setTexture("", "blank.tga", "", false);
ctrlButton->setTextureOver("", "blank.tga", "");
@ -2706,7 +2706,7 @@ namespace NLGUI
if (bg)
{
bg->setTexture("blank.tga");
bg->setColor(style.BackgroundColor);
bg->setColor(style.Background.color);
}
}
}
@ -4082,7 +4082,7 @@ namespace NLGUI
clearContext();
// Reset default background color
setBackgroundColor (_BrowserStyle.Current.BackgroundColor);
setBackgroundColor (_BrowserStyle.Current.Background.color);
setBackground ("blank.tga", true, false);
paragraphChange ();
@ -4940,7 +4940,7 @@ namespace NLGUI
style.pushStyle();
style.applyStyle(elm.getPseudo(":-webkit-meter-bar"));
if(style.hasStyle("background-color"))
color = style.Current.BackgroundColor;
color = style.Current.Background.color;
style.popStyle();
return color;
@ -4957,14 +4957,14 @@ namespace NLGUI
{
style.applyStyle(elm.getPseudo(":-webkit-meter-optimum-value"));
if (style.hasStyle("background-color"))
color = style.Current.BackgroundColor;
color = style.Current.Background.color;
break;
}
case VALUE_SUB_OPTIMAL:
{
style.applyStyle(elm.getPseudo(":-webkit-meter-suboptimum-value"));
if (style.hasStyle("background-color"))
color = style.Current.BackgroundColor;
color = style.Current.Background.color;
break;
}
case VALUE_EVEN_LESS_GOOD: // fall through
@ -4972,7 +4972,7 @@ namespace NLGUI
{
style.applyStyle(elm.getPseudo(":-webkit-meter-even-less-good-value"));
if (style.hasStyle("background-color"))
color = style.Current.BackgroundColor;
color = style.Current.Background.color;
break;
}
}//switch
@ -5009,7 +5009,7 @@ namespace NLGUI
style.pushStyle();
style.applyStyle(elm.getPseudo(":-webkit-progress-bar"));
if (style.hasStyle("background-color"))
color = style.Current.BackgroundColor;
color = style.Current.Background.color;
style.popStyle();
return color;
@ -5023,7 +5023,7 @@ namespace NLGUI
style.pushStyle();
style.applyStyle(elm.getPseudo(":-webkit-progress-value"));
if (style.hasStyle("background-color"))
color = style.Current.BackgroundColor;
color = style.Current.Background.color;
style.popStyle();
return color;
@ -5037,7 +5037,7 @@ namespace NLGUI
cellParams = _CellParams.back();
if (_Style.hasStyle("background-color"))
cellParams.BgColor = _Style.Current.BackgroundColor;
cellParams.BgColor = _Style.Current.Background.color;
else if (elm.hasNonEmptyAttribute("bgcolor"))
scanHTMLColor(elm.getAttribute("bgcolor").c_str(), cellParams.BgColor);
@ -5120,7 +5120,7 @@ namespace NLGUI
if (_Style.hasStyle("background-color"))
{
CRGBA bgColor = _Style.Current.BackgroundColor;
CRGBA bgColor = _Style.Current.Background.color;
scanHTMLColor(elm.getAttribute("bgcolor").c_str(), bgColor);
if (root)
{

@ -46,7 +46,7 @@ void checkRuleset(CHtmlElement &elm, CCssStyle &style, TStyleVec testset, bool e
}
else if (it.first == "background-color")
{
printf("[%s]: background-color: '%s'; expected '%s'\n", existsMessage.c_str(), style.Current.BackgroundColor.toString().c_str(), it.second.c_str());
printf("[%s]: background-color: '%s'; expected '%s'\n", existsMessage.c_str(), style.Current.Background.color.toString().c_str(), it.second.c_str());
printf(" (%s)\n", elm.toString().c_str());
failed2 = false;
}

Loading…
Cancel
Save