From 7af6be711880fcb32eca070aa081521d8932cfe9 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 18 Dec 2015 14:29:40 +0200 Subject: [PATCH 1/4] Added: html OL list --- code/nel/include/nel/gui/group_html.h | 15 +++ code/nel/src/gui/group_html.cpp | 128 ++++++++++++++++++++++++++ 2 files changed, 143 insertions(+) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index db3c9130b..ae21ad9c6 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -456,6 +456,21 @@ namespace NLGUI return _DL.back(); } + // OL + class HTMLOListElement { + public: + HTMLOListElement(int start, std::string type) + : Value(start),Type(type), First(true) + { } + + std::string getListMarkerText() const; + public: + sint32 Value; + std::string Type; + bool First; + }; + std::vector _OL; + // A mode std::vector _A; inline bool getA() const diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index dbe947839..4c851285b 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1721,6 +1721,29 @@ namespace NLGUI flushString (); getParagraph()->setFirstViewIndent(LIIndent); } + else if (!_OL.empty()) + { + if (_OL.back().First) + { + _OL.back().First = false; + newParagraph(ULBeginSpace); + } + else + { + newParagraph(LIBeginSpace); + } + + // OL list index can be overridden by
  • attribute + if (present[HTML_LI_VALUE] && value[HTML_LI_VALUE]) + fromString(value[HTML_LI_VALUE], _OL.back().Value); + + ucstring str; + str.fromUtf8(_OL.back().getListMarkerText() + ". "); + addString(str); + flushString(); + getParagraph()->setFirstViewIndent(LIIndent); + _OL.back().Value++; + } break; case HTML_P: newParagraph(PBeginSpace); @@ -1994,6 +2017,21 @@ namespace NLGUI getParagraph()->setFirstViewIndent(indent); } break; + case HTML_OL: + { + sint32 start = 1; + std::string type("1"); + + if (present[HTML_OL_START] && value[HTML_OL_START]) + fromString(value[HTML_OL_START], start); + if (present[HTML_OL_TYPE] && value[HTML_OL_TYPE]) + type = value[HTML_OL_TYPE]; + + _OL.push_back(HTMLOListElement(start, type)); + _Indent += ULIndent; + endParagraph(); + } + break; } } } @@ -2114,6 +2152,15 @@ namespace NLGUI _Localize = false; } break; + case HTML_OL: + if (!_OL.empty()) + { + _Indent -= ULIndent; + _Indent = std::max(_Indent, (uint)0); + endParagraph(); + popIfNotEmpty(_OL); + } + break; case HTML_UL: if (getUL()) { @@ -3938,6 +3985,7 @@ namespace NLGUI _DT = false; _UL.clear(); _DL.clear(); + _OL.clear(); _A.clear(); _Link.clear(); _LinkTitle.clear(); @@ -5414,5 +5462,85 @@ namespace NLGUI return 0; } + // *************************************************************************** + std::string CGroupHTML::HTMLOListElement::getListMarkerText() const + { + std::string ret; + sint32 number = Value; + bool upper = false; + + if (Type == "a" || Type == "A") + { + // @see toAlphabeticOrNumeric in WebKit + static const char lower[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; + static const char upper[26] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; + uint size = 26; + if (number < 1) + { + ret = toString(number); + } + else + { + const char* digits = (Type == "A" ? upper : lower); + while(number > 0) + { + --number; + ret.insert(ret.begin(), digits[number % size]); + number /= size; + } + } + } + else if (Type == "i" || Type == "I") + { + // @see toRoman in WebKit + static const char lower[7] = {'i', 'v', 'x', 'l', 'c', 'd', 'm'}; + static const char upper[7] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'}; + + if (number < 1 || number > 3999) + { + ret = toString(number); + } + else + { + const char* digits = (Type == "I" ? upper : lower); + uint8 i, d=0; + do { + uint32 num = number % 10; + if (num % 5 < 4){ + for (i = num % 5; i > 0; i--) + { + ret.insert(ret.begin(), digits[d]); + } + } + if (num >= 4 && num <= 8) + { + ret.insert(ret.begin(), digits[d + 1]); + } + if (num == 9) + { + ret.insert(ret.begin(), digits[d + 2]); + } + if (num % 5 == 4) + { + ret.insert(ret.begin(), digits[d]); + } + number /= 10; + d += 2; + } while (number > 0); + if (Type == "I") + { + ret = toUpper(ret); + } + } + } + else + { + ret = toString(Value); + } + + return ret; + } } From 5f2ab721f7e75121b99747d9b3ad14b0ab584209 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 18 Dec 2015 14:29:40 +0200 Subject: [PATCH 2/4] Added html HR element --- code/nel/src/gui/group_html.cpp | 37 +++++++++++++++++++ .../gamedev/interfaces_v3/login_widgets.xml | 23 +++++++++++- .../data/gamedev/interfaces_v3/widgets.xml | 23 ++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 4c851285b..d464b5a0c 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -2032,6 +2032,43 @@ namespace NLGUI endParagraph(); } break; + case HTML_HR: + { + newParagraph(0); + + CInterfaceGroup *sep = CWidgetManager::getInstance()->getParser()->createGroupInstance("html_hr", "", NULL, 0); + if (sep) + { + CStyleParams style; + style.TextColor = CRGBA(120, 120, 120, 255); + style.Height = 0; + style.Width = 0; + + if (present[HTML_HR_STYLE] && value[HTML_HR_STYLE]) + getStyleParams(value[HTML_HR_STYLE], style); + + CViewBitmap *bitmap = dynamic_cast(sep->getView("hr")); + if (bitmap) + { + bitmap->setColor(style.TextColor); + if (style.Width > 0) + { + clamp(style.Width, 1, 32000); + bitmap->setW(style.Width); + bitmap->setSizeRef(CInterfaceElement::none); + } + if (style.Height > 0) + { + clamp(style.Height, 1, 1000); + bitmap->setH(style.Height); + } + } + + getParagraph()->addChild(sep); + endParagraph(); + } + } + break; } } } 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 f41fa207c..8ca822dd7 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/login_widgets.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/login_widgets.xml @@ -955,6 +955,27 @@ highlight_over="255 255 255 128" force_inside_screen="true" /> - + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml b/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml index f272c6735..2a928b858 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml @@ -6927,4 +6927,27 @@ + + + From 4e329f0e55ac59a5e48102ad97bab9506bd06041 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 18 Dec 2015 14:29:40 +0200 Subject: [PATCH 3/4] Added: html TH element --- code/nel/src/gui/group_html.cpp | 13 +++++++++++++ code/nel/src/gui/libwww.cpp | 2 ++ 2 files changed, 15 insertions(+) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index d464b5a0c..8d43dbc02 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1783,11 +1783,21 @@ namespace NLGUI _TR.push_back(false); } break; + case HTML_TH: + // TH is similar to TD, just different font style case HTML_TD: { // Get cells parameters getCellsParameters (MY_HTML_TD, true); + if (element_number == HTML_TH) + { + _FontWeight.push_back(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; + } + CGroupTable *table = getTable(); if (table) { @@ -2124,6 +2134,9 @@ namespace NLGUI endParagraph(); // Add a cell break; + case HTML_TH: + popIfNotEmpty (_FontWeight); + // no break; case HTML_TD: popIfNotEmpty (_CellParams); if (!_Cells.empty()) diff --git a/code/nel/src/gui/libwww.cpp b/code/nel/src/gui/libwww.cpp index 62c46b83e..54e28abf0 100644 --- a/code/nel/src/gui/libwww.cpp +++ b/code/nel/src/gui/libwww.cpp @@ -481,6 +481,8 @@ namespace NLGUI HTML_DTD->tags[HTML_TR].number_of_attributes = sizeof(tr_attr) / sizeof(HTAttr) - 1; HTML_DTD->tags[HTML_TD].attributes = td_attr; HTML_DTD->tags[HTML_TD].number_of_attributes = sizeof(td_attr) / sizeof(HTAttr) - 1; + HTML_DTD->tags[HTML_TH].attributes = td_attr; + HTML_DTD->tags[HTML_TH].number_of_attributes = sizeof(td_attr) / sizeof(HTAttr) - 1; HTML_DTD->tags[HTML_IMG].attributes = img_attr; HTML_DTD->tags[HTML_IMG].number_of_attributes = sizeof(img_attr) / sizeof(HTAttr) - 1; HTML_DTD->tags[HTML_INPUT].attributes = input_attr; From e510db5c3105b796b798c167378ee72220430ca8 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 18 Dec 2015 14:29:40 +0200 Subject: [PATCH 4/4] Fixed: Table colspan overwrites previous row column width --- code/nel/src/gui/group_table.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/nel/src/gui/group_table.cpp b/code/nel/src/gui/group_table.cpp index 65ed2d93d..2ce6a70fc 100644 --- a/code/nel/src/gui/group_table.cpp +++ b/code/nel/src/gui/group_table.cpp @@ -805,12 +805,13 @@ namespace NLGUI uint newsize = column + cell->ColSpan - 1; if (newsize >= _Columns.size()) _Columns.resize(newsize+1); + for(uint span = 0; span < cell->ColSpan -1; span++){ column++; - _Columns[column].Width = _Columns[column-1].Width; - _Columns[column].WidthMax = _Columns[column-1].WidthMax; - _Columns[column].TableRatio = _Columns[column-1].TableRatio; - _Columns[column].WidthWanted = _Columns[column-1].WidthWanted; + _Columns[column].Width = std::max(_Columns[column].Width, _Columns[column-1].Width); + _Columns[column].WidthMax = std::max(_Columns[column].WidthMax, _Columns[column-1].WidthMax); + _Columns[column].TableRatio = std::max(_Columns[column].TableRatio, _Columns[column-1].TableRatio); + _Columns[column].WidthWanted = std::max(_Columns[column].WidthWanted, _Columns[column-1].WidthWanted); _Columns[column].RowSpan = _Columns[column-1].RowSpan; } }