From d32877ddc98f3349612c029b0918184b82f05b55 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 10 Aug 2018 16:00:43 +0300 Subject: [PATCH 1/4] Changed: Keep track of style states in a single struct --HG-- branch : develop --- code/nel/include/nel/gui/group_html.h | 82 ++---- code/nel/src/gui/group_html.cpp | 368 +++++++++++--------------- 2 files changed, 174 insertions(+), 276 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 35ba3e40e..0ccd227b7 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -505,78 +505,32 @@ namespace NLGUI // IL mode bool _LI; - // Current text color - std::vector _TextColor; - inline const NLMISC::CRGBA &getTextColor() const + // Current active style + CStyleParams _Style; + // Default style + CStyleParams _StyleDefault; + // Nested style stack + std::vector _StyleParams; + inline void pushStyle() { - if (_TextColor.empty()) - return TextColor; - return _TextColor.back(); + _StyleParams.push_back(_Style); } - - // Current global color flag - std::vector _GlobalColor; - inline bool getGlobalColor() const + inline void popStyle() { - if (_GlobalColor.empty()) - return false; - return _GlobalColor.back(); - } - - // Current font name - std::vector _FontFamily; - inline const char* getFontFamily() const - { - if (_FontFamily.empty()) - return ""; - return _FontFamily.back().c_str(); + if (_StyleParams.empty()) + _Style = _StyleDefault; + else + { + _Style = _StyleParams.back(); + _StyleParams.pop_back(); + } } - // Current font size - std::vector _FontSize; - inline uint getFontSize() const - { - if (_FontSize.empty()) - return TextFontSize; - return _FontSize.back(); - } inline uint getFontSizeSmaller() const { - if (getFontSize() < 5) + if (_Style.FontSize < 5) return 3; - return getFontSize()-2; - } - - std::vector _FontWeight; - inline uint getFontWeight() const - { - if (_FontWeight.empty()) - return 400; - return _FontWeight.back(); - } - - std::vector _FontOblique; - inline bool getFontOblique() const - { - if (_FontOblique.empty()) - return false; - return _FontOblique.back(); - } - - std::vector _FontUnderlined; - inline bool getFontUnderlined() const - { - if (_FontUnderlined.empty()) - return false; - return _FontUnderlined.back(); - } - - std::vector _FontStrikeThrough; - inline bool getFontStrikeThrough() const - { - if (_FontStrikeThrough.empty()) - return false; - return _FontStrikeThrough.back(); + return _Style.FontSize-2; } // Current link diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 9c022934a..46a32fb13 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1485,23 +1485,14 @@ namespace NLGUI { registerAnchorName(MY_HTML_A); - CStyleParams style; - style.FontFamily = getFontFamily(); - style.FontSize = getFontSize(); - style.TextColor = LinkColor; - style.Underlined = true; - style.StrikeThrough = getFontStrikeThrough(); - style.GlobalColor = LinkColorGlobalColor; + pushStyle(); + _Style.TextColor = LinkColor; + _Style.Underlined = true; + _Style.GlobalColor = LinkColorGlobalColor; if (present[HTML_A_STYLE] && value[HTML_A_STYLE]) - getStyleParams(value[HTML_A_STYLE], style); - - _FontFamily.push_back(style.FontFamily); - _FontSize.push_back(style.FontSize); - _TextColor.push_back(style.TextColor); - _FontUnderlined.push_back(style.Underlined); - _FontStrikeThrough.push_back(style.StrikeThrough); - _GlobalColor.push_back(style.GlobalColor); + getStyleParams(value[HTML_A_STYLE], _Style); + _A.push_back(true); _Link.push_back (""); _LinkTitle.push_back(""); @@ -1625,30 +1616,19 @@ namespace NLGUI break; case HTML_FONT: { - bool found = false; + pushStyle(); if (present[HTML_FONT_COLOR] && value[HTML_FONT_COLOR]) { CRGBA color; if (scanHTMLColor(value[HTML_FONT_COLOR], color)) - { - _TextColor.push_back(color); - found = true; - } - } - if (!found) - { - _TextColor.push_back(_TextColor.empty() ? CRGBA::White : _TextColor.back()); + _Style.TextColor = color; } if (present[HTML_FONT_SIZE] && value[HTML_FONT_SIZE]) { uint fontsize; fromString(value[HTML_FONT_SIZE], fontsize); - _FontSize.push_back(fontsize); - } - else - { - _FontSize.push_back(_FontSize.empty() ? TextFontSize : _FontSize.back()); + _Style.FontSize = fontsize; } } break; @@ -1720,46 +1700,64 @@ namespace NLGUI } break; case HTML_H1: - registerAnchorName(MY_HTML_H1); - newParagraph(PBeginSpace); - _FontSize.push_back(H1FontSize); - _TextColor.push_back(H1Color); - _GlobalColor.push_back(H1ColorGlobalColor); + { + registerAnchorName(MY_HTML_H1); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H1FontSize; + _Style.TextColor = H1Color; + _Style.GlobalColor = H1ColorGlobalColor; + } break; case HTML_H2: - registerAnchorName(MY_HTML_H2); - newParagraph(PBeginSpace); - _FontSize.push_back(H2FontSize); - _TextColor.push_back(H2Color); - _GlobalColor.push_back(H2ColorGlobalColor); + { + registerAnchorName(MY_HTML_H2); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H2FontSize; + _Style.TextColor = H2Color; + _Style.GlobalColor = H2ColorGlobalColor; + } break; case HTML_H3: - registerAnchorName(MY_HTML_H3); - newParagraph(PBeginSpace); - _FontSize.push_back(H3FontSize); - _TextColor.push_back(H3Color); - _GlobalColor.push_back(H3ColorGlobalColor); + { + registerAnchorName(MY_HTML_H3); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H3FontSize; + _Style.TextColor = H3Color; + _Style.GlobalColor = H3ColorGlobalColor; + } break; case HTML_H4: - registerAnchorName(MY_HTML_H4); - newParagraph(PBeginSpace); - _FontSize.push_back(H4FontSize); - _TextColor.push_back(H4Color); - _GlobalColor.push_back(H4ColorGlobalColor); + { + registerAnchorName(MY_HTML_H4); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H4FontSize; + _Style.TextColor = H4Color; + _Style.GlobalColor = H4ColorGlobalColor; + } break; case HTML_H5: - registerAnchorName(MY_HTML_H5); - newParagraph(PBeginSpace); - _FontSize.push_back(H5FontSize); - _TextColor.push_back(H5Color); - _GlobalColor.push_back(H5ColorGlobalColor); + { + registerAnchorName(MY_HTML_H5); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H5FontSize; + _Style.TextColor = H5Color; + _Style.GlobalColor = H5ColorGlobalColor; + } break; case HTML_H6: - registerAnchorName(MY_HTML_H6); - newParagraph(PBeginSpace); - _FontSize.push_back(H6FontSize); - _TextColor.push_back(H6Color); - _GlobalColor.push_back(H6ColorGlobalColor); + { + registerAnchorName(MY_HTML_H6); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H6FontSize; + _Style.TextColor = H6Color; + _Style.GlobalColor = H6ColorGlobalColor; + } break; case HTML_IMG: { @@ -1857,15 +1855,15 @@ namespace NLGUI if (present[MY_HTML_INPUT_TYPE] && value[MY_HTML_INPUT_TYPE]) { // by default not inherited, font family defaults to system font - CStyleParams style; - style.TextColor = TextColor; - style.FontSize = TextFontSize; - style.FontWeight = FONT_WEIGHT_NORMAL; - style.FontOblique = false; + pushStyle(); + _Style.TextColor = TextColor; + _Style.FontSize = TextFontSize; + _Style.FontWeight = FONT_WEIGHT_NORMAL; + _Style.FontOblique = false; // Global color flag if (present[MY_HTML_INPUT_GLOBAL_COLOR]) - style.GlobalColor = true; + _Style.GlobalColor = true; // Tooltip const char *tooltip = NULL; @@ -1873,13 +1871,7 @@ namespace NLGUI tooltip = value[MY_HTML_INPUT_ALT]; if (present[MY_HTML_INPUT_STYLE] && value[MY_HTML_INPUT_STYLE]) - getStyleParams(value[MY_HTML_INPUT_STYLE], style); - - _TextColor.push_back(style.TextColor); - _FontFamily.push_back(style.FontFamily); - _FontSize.push_back(style.FontSize); - _FontWeight.push_back(style.FontWeight); - _FontOblique.push_back(style.FontOblique); + getStyleParams(value[MY_HTML_INPUT_STYLE], _Style); string type = toLower(value[MY_HTML_INPUT_TYPE]); if (type == "image") @@ -1899,7 +1891,7 @@ namespace NLGUI // Add the ctrl button addButton (CCtrlButton::PushButton, name, normal, pushed.empty()?normal:pushed, over, - "html_submit_form", param.c_str(), tooltip, style); + "html_submit_form", param.c_str(), tooltip, _Style); } if (type == "button" || type == "submit") { @@ -1954,7 +1946,7 @@ namespace NLGUI if (!ctrlButton) ctrlButton = dynamic_cast(buttonGroup->getCtrl("b")); if (ctrlButton) { - ctrlButton->setModulateGlobalColorAll (style.GlobalColor); + ctrlButton->setModulateGlobalColorAll (_Style.GlobalColor); // Translate the tooltip if (tooltip) @@ -2037,7 +2029,7 @@ namespace NLGUI checked = (present[MY_HTML_INPUT_CHECKED] && value[MY_HTML_INPUT_CHECKED]); // Add the ctrl button - CCtrlButton *checkbox = addButton (btnType, name, normal, pushed, over, "", "", tooltip, style); + CCtrlButton *checkbox = addButton (btnType, name, normal, pushed, over, "", "", tooltip, _Style); if (checkbox) { if (btnType == CCtrlButton::RadioButton) @@ -2091,11 +2083,7 @@ namespace NLGUI } } - popIfNotEmpty(_FontFamily); - popIfNotEmpty(_FontSize); - popIfNotEmpty(_TextColor); - popIfNotEmpty(_FontWeight); - popIfNotEmpty(_FontOblique); + popStyle(); } } break; @@ -2210,25 +2198,12 @@ namespace NLGUI break; case HTML_PRE: { - CStyleParams style; - style.TextColor = getTextColor(); - style.FontFamily = "monospace"; - style.FontSize = getFontSize(); - style.FontWeight = getFontWeight(); - style.FontOblique = getFontOblique(); - style.Underlined = getFontUnderlined(); - style.StrikeThrough = getFontStrikeThrough(); + pushStyle(); + _Style.FontFamily = "monospace"; if (present[HTML_PRE_STYLE] && value[HTML_PRE_STYLE]) - getStyleParams(value[HTML_PRE_STYLE], style); + getStyleParams(value[HTML_PRE_STYLE], _Style); - _TextColor.push_back(style.TextColor); - _FontFamily.push_back(style.FontFamily); - _FontSize.push_back(style.FontSize); - _FontWeight.push_back(style.FontWeight); - _FontOblique.push_back(style.FontOblique); - _FontUnderlined.push_back(style.Underlined); - _FontStrikeThrough.push_back(style.StrikeThrough); _PRE.push_back(true); } @@ -2274,7 +2249,8 @@ namespace NLGUI if (element_number == HTML_TH) { - _FontWeight.push_back(FONT_WEIGHT_BOLD); + pushStyle(); + _Style.FontWeight = FONT_WEIGHT_BOLD; // center if not specified otherwise. TD/TH present/value arrays have same indices if (!(present[MY_HTML_TD_ALIGN] && value[MY_HTML_TD_ALIGN])) _CellParams.back().Align = CGroupCell::Center; @@ -2365,20 +2341,14 @@ namespace NLGUI if (!(_Forms.empty())) { // not inherited by default, font family defaults to system font - CStyleParams style; - style.TextColor = TextColor; - style.FontWeight = FONT_WEIGHT_NORMAL; - style.FontOblique = false; - style.FontSize = TextFontSize; + pushStyle(); + _Style.TextColor = TextColor; + _Style.FontWeight = FONT_WEIGHT_NORMAL; + _Style.FontOblique = false; + _Style.FontSize = TextFontSize; if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE]) - getStyleParams(value[MY_HTML_TEXTAREA_STYLE], style); - - _TextColor.push_back(style.TextColor); - _FontFamily.push_back(style.FontFamily); - _FontSize.push_back(style.FontSize); - _FontWeight.push_back(style.FontWeight); - _FontOblique.push_back(style.FontOblique); + getStyleParams(value[MY_HTML_TEXTAREA_STYLE], _Style); // read general property string templateName; @@ -2460,43 +2430,41 @@ namespace NLGUI break; case HTML_SPAN: { - CStyleParams style; - style.TextColor = getTextColor(); - style.FontFamily = getFontFamily(); - style.FontSize = getFontSize(); - style.FontWeight = getFontWeight(); - style.FontOblique = getFontOblique(); - style.Underlined = getFontUnderlined(); - style.StrikeThrough = getFontStrikeThrough(); - style.GlobalColor = getGlobalColor(); + pushStyle(); if (present[MY_HTML_SPAN_STYLE] && value[MY_HTML_SPAN_STYLE]) - getStyleParams(value[MY_HTML_SPAN_STYLE], style); - - _TextColor.push_back(style.TextColor); - _FontFamily.push_back(style.FontFamily); - _FontSize.push_back(style.FontSize); - _FontWeight.push_back(style.FontWeight); - _FontOblique.push_back(style.FontOblique); - _FontUnderlined.push_back(style.Underlined); - _FontStrikeThrough.push_back(style.StrikeThrough); - _GlobalColor.push_back(style.GlobalColor); + getStyleParams(value[MY_HTML_SPAN_STYLE], _Style); } break; case HTML_DEL: - _FontStrikeThrough.push_back(true); + { + pushStyle(); + _Style.StrikeThrough = true; + } break; case HTML_U: - _FontUnderlined.push_back(true); + { + pushStyle(); + _Style.Underlined = true; + } break; case HTML_EM: - _FontOblique.push_back(true); + { + pushStyle(); + _Style.FontOblique = true; + } break; case HTML_STRONG: - _FontWeight.push_back(FONT_WEIGHT_BOLD); + { + pushStyle(); + _Style.FontWeight = FONT_WEIGHT_BOLD; + } break; case HTML_SMALL: - _FontSize.push_back(getFontSizeSmaller()); + { + pushStyle(); + _Style.FontSize = getFontSizeSmaller(); + } break; case HTML_STYLE: case HTML_SCRIPT: @@ -2521,7 +2489,8 @@ namespace NLGUI if (!_DL.back().DT) { _DL.back().DT = true; - _FontWeight.push_back(FONT_WEIGHT_BOLD); + pushStyle(); + _Style.FontWeight = FONT_WEIGHT_BOLD; } if (!_LI) @@ -2542,7 +2511,7 @@ namespace NLGUI if (_DL.back().DT) { _DL.back().DT = false; - popIfNotEmpty (_FontWeight); + popStyle(); } if (!_DL.back().DD) @@ -2633,16 +2602,10 @@ namespace NLGUI _ReadingHeadTag = false; break; case HTML_FONT: - popIfNotEmpty (_TextColor); - popIfNotEmpty (_FontSize); + popStyle(); break; case HTML_A: - popIfNotEmpty (_FontFamily); - popIfNotEmpty (_FontSize); - popIfNotEmpty (_TextColor); - popIfNotEmpty (_FontUnderlined); - popIfNotEmpty (_FontStrikeThrough); - popIfNotEmpty (_GlobalColor); + popStyle(); popIfNotEmpty (_A); popIfNotEmpty (_Link); popIfNotEmpty (_LinkTitle); @@ -2654,22 +2617,14 @@ namespace NLGUI case HTML_H4: case HTML_H5: case HTML_H6: - popIfNotEmpty (_FontSize); - popIfNotEmpty (_TextColor); - popIfNotEmpty (_GlobalColor); + popStyle(); endParagraph(); break; case HTML_P: endParagraph(); break; case HTML_PRE: - popIfNotEmpty (_FontFamily); - popIfNotEmpty (_FontSize); - popIfNotEmpty (_FontWeight); - popIfNotEmpty (_FontOblique); - popIfNotEmpty (_TextColor); - popIfNotEmpty (_FontUnderlined); - popIfNotEmpty (_FontStrikeThrough); + popStyle(); popIfNotEmpty (_PRE); break; case HTML_DIV: @@ -2692,7 +2647,7 @@ namespace NLGUI // Add a cell break; case HTML_TH: - popIfNotEmpty (_FontWeight); + popStyle(); // no break; case HTML_TD: popIfNotEmpty (_CellParams); @@ -2717,11 +2672,7 @@ namespace NLGUI _Forms.back().Entries.push_back (entry); } - popIfNotEmpty (_FontFamily); - popIfNotEmpty (_FontSize); - popIfNotEmpty (_FontWeight); - popIfNotEmpty (_FontOblique); - popIfNotEmpty (_TextColor); + popStyle(); } popIfNotEmpty (_PRE); @@ -2843,7 +2794,7 @@ namespace NLGUI // unclosed DT if (_DL.back().DT) { - popIfNotEmpty (_FontWeight); + popStyle(); } // unclosed DD @@ -2859,7 +2810,7 @@ namespace NLGUI if (!_DL.empty()) { _DL.back().DT = false; - popIfNotEmpty (_FontWeight); + popStyle(); } break; case HTML_DD: @@ -2874,29 +2825,22 @@ namespace NLGUI } break; case HTML_SPAN: - popIfNotEmpty (_FontFamily); - popIfNotEmpty (_FontSize); - popIfNotEmpty (_FontWeight); - popIfNotEmpty (_FontOblique); - popIfNotEmpty (_TextColor); - popIfNotEmpty (_FontUnderlined); - popIfNotEmpty (_FontStrikeThrough); - popIfNotEmpty (_GlobalColor); + popStyle(); break; case HTML_DEL: - popIfNotEmpty (_FontStrikeThrough); + popStyle(); break; case HTML_U: - popIfNotEmpty (_FontUnderlined); + popStyle(); break; case HTML_EM: - popIfNotEmpty (_FontOblique); + popStyle(); break; case HTML_STRONG: - popIfNotEmpty (_FontWeight); + popStyle(); break; case HTML_SMALL: - popIfNotEmpty (_FontSize); + popStyle(); break; case HTML_STYLE: case HTML_SCRIPT: @@ -4325,7 +4269,7 @@ namespace NLGUI // Text added ? bool added = false; - bool embolden = getFontWeight() >= FONT_WEIGHT_BOLD; + bool embolden = _Style.FontWeight >= FONT_WEIGHT_BOLD; // Number of child in this paragraph if (_CurrentViewLink) @@ -4333,15 +4277,15 @@ namespace NLGUI bool skipLine = !_CurrentViewLink->getText().empty() && *(_CurrentViewLink->getText().rbegin()) == (ucchar) '\n'; // Compatible with current parameters ? if (!skipLine && - (getTextColor() == _CurrentViewLink->getColor()) && - (getFontFamily() == _CurrentViewLink->getFontName()) && - (getFontSize() == (uint)_CurrentViewLink->getFontSize()) && - (getFontUnderlined() == _CurrentViewLink->getUnderlined()) && - (getFontStrikeThrough() == _CurrentViewLink->getStrikeThrough()) && + (_Style.TextColor == _CurrentViewLink->getColor()) && + (_Style.FontFamily == _CurrentViewLink->getFontName()) && + (_Style.FontSize == (uint)_CurrentViewLink->getFontSize()) && + (_Style.Underlined == _CurrentViewLink->getUnderlined()) && + (_Style.StrikeThrough == _CurrentViewLink->getStrikeThrough()) && (embolden == _CurrentViewLink->getEmbolden()) && - (getFontOblique() == _CurrentViewLink->getOblique()) && + (_Style.FontOblique == _CurrentViewLink->getOblique()) && (getLink() == _CurrentViewLink->Link) && - (getGlobalColor() == _CurrentViewLink->getModulateGlobalColor())) + (_Style.GlobalColor == _CurrentViewLink->getModulateGlobalColor())) { // Concat the text _CurrentViewLink->setText(_CurrentViewLink->getText()+tmpStr); @@ -4401,16 +4345,16 @@ namespace NLGUI } } newLink->setText(tmpStr); - newLink->setColor(getTextColor()); - newLink->setFontName(getFontFamily()); - newLink->setFontSize(getFontSize()); + newLink->setColor(_Style.TextColor); + newLink->setFontName(_Style.FontFamily); + newLink->setFontSize(_Style.FontSize); newLink->setEmbolden(embolden); - newLink->setOblique(getFontOblique()); - newLink->setUnderlined(getFontUnderlined()); - newLink->setStrikeThrough(getFontStrikeThrough()); - newLink->setMultiLineSpace((uint)((float)getFontSize()*LineSpaceFontFactor)); + newLink->setOblique(_Style.FontOblique); + newLink->setUnderlined(_Style.Underlined); + newLink->setStrikeThrough(_Style.StrikeThrough); + newLink->setMultiLineSpace((uint)((float)(_Style.FontSize)*LineSpaceFontFactor)); newLink->setMultiLine(true); - newLink->setModulateGlobalColor(getGlobalColor()); + newLink->setModulateGlobalColor(_Style.GlobalColor); // newLink->setLineAtBottom (true); registerAnchor(newLink); @@ -4517,15 +4461,15 @@ namespace NLGUI { // Not added ? std::vector > templateParams; - templateParams.push_back (std::pair ("w", toString (cols*getFontSize()))); + templateParams.push_back (std::pair ("w", toString (cols*_Style.FontSize))); templateParams.push_back (std::pair ("id", name)); templateParams.push_back (std::pair ("prompt", "")); templateParams.push_back (std::pair ("multiline", multiLine?"true":"false")); - templateParams.push_back (std::pair ("fontsize", toString (getFontSize()))); - templateParams.push_back (std::pair ("color", getTextColor().toString())); - if (getFontWeight() >= FONT_WEIGHT_BOLD) + templateParams.push_back (std::pair ("fontsize", toString (_Style.FontSize))); + templateParams.push_back (std::pair ("color", _Style.TextColor.toString())); + if (_Style.FontWeight >= FONT_WEIGHT_BOLD) templateParams.push_back (std::pair ("fontweight", "bold")); - if (getFontOblique()) + if (_Style.FontOblique) templateParams.push_back (std::pair ("fontstyle", "oblique")); if (multiLine) templateParams.push_back (std::pair ("multi_min_line", toString(rows))); @@ -4767,13 +4711,6 @@ namespace NLGUI { _Paragraph = NULL; _PRE.clear(); - _TextColor.clear(); - _GlobalColor.clear(); - _FontSize.clear(); - _FontWeight.clear(); - _FontOblique.clear(); - _FontUnderlined.clear(); - _FontStrikeThrough.clear(); _Indent.clear(); _LI = false; _UL.clear(); @@ -4797,6 +4734,11 @@ namespace NLGUI _IgnoreHeadTag = false; _IgnoreBaseUrlTag = false; + // reset style + _StyleDefault = CStyleParams(); + _Style = _StyleDefault; + _StyleParams.clear(); + // TR paragraphChange (); @@ -6118,6 +6060,8 @@ namespace NLGUI // style.StrikeThrough; // text-decoration: line-through; text-decoration-line: line-through; void CGroupHTML::getStyleParams(const std::string &styleString, CStyleParams &style, bool inherit) { + const CStyleParams current = _Style; + float tmpf; TStyle styles = parseStyle(styleString); TStyle::iterator it; @@ -6126,7 +6070,7 @@ namespace NLGUI if (it->first == "font-size") { if (it->second == "inherit") - style.FontSize = getFontSize(); + style.FontSize = current.FontSize; else { float tmp; @@ -6140,7 +6084,7 @@ namespace NLGUI if (it->first == "font-style") { if (it->second == "inherit") - style.FontOblique = getFontOblique(); + style.FontOblique = current.FontOblique; else if (it->second == "italic" || it->second == "oblique") style.FontOblique = true; @@ -6149,7 +6093,7 @@ namespace NLGUI if (it->first == "font-family") { if (it->second == "inherit") - style.FontFamily = getFontFamily(); + style.FontFamily = current.FontFamily; else if (it->second == "monospace") style.FontFamily = "monospace"; @@ -6162,7 +6106,7 @@ namespace NLGUI // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight uint weight = 400; if (it->second == "inherit") - weight = getFontWeight(); + weight = current.FontWeight; else if (it->second == "normal") weight = 400; @@ -6173,7 +6117,7 @@ namespace NLGUI if (it->second == "lighter") { const uint lighter[] = {100, 100, 100, 100, 100, 400, 400, 700, 700}; - uint index = getFontWeight() / 100 - 1; + uint index = current.FontWeight / 100 - 1; clamp(index, 1u, 9u); weight = lighter[index-1]; } @@ -6181,7 +6125,7 @@ namespace NLGUI if (it->second == "bolder") { const uint bolder[] = {400, 400, 400, 700, 700, 900, 900, 900, 900}; - uint index = getFontWeight() / 100 + 1; + uint index = current.FontWeight / 100 + 1; clamp(index, 1u, 9u); weight = bolder[index-1]; } @@ -6197,7 +6141,7 @@ namespace NLGUI else if (it->first == "color") if (it->second == "inherit") - style.TextColor = getTextColor(); + style.TextColor = current.TextColor; else scanHTMLColor(it->second.c_str(), style.TextColor); else @@ -6224,7 +6168,7 @@ namespace NLGUI { bool b; if (it->second == "inherit") - style.GlobalColor = getGlobalColor(); + style.GlobalColor = current.GlobalColor; else if (fromString(it->second, b)) style.GlobalColor = b; @@ -6232,8 +6176,8 @@ namespace NLGUI } if (inherit) { - style.Underlined = getFontUnderlined() || style.Underlined; - style.StrikeThrough = getFontStrikeThrough() || style.StrikeThrough; + style.Underlined = current.Underlined || style.Underlined; + style.StrikeThrough = current.StrikeThrough || style.StrikeThrough; } } From 1525b03a83321bd207c8171757208d25d1c3ff95 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sat, 11 Aug 2018 09:59:01 +0300 Subject: [PATCH 2/4] Changed: Extend style attribute to other tags --HG-- branch : develop --- code/nel/include/nel/gui/libwww.h | 1 + code/nel/src/gui/group_html.cpp | 145 +++++++++++++++++++++++------- code/nel/src/gui/libwww.cpp | 1 + 3 files changed, 113 insertions(+), 34 deletions(-) diff --git a/code/nel/include/nel/gui/libwww.h b/code/nel/include/nel/gui/libwww.h index 0825779f2..892e07eb2 100644 --- a/code/nel/include/nel/gui/libwww.h +++ b/code/nel/include/nel/gui/libwww.h @@ -102,6 +102,7 @@ namespace NLGUI HTML_ATTR(TR,L_MARGIN), HTML_ATTR(TR,NOWRAP), HTML_ATTR(TR,VALIGN), + HTML_ATTR(TR,STYLE), }; enum diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 46a32fb13..970178947 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1530,6 +1530,7 @@ namespace NLGUI { _BlockLevelElement.push_back(true); registerAnchorName(MY_HTML_DIV); + pushStyle(); if (present[MY_HTML_DIV_NAME] && value[MY_HTML_DIV_NAME]) _DivName = value[MY_HTML_DIV_NAME]; @@ -1538,6 +1539,13 @@ namespace NLGUI if (present[MY_HTML_DIV_CLASS] && value[MY_HTML_DIV_CLASS]) instClass = value[MY_HTML_DIV_CLASS]; + string style; + if (present[MY_HTML_DIV_STYLE] && value[MY_HTML_DIV_STYLE]) + style = value[MY_HTML_DIV_STYLE]; + + if (!style.empty()) + getStyleParams(style, _Style); + // use generic template system if (_TrustedDomain && !instClass.empty() && instClass == "ryzom-ui-grouptemplate") { @@ -1545,10 +1553,6 @@ namespace NLGUI if (present[MY_HTML_DIV_ID] && value[MY_HTML_DIV_ID]) id = value[MY_HTML_DIV_ID]; - string style; - if (present[MY_HTML_DIV_STYLE] && value[MY_HTML_DIV_STYLE]) - style = value[MY_HTML_DIV_STYLE]; - typedef pair TTmplParam; vector tmplParams; @@ -1679,6 +1683,10 @@ namespace NLGUI image = image.substr(4, image.size()-5); setBackground (image, scale, repeat); } + + // set default text style from + getStyleParams(style, _StyleDefault); + _Style = _StyleDefault; } } break; @@ -1707,6 +1715,8 @@ namespace NLGUI _Style.FontSize = H1FontSize; _Style.TextColor = H1Color; _Style.GlobalColor = H1ColorGlobalColor; + if (present[MY_HTML_H1_STYLE] && value[MY_HTML_H1_STYLE]) + getStyleParams(value[MY_HTML_H1_STYLE], _Style); } break; case HTML_H2: @@ -1717,6 +1727,8 @@ namespace NLGUI _Style.FontSize = H2FontSize; _Style.TextColor = H2Color; _Style.GlobalColor = H2ColorGlobalColor; + if (present[MY_HTML_H2_STYLE] && value[MY_HTML_H2_STYLE]) + getStyleParams(value[MY_HTML_H2_STYLE], _Style); } break; case HTML_H3: @@ -1727,6 +1739,8 @@ namespace NLGUI _Style.FontSize = H3FontSize; _Style.TextColor = H3Color; _Style.GlobalColor = H3ColorGlobalColor; + if (present[MY_HTML_H3_STYLE] && value[MY_HTML_H3_STYLE]) + getStyleParams(value[MY_HTML_H3_STYLE], _Style); } break; case HTML_H4: @@ -1737,6 +1751,8 @@ namespace NLGUI _Style.FontSize = H4FontSize; _Style.TextColor = H4Color; _Style.GlobalColor = H4ColorGlobalColor; + if (present[MY_HTML_H4_STYLE] && value[MY_HTML_H4_STYLE]) + getStyleParams(value[MY_HTML_H4_STYLE], _Style); } break; case HTML_H5: @@ -1747,6 +1763,8 @@ namespace NLGUI _Style.FontSize = H5FontSize; _Style.TextColor = H5Color; _Style.GlobalColor = H5ColorGlobalColor; + if (present[MY_HTML_H5_STYLE] && value[MY_HTML_H5_STYLE]) + getStyleParams(value[MY_HTML_H5_STYLE], _Style); } break; case HTML_H6: @@ -1757,6 +1775,8 @@ namespace NLGUI _Style.FontSize = H6FontSize; _Style.TextColor = H6Color; _Style.GlobalColor = H6ColorGlobalColor; + if (present[MY_HTML_H6_STYLE] && value[MY_HTML_H6_STYLE]) + getStyleParams(value[MY_HTML_H6_STYLE], _Style); } break; case HTML_IMG: @@ -2177,6 +2197,10 @@ namespace NLGUI if (present[HTML_LI_VALUE] && value[HTML_LI_VALUE]) fromString(value[HTML_LI_VALUE], _UL.back().Value); + pushStyle(); + if (present[HTML_LI_STYLE] && value[HTML_LI_STYLE]) + getStyleParams(value[HTML_LI_STYLE], _Style); + ucstring str; str.fromUtf8(_UL.back().getListMarkerText()); addString (str); @@ -2194,7 +2218,12 @@ namespace NLGUI } break; case HTML_P: - newParagraph(PBeginSpace); + { + newParagraph(PBeginSpace); + pushStyle(); + if (present[HTML_BLOCK_STYLE] && value[HTML_BLOCK_STYLE]) + getStyleParams(value[HTML_BLOCK_STYLE], _Style); + } break; case HTML_PRE: { @@ -2210,6 +2239,7 @@ namespace NLGUI break; case HTML_TABLE: { + pushStyle(); registerAnchorName(MY_HTML_TABLE); // Get cells parameters @@ -2228,6 +2258,8 @@ namespace NLGUI fromString(value[MY_HTML_TABLE_CELLSPACING], table->CellSpacing); if (present[MY_HTML_TABLE_CELLPADDING] && value[MY_HTML_TABLE_CELLPADDING]) fromString(value[MY_HTML_TABLE_CELLPADDING], table->CellPadding); + if (present[MY_HTML_TABLE_STYLE] && value[MY_HTML_TABLE_STYLE]) + getStyleParams(value[MY_HTML_TABLE_STYLE], _Style); table->setMarginLeft(getIndent()); addHtmlGroup (table, 0); @@ -2247,15 +2279,18 @@ namespace NLGUI // Get cells parameters getCellsParameters (MY_HTML_TD, true); + pushStyle(); if (element_number == HTML_TH) { - pushStyle(); _Style.FontWeight = FONT_WEIGHT_BOLD; // center if not specified otherwise. TD/TH present/value arrays have same indices if (!(present[MY_HTML_TD_ALIGN] && value[MY_HTML_TD_ALIGN])) _CellParams.back().Align = CGroupCell::Center; } + if (present[MY_HTML_TD_STYLE] && value[MY_HTML_TD_STYLE]) + getStyleParams(value[MY_HTML_TD_STYLE], _Style); + CGroupTable *table = getTable(); if (table) { @@ -2335,21 +2370,21 @@ namespace NLGUI } break; case HTML_TEXTAREA: + pushStyle(); _PRE.push_back(true); + // not inherited by default, font family defaults to system font + _Style.TextColor = TextColor; + _Style.FontWeight = FONT_WEIGHT_NORMAL; + _Style.FontOblique = false; + _Style.FontSize = TextFontSize; + + if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE]) + getStyleParams(value[MY_HTML_TEXTAREA_STYLE], _Style); + // Got one form ? if (!(_Forms.empty())) { - // not inherited by default, font family defaults to system font - pushStyle(); - _Style.TextColor = TextColor; - _Style.FontWeight = FONT_WEIGHT_NORMAL; - _Style.FontOblique = false; - _Style.FontSize = TextFontSize; - - if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE]) - getStyleParams(value[MY_HTML_TEXTAREA_STYLE], _Style); - // read general property string templateName; @@ -2398,6 +2433,10 @@ namespace NLGUI // Set TR flag if (!_TR.empty()) _TR.back() = true; + + pushStyle(); + if (present[MY_HTML_TR_STYLE] && value[MY_HTML_TR_STYLE]) + getStyleParams(value[MY_HTML_TR_STYLE], _Style); } break; case HTML_UL: @@ -2411,6 +2450,10 @@ namespace NLGUI _LI = _UL.size() > 1 || _DL.size() > 1; _Indent.push_back(getIndent() + ULIndent); endParagraph(); + + pushStyle(); + if (present[HTML_UL_STYLE] && value[HTML_UL_STYLE]) + getStyleParams(value[HTML_UL_STYLE], _Style); break; case HTML_OBJECT: _ObjectType.clear(); @@ -2471,27 +2514,36 @@ namespace NLGUI _IgnoreText = true; break; case HTML_DL: - _DL.push_back(HTMLDListElement()); - _LI = _DL.size() > 1 || !_UL.empty(); - endParagraph(); + { + _DL.push_back(HTMLDListElement()); + _LI = _DL.size() > 1 || !_UL.empty(); + endParagraph(); + pushStyle(); + if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE]) + getStyleParams(value[HTML_GEN_STYLE], _Style); + } break; case HTML_DT: if (!_DL.empty()) { - // close DT if still open + // close if still open if (_DL.back().DD) { _DL.back().DD = false; popIfNotEmpty(_Indent); + popStyle(); } - // see if this is the first
, closing tag not required - if (!_DL.back().DT) - { - _DL.back().DT = true; - pushStyle(); - _Style.FontWeight = FONT_WEIGHT_BOLD; - } + // close if still open + if (_DL.back().DT) + popStyle(); + + _DL.back().DT = true; + + pushStyle(); + _Style.FontWeight = FONT_WEIGHT_BOLD; + if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE]) + getStyleParams(value[HTML_GEN_STYLE], _Style); if (!_LI) { @@ -2514,12 +2566,20 @@ namespace NLGUI popStyle(); } - if (!_DL.back().DD) + if (_DL.back().DD) { - _DL.back().DD = true; - _Indent.push_back(getIndent() + ULIndent); + _DL.back().DD = false; + popStyle(); + popIfNotEmpty(_Indent); } + _DL.back().DD = true; + _Indent.push_back(getIndent() + ULIndent); + + pushStyle(); + if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE]) + getStyleParams(value[HTML_GEN_STYLE], _Style); + if (!_LI) { _LI = true; @@ -2533,6 +2593,7 @@ namespace NLGUI break; case HTML_OL: { + pushStyle(); sint32 start = 1; std::string type("1"); @@ -2540,6 +2601,8 @@ namespace NLGUI fromString(value[HTML_OL_START], start); if (present[HTML_OL_TYPE] && value[HTML_OL_TYPE]) type = value[HTML_OL_TYPE]; + if (present[HTML_OL_STYLE] && value[HTML_OL_STYLE]) + getStyleParams(value[HTML_OL_STYLE], _Style); _UL.push_back(HTMLOListElement(start, type)); // if LI is already present @@ -2621,6 +2684,7 @@ namespace NLGUI endParagraph(); break; case HTML_P: + popStyle(); endParagraph(); break; case HTML_PRE: @@ -2628,6 +2692,7 @@ namespace NLGUI popIfNotEmpty (_PRE); break; case HTML_DIV: + popStyle(); if (isBlockLevelElement()) { endParagraph(); @@ -2638,6 +2703,7 @@ namespace NLGUI break; case HTML_TABLE: + popStyle(); popIfNotEmpty (_CellParams); popIfNotEmpty (_TR); popIfNotEmpty (_Cells); @@ -2647,14 +2713,15 @@ namespace NLGUI // Add a cell break; case HTML_TH: - popStyle(); // no break; case HTML_TD: + popStyle(); popIfNotEmpty (_CellParams); if (!_Cells.empty()) _Cells.back() = NULL; break; case HTML_TR: + popStyle(); popIfNotEmpty (_CellParams); break; case HTML_TEXTAREA: @@ -2671,10 +2738,9 @@ namespace NLGUI entry.TextArea = textArea; _Forms.back().Entries.push_back (entry); } - - popStyle(); } + popStyle(); popIfNotEmpty (_PRE); } break; @@ -2782,10 +2848,16 @@ namespace NLGUI if (!_UL.empty()) { endParagraph(); + popStyle(); popIfNotEmpty(_UL); popIfNotEmpty(_Indent); } break; + case HTML_LI: + { + popStyle(); + } + break; case HTML_DL: if (!_DL.empty()) { @@ -2801,16 +2873,19 @@ namespace NLGUI if (_DL.back().DD) { popIfNotEmpty(_Indent); + popStyle(); } popIfNotEmpty (_DL); + popStyle(); } break; case HTML_DT: if (!_DL.empty()) { + if (_DL.back().DT) + popStyle(); _DL.back().DT = false; - popStyle(); } break; case HTML_DD: @@ -2821,6 +2896,7 @@ namespace NLGUI { _DL.back().DD = false; popIfNotEmpty(_Indent); + popStyle(); } } break; @@ -4477,6 +4553,7 @@ namespace NLGUI templateParams.push_back (std::pair ("enter_recover_focus", "false")); if (maxlength > 0) templateParams.push_back (std::pair ("max_num_chars", toString(maxlength))); + CInterfaceGroup *textArea = CWidgetManager::getInstance()->getParser()->createGroupInstance (templateName.c_str(), getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size()); diff --git a/code/nel/src/gui/libwww.cpp b/code/nel/src/gui/libwww.cpp index c8b41a38f..fef3d788e 100644 --- a/code/nel/src/gui/libwww.cpp +++ b/code/nel/src/gui/libwww.cpp @@ -101,6 +101,7 @@ namespace NLGUI HTML_ATTR(TR,L_MARGIN), HTML_ATTR(TR,NOWRAP), HTML_ATTR(TR,VALIGN), + HTML_ATTR(TR,STYLE), { 0 } }; From 33f6b64bb999969eb15390ea6d9d1ffd44b89201 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 10 Aug 2018 14:09:34 +0300 Subject: [PATCH 3/4] Changed: Add text-shadow and text-stroke style properties --HG-- branch : develop --- code/nel/include/nel/3d/text_context.h | 110 +++++++------- code/nel/include/nel/3d/text_context_user.h | 2 +- code/nel/include/nel/3d/u_text_context.h | 2 +- code/nel/include/nel/gui/group_html.h | 28 +++- code/nel/include/nel/gui/view_text.h | 4 + code/nel/src/3d/text_context.cpp | 3 +- code/nel/src/3d/text_context_user.cpp | 4 +- code/nel/src/gui/group_html.cpp | 159 +++++++++++++++++++- code/nel/src/gui/view_text.cpp | 24 +++ 9 files changed, 276 insertions(+), 60 deletions(-) diff --git a/code/nel/include/nel/3d/text_context.h b/code/nel/include/nel/3d/text_context.h index 156ea9f79..a95916da4 100644 --- a/code/nel/include/nel/3d/text_context.h +++ b/code/nel/include/nel/3d/text_context.h @@ -88,7 +88,7 @@ public: void setShadeOutline (bool b) { _ShadeOutline = b; } - void setShadeExtent (float shext) { _ShadeExtent = shext; } + void setShadeExtent (float x, float y) { _ShadeExtentX = x; _ShadeExtentY = y; } /// The alpha of the shade is multiplied at each draw with the alpha of the color. Default: (0,0,0,255) void setShadeColor (NLMISC::CRGBA color) { _ShadeColor = color; } @@ -157,19 +157,20 @@ public: rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - rCS.render2D(*_Driver, x+rext, z-rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x-rext, z-rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x-rext, z+rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x+rext, z+rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x+_ShadeExtent, z, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x-_ShadeExtent, z, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + rCS.render2D(*_Driver, x+rextX, z-rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x-rextX, z-rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x-rextX, z+rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x+rextX, z+rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x+_ShadeExtentX, z, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x-_ShadeExtentX, z, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } else { - rCS.render2D(*_Driver, x+_ShadeExtent, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } rCS.Color= bkup; } @@ -190,19 +191,20 @@ public: rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - rCS.render2DClip(*_Driver, rdrBuffer, x+rext, z-rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x-rext, z-rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x-rext, z+rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x+rext, z+rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtent, z, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x-_ShadeExtent, z, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x, z+_ShadeExtent, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x, z-_ShadeExtent, xmin, ymin, xmax, ymax); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + rCS.render2DClip(*_Driver, rdrBuffer, x+rextX, z-rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x-rextX, z-rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x-rextX, z+rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x+rextX, z+rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtentX, z, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x-_ShadeExtentX, z, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x, z+_ShadeExtentY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x, z-_ShadeExtentY, xmin, ymin, xmax, ymax); } else { - rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtent, z-_ShadeExtent, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtentX, z-_ShadeExtentY, xmin, ymin, xmax, ymax); } rCS.Color= bkup; } @@ -223,19 +225,20 @@ public: rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rext, y-rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rext, y-rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rext, y+rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rext, y+rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtent, y, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-_ShadeExtent, y, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y+_ShadeExtent, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y-_ShadeExtent, depth, xmin, ymin, xmax, ymax); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rextX, y-rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rextX, y-rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rextX, y+rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rextX, y+rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtentX, y, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-_ShadeExtentX, y, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y+_ShadeExtentY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y-_ShadeExtentY, depth, xmin, ymin, xmax, ymax); } else { - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtent, y-_ShadeExtent, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtentX, y-_ShadeExtentY, depth, xmin, ymin, xmax, ymax); } rCS.Color= bkup; } @@ -258,19 +261,20 @@ public: _TempString.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - _TempString.render2D(*_Driver,x+rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z+_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + _TempString.render2D(*_Driver,x+rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z+_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z-_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); } else { - _TempString.render2D(*_Driver,x+_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } _TempString.Color = bkup; } @@ -297,19 +301,20 @@ public: _TempString.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - _TempString.render2D(*_Driver,x+rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z+_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + _TempString.render2D(*_Driver,x+rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z+_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z-_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); } else { - _TempString.render2D(*_Driver,x+_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } _TempString.Color = bkup; } @@ -412,7 +417,8 @@ private: bool _ShadeOutline; /// shade's extent (shadow size) - float _ShadeExtent; + float _ShadeExtentX; + float _ShadeExtentY; /// Shade color (default is black) NLMISC::CRGBA _ShadeColor; diff --git a/code/nel/include/nel/3d/text_context_user.h b/code/nel/include/nel/3d/text_context_user.h index b05238dbf..15e93c3f2 100644 --- a/code/nel/include/nel/3d/text_context_user.h +++ b/code/nel/include/nel/3d/text_context_user.h @@ -80,7 +80,7 @@ public: bool getShaded() const; void setShadeOutline(bool b); bool getShadeOutline() const; - void setShadeExtent(float shext) ; + void setShadeExtent(float x, float y); void setShadeColor (NLMISC::CRGBA sc); NLMISC::CRGBA getShadeColor () const; void setKeep800x600Ratio(bool keep); diff --git a/code/nel/include/nel/3d/u_text_context.h b/code/nel/include/nel/3d/u_text_context.h index 0aa9ea2f9..4c1dfea47 100644 --- a/code/nel/include/nel/3d/u_text_context.h +++ b/code/nel/include/nel/3d/u_text_context.h @@ -205,7 +205,7 @@ public: * set the shadow's size * \param the shade extent */ - virtual void setShadeExtent (float shext) = 0; + virtual void setShadeExtent (float x, float y) = 0; /** * set the shadow's color * The alpha of the shade is multiplied at each draw with the alpha of the color. Default: (0,0,0,255) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 0ccd227b7..811cd3503 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -75,11 +75,26 @@ namespace NLGUI }; static SWebOptions options; - + + // text-shadow + struct STextShadow + { + public: + STextShadow(bool enabled = false, bool outline = false, sint32 x=1, sint32 y=1, NLMISC::CRGBA color=NLMISC::CRGBA::Black) + : Enabled(enabled), Outline(outline), X(x), Y(y), Color(color) + { } + + bool Enabled; + bool Outline; + sint32 X; + sint32 Y; + NLMISC::CRGBA Color; + }; + class CStyleParams { public: - CStyleParams () : FontFamily(""), TextColor(255,255,255,255) + CStyleParams () : FontFamily(""), TextColor(255,255,255,255), TextShadow() { FontSize=10; FontWeight=400; @@ -97,6 +112,7 @@ namespace NLGUI bool FontOblique; std::string FontFamily; NLMISC::CRGBA TextColor; + STextShadow TextShadow; bool GlobalColor; bool Underlined; bool StrikeThrough; @@ -595,6 +611,14 @@ namespace NLGUI return _TR.back(); } + std::vector _TextShadow; + inline STextShadow getTextShadow() const + { + if (_TextShadow.empty()) + return STextShadow(); + return _TextShadow.back(); + } + // Forms class CForm { diff --git a/code/nel/include/nel/gui/view_text.h b/code/nel/include/nel/gui/view_text.h index 8b8e1a7cf..cf53b5207 100644 --- a/code/nel/include/nel/gui/view_text.h +++ b/code/nel/include/nel/gui/view_text.h @@ -88,6 +88,7 @@ namespace NLGUI void setShadow (bool bShadow); void setShadowOutline (bool bShadowOutline); void setShadowColor (const NLMISC::CRGBA &color); + void setShadowOffset (sint x, sint y); void setLineMaxW (sint nMaxW, bool invalidate=true); void setMultiLine (bool bMultiLine); void setMultiLineSpace (sint nMultiLineSpace); @@ -112,6 +113,7 @@ namespace NLGUI bool getShadow() { return _Shadow; } bool getShadowOutline() { return _ShadowOutline; } NLMISC::CRGBA getShadowColor() { return _ShadowColor; } + void getShadowOffset(sint &x, sint &y) { x = _ShadowX; y = _ShadowY; } sint getLineMaxW() const { return _LineMaxW; } bool getMultiLine() const { return _MultiLine; } sint getMultiLineSpace() const { return _MultiLineSpace; } @@ -247,6 +249,8 @@ namespace NLGUI /// the shadow mode bool _Shadow; bool _ShadowOutline; + sint32 _ShadowX; + sint32 _ShadowY; /// the case mode TCaseMode _CaseMode; /// the text shadow color diff --git a/code/nel/src/3d/text_context.cpp b/code/nel/src/3d/text_context.cpp index 8cee144ca..5fcc43daa 100644 --- a/code/nel/src/3d/text_context.cpp +++ b/code/nel/src/3d/text_context.cpp @@ -47,7 +47,8 @@ CTextContext::CTextContext() _Shaded = false; _ShadeOutline = false; - _ShadeExtent = 0.001f; + _ShadeExtentX = 0.001f; + _ShadeExtentY = 0.001f; _ShadeColor = NLMISC::CRGBA(0,0,0); _Keep800x600Ratio= true; diff --git a/code/nel/src/3d/text_context_user.cpp b/code/nel/src/3d/text_context_user.cpp index 1834a93ce..ae2cc2417 100644 --- a/code/nel/src/3d/text_context_user.cpp +++ b/code/nel/src/3d/text_context_user.cpp @@ -187,11 +187,11 @@ bool CTextContextUser::getShadeOutline() const return _TextContext.getShadeOutline(); } -void CTextContextUser::setShadeExtent(float shext) +void CTextContextUser::setShadeExtent(float x, float y) { H_AUTO2; - _TextContext.setShadeExtent(shext); + _TextContext.setShadeExtent(x, y); } void CTextContextUser::setShadeColor (NLMISC::CRGBA sc) { diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 970178947..e8a2ac889 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1057,6 +1057,29 @@ namespace NLGUI _CellParams.push_back (cellParams); \ } + static bool scanCssLength(const std::string& str, uint32 &px) + { + if (fromString(str, px)) + return true; + + if (str == "thin") + { + px = 1; + return true; + } + if (str == "medium") + { + px = 3; + return true; + } + if (str == "thick") + { + px = 5; + return true; + } + + return false; + } static bool isHexa(char c) { @@ -2378,6 +2401,7 @@ namespace NLGUI _Style.FontWeight = FONT_WEIGHT_NORMAL; _Style.FontOblique = false; _Style.FontSize = TextFontSize; + _Style.TextShadow = STextShadow(true); if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE]) getStyleParams(value[MY_HTML_TEXTAREA_STYLE], _Style); @@ -4351,8 +4375,17 @@ namespace NLGUI if (_CurrentViewLink) { bool skipLine = !_CurrentViewLink->getText().empty() && *(_CurrentViewLink->getText().rbegin()) == (ucchar) '\n'; + bool sameShadow = _Style.TextShadow.Enabled && _CurrentViewLink->getShadow(); + if (sameShadow && _Style.TextShadow.Enabled) + { + sint sx, sy; + _CurrentViewLink->getShadowOffset(sx, sy); + sameShadow = (_Style.TextShadow.Color == _CurrentViewLink->getShadowColor()); + sameShadow = sameShadow && (_Style.TextShadow.Outline == _CurrentViewLink->getShadowOutline()); + sameShadow = sameShadow && (_Style.TextShadow.X == sx) && (_Style.TextShadow.Y == sy); + } // Compatible with current parameters ? - if (!skipLine && + if (!skipLine && sameShadow && (_Style.TextColor == _CurrentViewLink->getColor()) && (_Style.FontFamily == _CurrentViewLink->getFontName()) && (_Style.FontSize == (uint)_CurrentViewLink->getFontSize()) && @@ -4431,6 +4464,13 @@ namespace NLGUI newLink->setMultiLineSpace((uint)((float)(_Style.FontSize)*LineSpaceFontFactor)); newLink->setMultiLine(true); newLink->setModulateGlobalColor(_Style.GlobalColor); + if (_Style.TextShadow.Enabled) + { + newLink->setShadow(true); + newLink->setShadowColor(_Style.TextShadow.Color); + newLink->setShadowOutline(_Style.TextShadow.Outline); + newLink->setShadowOffset(_Style.TextShadow.X, _Style.TextShadow.Y); + } // newLink->setLineAtBottom (true); registerAnchor(newLink); @@ -4553,6 +4593,14 @@ namespace NLGUI templateParams.push_back (std::pair ("enter_recover_focus", "false")); if (maxlength > 0) templateParams.push_back (std::pair ("max_num_chars", toString(maxlength))); + templateParams.push_back (std::pair ("shadow", toString(_Style.TextShadow.Enabled))); + if (_Style.TextShadow.Enabled) + { + templateParams.push_back (std::pair ("shadow_x", toString(_Style.TextShadow.X))); + templateParams.push_back (std::pair ("shadow_y", toString(_Style.TextShadow.Y))); + templateParams.push_back (std::pair ("shadow_color", _Style.TextShadow.Color.toString())); + templateParams.push_back (std::pair ("shadow_outline", toString(_Style.TextShadow.Outline))); + } CInterfaceGroup *textArea = CWidgetManager::getInstance()->getParser()->createGroupInstance (templateName.c_str(), getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size()); @@ -6229,6 +6277,115 @@ namespace NLGUI style.StrikeThrough = (prop.find("line-through") != std::string::npos); } else + if (it->first == "text-stroke" || it->first == "-webkit-text-stroke") + { + // text-stroke: length || color + bool success = false; + uint px = 0; + CRGBA color; + std::vector parts; + NLMISC::splitString(it->second, " ", parts); + if (parts.size() == 1) + { + success = scanCssLength(parts[0], px); + if (!success) + success = scanHTMLColor(parts[0].c_str(), color); + } + else if (parts.size() == 2) + { + success = scanCssLength(parts[0], px); + if (success) + success = scanHTMLColor(parts[1].c_str(), color); + else + { + success = scanHTMLColor(parts[0].c_str(), color); + success = success && scanCssLength(parts[1], px); + } + } + + // do not disable shadow if one is already set + if (success) + { + style.TextShadow.Enabled = (px > 0); + style.TextShadow.Color = color; + style.TextShadow.X = px; + style.TextShadow.Y = px; + style.TextShadow.Outline = true; + } + } + else + if (it->first == "text-shadow") + { + if (it->second == "none") + style.TextShadow = STextShadow(false); + else + if (it->second == "inherit") + style.TextShadow = current.TextShadow; + else + { + // text-shadow: offset-x offset-y | blur | #color + // text-shadow: #color | offset-x offset-y + bool success = true; + std::string prop(it->second); + size_t pos; + pos = prop.find_first_of(",\n\r"); + if (pos != std::string::npos) + prop = prop.substr(0, pos); + + std::vector parts; + NLMISC::splitString(prop, " ", parts); + switch(parts.size()) + { + case 1: + { + success = scanHTMLColor(it->second.c_str(), style.TextShadow.Color); + break; + } + // no case 2: + case 3: + { + if (!fromString(parts[0], style.TextShadow.X)) + { + success = scanHTMLColor(parts[0].c_str(), style.TextShadow.Color); + success = success && fromString(parts[1], style.TextShadow.X); + success = success && fromString(parts[2], style.TextShadow.Y); + } + else + { + success = fromString(parts[1], style.TextShadow.Y); + success = success && scanHTMLColor(parts[2].c_str(), style.TextShadow.Color); + } + break; + } + case 4: + { + if (!fromString(parts[0], style.TextShadow.X)) + { + success = scanHTMLColor(parts[0].c_str(), style.TextShadow.Color); + success = success && fromString(parts[1], style.TextShadow.X); + success = success && fromString(parts[2], style.TextShadow.Y); + // ignore blur [3] + } + else + { + success = fromString(parts[0], style.TextShadow.X); + success = success && fromString(parts[1], style.TextShadow.Y); + // ignore blur [2] + success = success && scanHTMLColor(parts[3].c_str(), style.TextShadow.Color); + } + break; + } + default: + { + // unsupported rule + break; + } + } + + style.TextShadow.Enabled = success; + } + } + else if (it->first == "width") getPercentage(style.Width, tmpf, it->second.c_str()); else diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index c14a7f9a1..bd10afbb9 100644 --- a/code/nel/src/gui/view_text.cpp +++ b/code/nel/src/gui/view_text.cpp @@ -72,6 +72,8 @@ namespace NLGUI _Shadow = false; _ShadowOutline = false; _ShadowColor = CRGBA(0,0,0,255); + _ShadowX = 1; + _ShadowY = 1; _MultiLine = false; _TextMode = DontClipWord; @@ -955,6 +957,19 @@ namespace NLGUI ((_YReal) > (ClipY+ClipH)) || ((_YReal+_HReal) < ClipY)) return; + // hack: allow shadow to overflow outside parent box. + // In CGroupHTML context, clip is set for row + if (std::abs(_ShadowX) > 0) + { + ClipX -= 3; + ClipW += 3; + } + if (std::abs(_ShadowY) > 0) + { + ClipY -= 3; + ClipH += 3; + } + // *** Screen Minimized? uint32 w, h; float oow, ooh; @@ -992,6 +1007,7 @@ namespace NLGUI TextContext->setShaded (_Shadow); TextContext->setShadeOutline (_ShadowOutline); TextContext->setShadeColor (shcol); + TextContext->setShadeExtent (_ShadowX*oow, _ShadowY*ooh); TextContext->setFontSize (_FontSize); TextContext->setEmbolden (_Embolden); TextContext->setOblique (_Oblique); @@ -1119,6 +1135,7 @@ namespace NLGUI TextContext->setShaded (_Shadow); TextContext->setShadeOutline (_ShadowOutline); TextContext->setShadeColor (shcol); + TextContext->setShadeExtent (_ShadowX*oow, _ShadowY*ooh); TextContext->setFontSize (_FontSize); TextContext->setEmbolden (_Embolden); TextContext->setOblique (_Oblique); @@ -1339,6 +1356,13 @@ namespace NLGUI _ShadowColor = color; } + // *************************************************************************** + void CViewText::setShadowOffset(sint32 x, sint32 y) + { + _ShadowX = x; + _ShadowY = y; + } + // *************************************************************************** void CViewText::setLineMaxW (sint nMaxW, bool invalidate) { From 15355e3815f3d3380da1a6d744481b8766ada8a3 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sat, 11 Aug 2018 15:33:01 +0300 Subject: [PATCH 4/4] Changed: shadow attributes for CViewText and editbox templates --HG-- branch : develop --- code/nel/src/gui/view_text.cpp | 28 +++++++++++++++ .../gamedev/interfaces_v3/login_widgets.xml | 35 ++++++++++++++++--- .../data/gamedev/interfaces_v3/widgets.xml | 22 ++++++++++-- 3 files changed, 78 insertions(+), 7 deletions(-) diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index bd10afbb9..34f8fd3e1 100644 --- a/code/nel/src/gui/view_text.cpp +++ b/code/nel/src/gui/view_text.cpp @@ -438,6 +438,22 @@ namespace NLGUI return true; } else + if( name == "shadow_x" ) + { + sint sx; + if( fromString( value, sx ) ) + _ShadowX = sx; + return true; + } + else + if( name == "shadow_y" ) + { + sint sy; + if( fromString( value, sy ) ) + _ShadowY = sy; + return true; + } + else if( name == "multi_line" ) { bool b; @@ -618,6 +634,8 @@ namespace NLGUI 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_x", BAD_CAST toString( _ShadowX ).c_str() ); + xmlSetProp( node, BAD_CAST "shadow_y", BAD_CAST toString( _ShadowY ).c_str() ); xmlSetProp( node, BAD_CAST "multi_line", BAD_CAST toString( _MultiLine ).c_str() ); std::string just; @@ -729,6 +747,16 @@ namespace NLGUI if (prop) _ShadowColor = convertColor(prop); + prop= (char*) xmlGetProp( cur, (xmlChar*)"shadow_x" ); + _ShadowX = 1; + if (prop) + fromString( (const char *)prop, _ShadowX); + + prop= (char*) xmlGetProp( cur, (xmlChar*)"shadow_y" ); + _ShadowY = 1; + if (prop) + fromString( (const char *)prop, _ShadowY); + prop = (char*) xmlGetProp( cur, (xmlChar*)"multi_line" ); _MultiLine = false; if (prop) diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/login_widgets.xml b/code/ryzom/client/data/gamedev/interfaces_v3/login_widgets.xml index 660cb4f9d..6d7ac1fa7 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/login_widgets.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/login_widgets.xml @@ -75,6 +75,11 @@ keep="true" max_historic="0" fontsize="10" + shadow="true" + shadow_x="1" + shadow_y="1" + shadow_color="0 0 0 255" + shadow_outline="false" backup_father_container_pos="false" want_return="false" color="255 255 255 255" @@ -93,7 +98,7 @@ - + @@ -114,6 +119,11 @@ fontsize="10" fontweight="" fontstyle="" + shadow="true" + shadow_x="1" + shadow_y="1" + shadow_color="0 0 0 255" + shadow_outline="false" backup_father_container_pos="false" want_return="false" color="255 255 255 255" @@ -124,7 +134,7 @@ - + @@ -153,6 +163,11 @@ keep="true" max_historic="40" fontsize="10" + shadow="true" + shadow_x="1" + shadow_y="1" + shadow_color="0 0 0 255" + shadow_outline="false" backup_father_container_pos="false" want_return="false" color="255 255 255 255" @@ -162,7 +177,7 @@ - + @@ -397,6 +412,11 @@ keep="true" max_historic="40" fontsize="10" + shadow="true" + shadow_x="1" + shadow_y="1" + shadow_color="0 0 0 255" + shadow_outline="false" backup_father_container_pos="false" want_return="false" color="255 255 255 255" @@ -407,7 +427,7 @@ - + @@ -435,6 +455,11 @@ keep="true" max_historic="40" fontsize="10" + shadow="true" + shadow_x="1" + shadow_y="1" + shadow_color="0 0 0 255" + shadow_outline="false" backup_father_container_pos="false" want_return="false" color="255 255 255 255" @@ -444,7 +469,7 @@ - + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml b/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml index e5ece5680..62c202815 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml @@ -2653,6 +2653,11 @@ keep="true" max_historic="40" fontsize="10" + shadow="true" + shadow_x="1" + shadow_y="1" + shadow_color="0 0 0 255" + shadow_outline="false" backup_father_container_pos="false" want_return="false" clear_on_escape="false" @@ -2722,7 +2727,11 @@ multi_line_space="0" fontsize="#fontsize" color="#color" - shadow="true" + shadow="#shadow" + shadow_x="#shadow_x" + shadow_y="#shadow_y" + shadow_color="#shadow_color" + shadow_outline="#shadow_outline" hardtext="" global_color="false" /> @@ -2826,6 +2835,11 @@ keep="true" max_historic="40" fontsize="10" + shadow="true" + shadow_x="1" + shadow_y="1" + shadow_color="0 0 0 255" + shadow_outline="false" backup_father_container_pos="false" want_return="false" color="255 255 255 255" @@ -2886,7 +2900,11 @@ multi_min_line="#multi_min_line" fontsize="#fontsize" color="#color" - shadow="true" + shadow="#shadow" + shadow_x="#shadow_x" + shadow_y="#shadow_y" + shadow_color="#shadow_color" + shadow_outline="#shadow_outline" hardtext="" global_color="false" render_layer="#render_layer" />