From 737d068147056559aee62d8be988a6a95d97495f Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 3 Dec 2015 15:50:54 +0200 Subject: [PATCH] Added: style for html elements del, u, em, strong, small, and dl list --- code/nel/include/nel/gui/group_html.h | 16 ++++ code/nel/src/gui/group_html.cpp | 101 +++++++++++++++++++++++++- 2 files changed, 115 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 9e24bfda6..c6bc06b94 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -419,6 +419,15 @@ namespace NLGUI return _UL.back(); } + // DL list + std::vector _DL; + inline bool getDL() const + { + if (_DL.empty()) + return false; + return _DL.back(); + } + // A mode std::vector _A; inline bool getA() const @@ -430,6 +439,7 @@ namespace NLGUI // IL mode bool _LI; + bool _DT; // Current text color std::vector _TextColor; @@ -457,6 +467,12 @@ namespace NLGUI return TextFontSize; return _FontSize.back(); } + inline uint getFontSizeSmaller() const + { + if (getFontSize() < 5) + return 3; + return getFontSize()-2; + } std::vector _FontWeight; inline uint getFontWeight() const diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index f260a523f..7494f9540 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -53,6 +53,8 @@ using namespace NLMISC; #define DEFAULT_RYZOM_CONNECTION_TIMEOUT (30.0) // Allow up to 10 redirects, then give up #define DEFAULT_RYZOM_REDIRECT_LIMIT (10) +// +#define FONT_WEIGHT_BOLD 700 namespace NLGUI { @@ -1832,11 +1834,64 @@ namespace NLGUI _FontStrikeThrough.push_back(style.StrikeThrough); } break; - + case HTML_DEL: + _FontStrikeThrough.push_back(true); + break; + case HTML_U: + _FontUnderlined.push_back(true); + break; + case HTML_EM: + _FontOblique.push_back(true); + break; + case HTML_STRONG: + _FontWeight.push_back(FONT_WEIGHT_BOLD); + break; + case HTML_SMALL: + _FontSize.push_back(getFontSizeSmaller()); + break; case HTML_STYLE: case HTML_SCRIPT: _IgnoreText = true; break; + case HTML_DL: + _DL.push_back(true); + endParagraph(); + break; + case HTML_DT: + if (getDL()) + { + newParagraph(0); + + // see if this is the first
, closing tag not required + if (!_DT) + { + _DT = true; + _FontWeight.push_back(FONT_WEIGHT_BOLD); + } + + if (_DL.size() > 1) + { + uint indent = (_DL.size()-1) * ULIndent; + getParagraph()->setFirstViewIndent(indent); + } + } + break; + case HTML_DD: + if (getDL()) + { + newParagraph(0); + + // if there was no closing tag for
, then remove
style + if (_DT) + { + _DT = false; + popIfNotEmpty (_FontWeight); + } + + uint indent = _DL.size()*ULIndent; + getParagraph()->setFirstViewIndent(indent); + } + break; } } } @@ -1966,6 +2021,30 @@ namespace NLGUI popIfNotEmpty (_UL); } break; + case HTML_DL: + if (getDL()) + { + endParagraph(); + popIfNotEmpty (_DL); + if (_DT) { + _DT = false; + popIfNotEmpty (_FontWeight); + } + } + break; + case HTML_DT: + if (getDL()) + { + if (_DT) + { + _DT = false; + popIfNotEmpty (_FontWeight); + } + } + break; + case HTML_DD: + // style not changed + break; case HTML_SPAN: popIfNotEmpty (_FontSize); popIfNotEmpty (_FontWeight); @@ -1974,6 +2053,21 @@ namespace NLGUI popIfNotEmpty (_FontUnderlined); popIfNotEmpty (_FontStrikeThrough); break; + case HTML_DEL: + popIfNotEmpty (_FontStrikeThrough); + break; + case HTML_U: + popIfNotEmpty (_FontUnderlined); + break; + case HTML_EM: + popIfNotEmpty (_FontOblique); + break; + case HTML_STRONG: + popIfNotEmpty (_FontWeight); + break; + case HTML_SMALL: + popIfNotEmpty (_FontSize); + break; case HTML_STYLE: case HTML_SCRIPT: _IgnoreText = false; @@ -2060,6 +2154,7 @@ namespace NLGUI _CurrentViewImage = NULL; _Indent = 0; _LI = false; + _DT = false; _SelectOption = false; _GroupListAdaptor = NULL; _UrlFragment.clear(); @@ -3373,7 +3468,7 @@ namespace NLGUI // Text added ? bool added = false; - bool embolden = getFontWeight() >= 700; + bool embolden = getFontWeight() >= FONT_WEIGHT_BOLD; // Number of child in this paragraph if (_CurrentViewLink) @@ -3734,7 +3829,9 @@ namespace NLGUI _FontStrikeThrough.clear(); _Indent = 0; _LI = false; + _DT = false; _UL.clear(); + _DL.clear(); _A.clear(); _Link.clear(); _LinkTitle.clear();