From 8be553401d112ed821549a956532863789abe497 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 13 Feb 2020 12:55:29 +0200 Subject: [PATCH] Changed: Add proper ids to groups in webig --- code/nel/include/nel/gui/group_html.h | 4 ++++ code/nel/src/gui/group_html.cpp | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 74c5a0145..d1091cec0 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -360,6 +360,10 @@ namespace NLGUI // Delete page content and prepare next page void removeContent (); + // Counter to number html elements without id attribute + uint32 getNextAutoIdSeq() { return _AutoIdSeq++; } + uint32 _AutoIdSeq; + // Current URL for relative links in page std::string _URL; // Current URL diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 160cda8ba..9bebac4e5 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1455,6 +1455,7 @@ namespace NLGUI _LastRefreshTime = 0.0; _RenderNextTime = false; _WaitingForStylesheet = false; + _AutoIdSeq = 0; // Register CWidgetManager::getInstance()->registerClockMsgTarget(this); @@ -2543,6 +2544,7 @@ namespace NLGUI { // Add a new paragraph CGroupParagraph *newParagraph = new CGroupParagraph(CViewBase::TCtorParam()); + newParagraph->setId(getCurrentGroup()->getId() + ":PARAGRAPH" + toString(getNextAutoIdSeq())); newParagraph->setResizeFromChildH(true); newParagraph->setMarginLeft(getIndent()); @@ -3285,6 +3287,7 @@ namespace NLGUI _ReadingHeadTag = false; _IgnoreHeadTag = false; _IgnoreBaseUrlTag = false; + _AutoIdSeq = 0; paragraphChange (); @@ -4361,6 +4364,7 @@ namespace NLGUI if (!_GroupListAdaptor) { _GroupListAdaptor = new CGroupListAdaptor(CViewBase::TCtorParam()); // deleted by the list + _GroupListAdaptor->setId(getList()->getId() + ":GLA"); _GroupListAdaptor->setResizeFromChildH(true); getList()->addChild (_GroupListAdaptor, true); } @@ -5677,6 +5681,8 @@ namespace NLGUI { string style = elm.getAttribute("style"); string id = elm.getAttribute("id"); + if (id.empty()) + id = "DIV" + toString(getNextAutoIdSeq()); typedef pair TTmplParam; vector tmplParams; @@ -5709,10 +5715,10 @@ namespace NLGUI parentId = _Paragraph->getId(); } - CInterfaceGroup *inst = CWidgetManager::getInstance()->getParser()->createGroupInstance(templateName, this->_Id+":"+id, tmplParams); + CInterfaceGroup *inst = CWidgetManager::getInstance()->getParser()->createGroupInstance(templateName, parentId, tmplParams); if (inst) { - inst->setId(this->_Id+":"+id); + inst->setId(parentId+":"+id); inst->updateCoords(); if (haveParentDiv) { @@ -6641,6 +6647,10 @@ namespace NLGUI CGroupTable *table = new CGroupTable(TCtorParam()); table->BgColor = _CellParams.back().BgColor; + if (elm.hasNonEmptyAttribute("id")) + table->setId(getCurrentGroup()->getId() + ":" + elm.getAttribute("id")); + else + table->setId(getCurrentGroup()->getId() + ":TABLE" + toString(getNextAutoIdSeq())); // TODO: border-spacing: 2em; { @@ -6801,6 +6811,10 @@ namespace NLGUI } _Cells.back() = new CGroupCell(CViewBase::TCtorParam()); + if (elm.hasNonEmptyAttribute("id")) + _Cells.back()->setId(getCurrentGroup()->getId() + ":TD" + elm.getAttribute("id")); + else + _Cells.back()->setId(getCurrentGroup()->getId() + ":TD" + toString(getNextAutoIdSeq())); if (_Style.checkStyle("background-repeat", "repeat")) _Cells.back()->setTextureTile(true);