Merge remote-tracking branch 'origin/webig-fixes' into yubo

fix_opengl_on_mac
Ulukyn 5 years ago
commit c9bec465bc

@ -357,6 +357,10 @@ namespace NLGUI
// Delete page content and prepare next page // Delete page content and prepare next page
void removeContent (); void removeContent ();
// Counter to number html elements without id attribute
uint32 getNextAutoIdSeq() { return _AutoIdSeq++; }
uint32 _AutoIdSeq;
// Current URL for relative links in page // Current URL for relative links in page
std::string _URL; std::string _URL;
// Current URL // Current URL
@ -676,6 +680,8 @@ namespace NLGUI
std::vector<CEntry> Entries; std::vector<CEntry> Entries;
}; };
std::vector<CForm> _Forms; std::vector<CForm> _Forms;
// if <FORM> element has been closed or not
bool _FormOpen;
// submit buttons added to from // submit buttons added to from
struct SFormSubmitButton struct SFormSubmitButton
@ -946,6 +952,7 @@ namespace NLGUI
//void htmlEM(const CHtmlElement &elm); //void htmlEM(const CHtmlElement &elm);
void htmlFONT(const CHtmlElement &elm); void htmlFONT(const CHtmlElement &elm);
void htmlFORM(const CHtmlElement &elm); void htmlFORM(const CHtmlElement &elm);
void htmlFORMend(const CHtmlElement &elm);
void htmlH(const CHtmlElement &elm); void htmlH(const CHtmlElement &elm);
void htmlHend(const CHtmlElement &elm); void htmlHend(const CHtmlElement &elm);
void htmlHEAD(const CHtmlElement &elm); void htmlHEAD(const CHtmlElement &elm);

