From 028f6cdd3e32d23e1412c8c77a8444057284587c Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sat, 18 Sep 2021 17:26:53 +0300 Subject: [PATCH 1/4] Add -ryzom-modulate-text-color to separate text from background, ryzom/ryzomcore#644 --- nel/include/nel/gui/css_style.h | 3 +++ nel/src/gui/css_style.cpp | 10 ++++++++++ nel/src/gui/group_html.cpp | 12 +++++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/nel/include/nel/gui/css_style.h b/nel/include/nel/gui/css_style.h index 042486d17..674f0268e 100644 --- a/nel/include/nel/gui/css_style.h +++ b/nel/include/nel/gui/css_style.h @@ -63,6 +63,7 @@ namespace NLGUI Underlined=false; StrikeThrough=false; GlobalColor=false; + GlobalColorText=false; DisplayBlock=false; Width=-1; Height=-1; @@ -93,6 +94,7 @@ namespace NLGUI NLMISC::CRGBA TextColor; STextShadow TextShadow; bool GlobalColor; + bool GlobalColorText; bool Underlined; bool StrikeThrough; bool DisplayBlock; @@ -215,6 +217,7 @@ namespace NLGUI _StyleStack.push_back(Current); Current.GlobalColor = false; + // inherit GlobalColorText Current.DisplayBlock = false; Current.Width=-1; Current.Height=-1; diff --git a/nel/src/gui/css_style.cpp b/nel/src/gui/css_style.cpp index 912ff04d4..567ffe42a 100644 --- a/nel/src/gui/css_style.cpp +++ b/nel/src/gui/css_style.cpp @@ -936,6 +936,16 @@ namespace NLGUI style.GlobalColor = b; } else + if (it->first == "-ryzom-modulate-text-color") + { + bool b; + if (it->second == "inherit") + style.GlobalColorText = current.GlobalColorText; + else + if (fromString(it->second, b)) + style.GlobalColorText = b; + } + else if (it->first == "background-color") { if (it->second == "inherit") diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp index 1dd28d473..0cb32f25e 100644 --- a/nel/src/gui/group_html.cpp +++ b/nel/src/gui/group_html.cpp @@ -2551,7 +2551,7 @@ namespace NLGUI (embolden == text->getEmbolden()) && (style.FontOblique == text->getOblique()) && (getLink() == text->Link) && - (style.GlobalColor == text->getModulateGlobalColor()); + (style.GlobalColorText == text->getModulateGlobalColor()); } // *************************************************************************** @@ -2588,7 +2588,10 @@ namespace NLGUI nlinfo("Text button template '%s' is missing :button or :b text element", tpl.c_str()); return; } - ctrlButton->setModulateGlobalColorAll(false); + ctrlButton->setModulateGlobalColorAll(_Style.Current.GlobalColor); + ctrlButton->setTextModulateGlobalColorNormal(_Style.Current.GlobalColorText); + ctrlButton->setTextModulateGlobalColorOver(_Style.Current.GlobalColorText); + ctrlButton->setTextModulateGlobalColorPushed(_Style.Current.GlobalColorText); // Translate the tooltip ctrlButton->setText(text); @@ -2619,7 +2622,7 @@ namespace NLGUI newLink->setText(text); newLink->setMultiLineSpace((uint)((float)(_Style.Current.FontSize)*LineSpaceFontFactor)); newLink->setMultiLine(true); - newLink->setModulateGlobalColor(_Style.Current.GlobalColor); + newLink->setModulateGlobalColor(_Style.Current.GlobalColorText); setTextStyle(newLink, _Style.Current); registerAnchor(newLink); @@ -5247,6 +5250,9 @@ namespace NLGUI if (ctrlButton) { ctrlButton->setModulateGlobalColorAll (_Style.Current.GlobalColor); + ctrlButton->setTextModulateGlobalColorNormal(_Style.Current.GlobalColorText); + ctrlButton->setTextModulateGlobalColorOver(_Style.Current.GlobalColorText); + ctrlButton->setTextModulateGlobalColorPushed(_Style.Current.GlobalColorText); // Translate the tooltip if (!tooltip.empty()) From 5c53148907435dd301c44f99ea332d20f738bd7a Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sat, 18 Sep 2021 17:30:25 +0300 Subject: [PATCH 2/4] Fix downloaded background images not showing --- nel/src/gui/group_html.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp index 0cb32f25e..5d7a66eed 100644 --- a/nel/src/gui/group_html.cpp +++ b/nel/src/gui/group_html.cpp @@ -350,7 +350,7 @@ namespace NLGUI void CGroupHTML::TextureDownloadCB::finish() { // tmpdest file does not exist if download skipped (ie cache was used) - if (CFile::fileExists(tmpdest) && CFile::getFileSize(tmpdest) == 0) + if (CFile::fileExists(tmpdest) && CFile::getFileSize(tmpdest) > 0) { if (CFile::fileExists(dest)) CFile::deleteFile(dest); From fc6ecc7dbd62723463410f9c9199b2f8ca6a35e7 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sat, 18 Sep 2021 17:40:41 +0300 Subject: [PATCH 3/4] Fix html,body background not using container opacity --- nel/src/gui/group_html.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp index 5d7a66eed..021a3691a 100644 --- a/nel/src/gui/group_html.cpp +++ b/nel/src/gui/group_html.cpp @@ -4120,6 +4120,22 @@ namespace NLGUI void CGroupHTML::draw () { + uint8 CurrentAlpha = 255; + // search a parent container + CInterfaceGroup *gr = getParent(); + while (gr) + { + if (gr->isGroupContainer()) + { + CGroupContainer *gc = static_cast(gr); + CurrentAlpha = gc->getCurrentContainerAlpha(); + break; + } + gr = gr->getParent(); + } + m_HtmlBackground.CurrentAlpha = CurrentAlpha; + m_BodyBackground.CurrentAlpha = CurrentAlpha; + m_HtmlBackground.draw(); m_BodyBackground.draw(); CGroupScrollText::draw (); From 9ecda657916edf4301e515b81e101749a7e41af2 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sun, 19 Sep 2021 14:08:16 +0300 Subject: [PATCH 4/4] Fix table td background color inheriting from row --- nel/include/nel/gui/group_html.h | 3 +++ nel/src/gui/group_html.cpp | 18 +++++++----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/nel/include/nel/gui/group_html.h b/nel/include/nel/gui/group_html.h index 4315d8059..8b6ad19b6 100644 --- a/nel/include/nel/gui/group_html.h +++ b/nel/include/nel/gui/group_html.h @@ -391,6 +391,9 @@ namespace NLGUI CSSBackgroundRenderer m_HtmlBackground; CSSBackgroundRenderer m_BodyBackground; + // active table.tr background color from css or from bgcolor attribute + std::vector m_TableRowBackgroundColor; + // Valid base href was found bool _IgnoreBaseUrlTag; // Fragment from loading url diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp index 021a3691a..10472851c 100644 --- a/nel/src/gui/group_html.cpp +++ b/nel/src/gui/group_html.cpp @@ -3076,6 +3076,7 @@ namespace NLGUI _IgnoreHeadTag = false; _IgnoreBaseUrlTag = false; _AutoIdSeq = 0; + m_TableRowBackgroundColor.clear(); paragraphChange (); @@ -6607,20 +6608,11 @@ namespace NLGUI // *************************************************************************** void CGroupHTML::htmlTD(const CHtmlElement &elm) { - CRGBA rowColor = CRGBA::Transparent; - // remember row color so we can blend it with cell color - if (!_CellParams.empty()) - rowColor = _CellParams.back().BgColor; - // Get cells parameters getCellsParameters(elm, true); - // if cell has own background,then it must be blended with row - if (rowColor.A > 0 && _Style.Current.Background.color.A < 255) - { - _Style.Current.Background.color.blendFromui(rowColor, - _Style.Current.Background.color, _Style.Current.Background.color.A); - } + if (!m_TableRowBackgroundColor.empty() && m_TableRowBackgroundColor.back().A > 0) + _Style.Current.Background.color.blendFromui(m_TableRowBackgroundColor.back(), _Style.Current.Background.color, _Style.Current.Background.color.A); if (elm.ID == HTML_TH) { @@ -6836,6 +6828,9 @@ namespace NLGUI // Get cells parameters getCellsParameters(elm, true); + m_TableRowBackgroundColor.push_back(_CellParams.back().BgColor); + _CellParams.back().BgColor = CRGBA::Transparent; + // TODO: this probably ends up in first cell renderPseudoElement(":before", elm); @@ -6850,6 +6845,7 @@ namespace NLGUI renderPseudoElement(":after", elm); popIfNotEmpty(_CellParams); + popIfNotEmpty(m_TableRowBackgroundColor); } // ***************************************************************************