@ -1189,7 +1189,7 @@ namespace NLGUI
case HTML_DT: htmlDTend(elm); break; case HTML_DT: htmlDTend(elm); break;
case HTML_EM: renderPseudoElement(":after", elm);break; case HTML_EM: renderPseudoElement(":after", elm);break;
case HTML_FONT: break; case HTML_FONT: break;
case HTML_FORM: renderPseudoElement(":after", elm);break; case HTML_FORM: htmlFORMend(elm); break;
case HTML_H1://no-break case HTML_H1://no-break
case HTML_H2://no-break case HTML_H2://no-break
case HTML_H3://no-break case HTML_H3://no-break
@ -1443,6 +1443,8 @@ namespace NLGUI
_LastRefreshTime = 0.0; _LastRefreshTime = 0.0;
_RenderNextTime = false; _RenderNextTime = false;
_WaitingForStylesheet = false; _WaitingForStylesheet = false;
_AutoIdSeq = 0;
_FormOpen = false;
// Register // Register
CWidgetManager::getInstance()->registerClockMsgTarget(this); CWidgetManager::getInstance()->registerClockMsgTarget(this);
@ -2531,6 +2533,7 @@ namespace NLGUI
{ {
// Add a new paragraph // Add a new paragraph
CGroupParagraph *newParagraph = new CGroupParagraph(CViewBase::TCtorParam()); CGroupParagraph *newParagraph = new CGroupParagraph(CViewBase::TCtorParam());
newParagraph->setId(getCurrentGroup()->getId() + ":PARAGRAPH" + toString(getNextAutoIdSeq()));
newParagraph->setResizeFromChildH(true); newParagraph->setResizeFromChildH(true);
newParagraph->setMarginLeft(getIndent()); newParagraph->setMarginLeft(getIndent());
@ -3238,6 +3241,7 @@ namespace NLGUI
_Cells.clear(); _Cells.clear();
_TR.clear(); _TR.clear();
_Forms.clear(); _Forms.clear();
_FormOpen = false;
_FormSubmit.clear(); _FormSubmit.clear();
_Groups.clear(); _Groups.clear();
_Divs.clear(); _Divs.clear();
@ -3251,6 +3255,7 @@ namespace NLGUI
_ReadingHeadTag = false; _ReadingHeadTag = false;
_IgnoreHeadTag = false; _IgnoreHeadTag = false;
_IgnoreBaseUrlTag = false; _IgnoreBaseUrlTag = false;
_AutoIdSeq = 0;
paragraphChange (); paragraphChange ();
@ -4327,6 +4332,7 @@ namespace NLGUI
if (!_GroupListAdaptor) if (!_GroupListAdaptor)
{ {
_GroupListAdaptor = new CGroupListAdaptor(CViewBase::TCtorParam()); // deleted by the list _GroupListAdaptor = new CGroupListAdaptor(CViewBase::TCtorParam()); // deleted by the list
_GroupListAdaptor->setId(getList()->getId() + ":GLA");
_GroupListAdaptor->setResizeFromChildH(true); _GroupListAdaptor->setResizeFromChildH(true);
getList()->addChild (_GroupListAdaptor, true); getList()->addChild (_GroupListAdaptor, true);
} }
@ -5541,6 +5547,11 @@ namespace NLGUI
std::string tooltip = elm.getAttribute("tooltip"); std::string tooltip = elm.getAttribute("tooltip");
bool disabled = elm.hasAttribute("disabled"); bool disabled = elm.hasAttribute("disabled");
if (formId.empty() && _FormOpen)
{
formId = _Forms.back().id;
}
if (!formAction.empty()) if (!formAction.empty())
{ {
formAction = getAbsoluteUrl(formAction); formAction = getAbsoluteUrl(formAction);
@ -5643,6 +5654,8 @@ namespace NLGUI
{ {
string style = elm.getAttribute("style"); string style = elm.getAttribute("style");
string id = elm.getAttribute("id"); string id = elm.getAttribute("id");
if (id.empty())
id = "DIV" + toString(getNextAutoIdSeq());
typedef pair<string, string> TTmplParam; typedef pair<string, string> TTmplParam;
vector<TTmplParam> tmplParams; vector<TTmplParam> tmplParams;
@ -5675,10 +5688,10 @@ namespace NLGUI
parentId = _Paragraph->getId(); 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) if (inst)
{ {
inst->setId(this->_Id+":"+id); inst->setId(parentId+":"+id);
inst->updateCoords(); inst->updateCoords();
if (haveParentDiv) if (haveParentDiv)
{ {
@ -5811,6 +5824,8 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CGroupHTML::htmlFORM(const CHtmlElement &elm) void CGroupHTML::htmlFORM(const CHtmlElement &elm)
{ {
_FormOpen = true;
// Build the form // Build the form
CGroupHTML::CForm form; CGroupHTML::CForm form;
// id check is case sensitive and auto id's are uppercase // id check is case sensitive and auto id's are uppercase
@ -5835,6 +5850,12 @@ namespace NLGUI
renderPseudoElement(":before", elm); renderPseudoElement(":before", elm);
} }
void CGroupHTML::htmlFORMend(const CHtmlElement &elm)
{
_FormOpen = false;
renderPseudoElement(":after", elm);
}
// *************************************************************************** // ***************************************************************************
void CGroupHTML::htmlH(const CHtmlElement &elm) void CGroupHTML::htmlH(const CHtmlElement &elm)
{ {
@ -6607,6 +6628,10 @@ namespace NLGUI
CGroupTable *table = new CGroupTable(TCtorParam()); CGroupTable *table = new CGroupTable(TCtorParam());
table->BgColor = _CellParams.back().BgColor; 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; // TODO: border-spacing: 2em;
{ {
@ -6767,6 +6792,10 @@ namespace NLGUI
} }
_Cells.back() = new CGroupCell(CViewBase::TCtorParam()); _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")) if (_Style.checkStyle("background-repeat", "repeat"))
_Cells.back()->setTextureTile(true); _Cells.back()->setTextureTile(true);

@ -1116,8 +1116,8 @@ class CHandlerHTMLSubmitForm : public IActionHandler
return; return;
} }
sint32 x = pCaller->getEventX(); sint32 x = pCaller ? pCaller->getEventX() : 0;
sint32 y = pCaller->getEventY(); sint32 y = pCaller ? pCaller->getEventY() : 0;
CInterfaceElement *element = CWidgetManager::getInstance()->getElementFromId(container); CInterfaceElement *element = CWidgetManager::getInstance()->getElementFromId(container);
{ {
@ -1127,6 +1127,10 @@ class CHandlerHTMLSubmitForm : public IActionHandler
{ {
groupHtml->submitForm(button, x, y); groupHtml->submitForm(button, x, y);
} }
else
{
nlwarning("CGroupHTML with id '%s' not found.", container.c_str());
}
} }
} }
}; };

Loading…
Cancel
Save