Fixed: Multiline text inside lists

--HG--
branch : develop
This commit is contained in:
Nimetu 2017-09-02 23:13:04 +03:00
parent c22b361dc2
commit d6dcf7415a
7 changed files with 48 additions and 34 deletions

View file

@ -714,7 +714,12 @@ namespace NLGUI
std::vector<CCellParams> _CellParams; std::vector<CCellParams> _CellParams;
// Indentation // Indentation
uint _Indent; std::vector<uint> _Indent;
inline uint getIndent() const {
if (_Indent.empty())
return 0;
return _Indent.back();
}
// Current node is a title // Current node is a title
bool _Title; bool _Title;

View file

@ -94,6 +94,7 @@ namespace NLGUI
_XReal = _YReal = _WReal = _HReal = 0; _XReal = _YReal = _WReal = _HReal = 0;
_X = _Y = _W = _H = 0; _X = _Y = _W = _H = 0;
//_Snap = 1; //_Snap = 1;
_MarginLeft = 0;
_PosRef = Hotspot_BL; _PosRef = Hotspot_BL;
_ParentPosRef = Hotspot_BL; _ParentPosRef = Hotspot_BL;
@ -178,6 +179,9 @@ namespace NLGUI
sint32 getH() const { return (_Active?_H:0); } sint32 getH() const { return (_Active?_H:0); }
sint32 getH(bool bTestActive) const { return (bTestActive?(_Active?_H:0):_H); } sint32 getH(bool bTestActive) const { return (bTestActive?(_Active?_H:0):_H); }
void setMarginLeft(sint32 m) { _MarginLeft = m; }
sint32 getMarginLeft() const { return _MarginLeft; }
/** /**
* Get the max width used by the window. * Get the max width used by the window.
* *
@ -568,6 +572,8 @@ namespace NLGUI
sint32 _W; sint32 _W;
sint32 _H; sint32 _H;
sint32 _MarginLeft;
//sint32 _Snap; //sint32 _Snap;
// position references e.g. : _PosRef=BL, _ParentPosref=MM : the bottom left corner of the element // position references e.g. : _PosRef=BL, _ParentPosref=MM : the bottom left corner of the element

View file

@ -93,7 +93,7 @@ namespace NLGUI
void setMultiLineSpace (sint nMultiLineSpace); void setMultiLineSpace (sint nMultiLineSpace);
void setMultiLineMaxWOnly (bool state); void setMultiLineMaxWOnly (bool state);
void setMultiLineClipEndSpace (bool state); // use it for multiline edit box for instance void setMultiLineClipEndSpace (bool state); // use it for multiline edit box for instance
void setFirstLineX (uint firstLineX); void setFirstLineX (sint firstLineX);
void setMultiMaxLine(uint l) { _MultiMaxLine = l; } void setMultiMaxLine(uint l) { _MultiMaxLine = l; }
void setMultiMinLine(uint l) { _MultiMinLine = l; } void setMultiMinLine(uint l) { _MultiMinLine = l; }
@ -398,7 +398,7 @@ namespace NLGUI
uint _TextSelectionEnd; uint _TextSelectionEnd;
// First line X coordinate // First line X coordinate
uint _FirstLineX; sint _FirstLineX;
/// Dynamic tooltips /// Dynamic tooltips
std::vector<CCtrlToolTip*> _Tooltips; std::vector<CCtrlToolTip*> _Tooltips;

View file

@ -2181,8 +2181,9 @@ namespace NLGUI
sint32 indent = LIIndent; sint32 indent = LIIndent;
// list-style-type: outside // list-style-type: outside
if (_CurrentViewLink) if (_CurrentViewLink)
indent -= _CurrentViewLink->getMaxUsedW(); {
getParagraph()->setFirstViewIndent(indent); getParagraph()->setFirstViewIndent(-_CurrentViewLink->getMaxUsedW());
}
flushString (); flushString ();
@ -2238,8 +2239,7 @@ namespace NLGUI
if (present[MY_HTML_TABLE_CELLPADDING] && value[MY_HTML_TABLE_CELLPADDING]) if (present[MY_HTML_TABLE_CELLPADDING] && value[MY_HTML_TABLE_CELLPADDING])
fromString(value[MY_HTML_TABLE_CELLPADDING], table->CellPadding); fromString(value[MY_HTML_TABLE_CELLPADDING], table->CellPadding);
// Table must fit the container size table->setMarginLeft(getIndent());
addHtmlGroup (table, 0); addHtmlGroup (table, 0);
_Tables.push_back(table); _Tables.push_back(table);
@ -2247,6 +2247,7 @@ namespace NLGUI
// Add a cell pointer // Add a cell pointer
_Cells.push_back(NULL); _Cells.push_back(NULL);
_TR.push_back(false); _TR.push_back(false);
_Indent.push_back(0);
} }
break; break;
case HTML_TH: case HTML_TH:
@ -2328,7 +2329,12 @@ namespace NLGUI
_Cells.back()->NewLine = getTR(); _Cells.back()->NewLine = getTR();
table->addChild (_Cells.back()); table->addChild (_Cells.back());
// reusing indent pushed by table
_Indent.back() = 0;
newParagraph(TDBeginSpace); newParagraph(TDBeginSpace);
// indent is already 0, getParagraph()->setMarginLeft(0); // maybe setIndent(0) if LI is using one
// Reset TR flag // Reset TR flag
if (!_TR.empty()) if (!_TR.empty())
@ -2418,7 +2424,7 @@ namespace NLGUI
_UL.push_back(HTMLOListElement(1, "square")); _UL.push_back(HTMLOListElement(1, "square"));
// if LI is already present // if LI is already present
_LI = _UL.size() > 1 || _DL.size() > 1; _LI = _UL.size() > 1 || _DL.size() > 1;
_Indent += ULIndent; _Indent.push_back(getIndent() + ULIndent);
endParagraph(); endParagraph();
break; break;
case HTML_OBJECT: case HTML_OBJECT:
@ -2489,6 +2495,13 @@ namespace NLGUI
case HTML_DT: case HTML_DT:
if (!_DL.empty()) if (!_DL.empty())
{ {
// close DT if still open
if (_DL.back().DD)
{
_DL.back().DD = false;
popIfNotEmpty(_Indent);
}
// see if this is the first <dt>, closing tag not required // see if this is the first <dt>, closing tag not required
if (!_DL.back().DT) if (!_DL.back().DT)
{ {
@ -2519,8 +2532,8 @@ namespace NLGUI
if (!_DL.back().DD) if (!_DL.back().DD)
{ {
_Indent += ULIndent;
_DL.back().DD = true; _DL.back().DD = true;
_Indent.push_back(getIndent() + ULIndent);
} }
if (!_LI) if (!_LI)
@ -2547,7 +2560,7 @@ namespace NLGUI
_UL.push_back(HTMLOListElement(start, type)); _UL.push_back(HTMLOListElement(start, type));
// if LI is already present // if LI is already present
_LI = _UL.size() > 1 || _DL.size() > 1; _LI = _UL.size() > 1 || _DL.size() > 1;
_Indent += ULIndent; _Indent.push_back(getIndent() + ULIndent);
endParagraph(); endParagraph();
} }
break; break;
@ -2659,6 +2672,7 @@ namespace NLGUI
popIfNotEmpty (_TR); popIfNotEmpty (_TR);
popIfNotEmpty (_Cells); popIfNotEmpty (_Cells);
popIfNotEmpty (_Tables); popIfNotEmpty (_Tables);
popIfNotEmpty (_Indent);
endParagraph(); endParagraph();
// Add a cell // Add a cell
break; break;
@ -2801,13 +2815,9 @@ namespace NLGUI
case HTML_UL: case HTML_UL:
if (!_UL.empty()) if (!_UL.empty())
{ {
if (_Indent > ULIndent)
_Indent = _Indent - ULIndent;
else
_Indent = 0;
endParagraph(); endParagraph();
popIfNotEmpty(_UL); popIfNotEmpty(_UL);
popIfNotEmpty(_Indent);
} }
break; break;
case HTML_DL: case HTML_DL:
@ -2824,10 +2834,7 @@ namespace NLGUI
// unclosed DD // unclosed DD
if (_DL.back().DD) if (_DL.back().DD)
{ {
if (_Indent > ULIndent) popIfNotEmpty(_Indent);
_Indent = _Indent - ULIndent;
else
_Indent = 0;
} }
popIfNotEmpty (_DL); popIfNotEmpty (_DL);
@ -2846,12 +2853,8 @@ namespace NLGUI
// parser will process two DD in a row as nested when first DD is not closed // parser will process two DD in a row as nested when first DD is not closed
if (_DL.back().DD) if (_DL.back().DD)
{ {
if (_Indent > ULIndent)
_Indent = _Indent - ULIndent;
else
_Indent = 0;
_DL.back().DD = false; _DL.back().DD = false;
popIfNotEmpty(_Indent);
} }
} }
break; break;
@ -2964,7 +2967,7 @@ namespace NLGUI
_Connecting = false; _Connecting = false;
_CurrentViewLink = NULL; _CurrentViewLink = NULL;
_CurrentViewImage = NULL; _CurrentViewImage = NULL;
_Indent = 0; _Indent.clear();
_LI = false; _LI = false;
_SelectOption = false; _SelectOption = false;
_GroupListAdaptor = NULL; _GroupListAdaptor = NULL;
@ -4033,7 +4036,7 @@ namespace NLGUI
CGroupParagraph *newParagraph = new CGroupParagraph(CViewBase::TCtorParam()); CGroupParagraph *newParagraph = new CGroupParagraph(CViewBase::TCtorParam());
newParagraph->setResizeFromChildH(true); newParagraph->setResizeFromChildH(true);
newParagraph->setIndent(_Indent); newParagraph->setMarginLeft(getIndent());
// Add to the group // Add to the group
addHtmlGroup (newParagraph, beginSpace); addHtmlGroup (newParagraph, beginSpace);
@ -4767,7 +4770,7 @@ namespace NLGUI
_FontOblique.clear(); _FontOblique.clear();
_FontUnderlined.clear(); _FontUnderlined.clear();
_FontStrikeThrough.clear(); _FontStrikeThrough.clear();
_Indent = 0; _Indent.clear();
_LI = false; _LI = false;
_UL.clear(); _UL.clear();
_DL.clear(); _DL.clear();

View file

@ -509,7 +509,7 @@ namespace NLGUI
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CInterfaceElement::updateCoords() void CInterfaceElement::updateCoords()
{ {
_XReal = _X; _XReal = _X + _MarginLeft;
_YReal = _Y; _YReal = _Y;
_WReal = getW(); _WReal = getW();
_HReal = getH(); _HReal = getH();
@ -526,7 +526,7 @@ namespace NLGUI
if (el == NULL) if (el == NULL)
return; return;
_XReal += el->_XReal; _XReal += el->_XReal - el->_MarginLeft;
_YReal += el->_YReal; _YReal += el->_YReal;
THotSpot hsParent = _ParentPosRef; THotSpot hsParent = _ParentPosRef;

View file

@ -1457,7 +1457,7 @@ namespace NLGUI
} }
CViewBase::updateCoords(); CViewBase::updateCoords();
_XReal += _OffsetX; _XReal += _OffsetX + _MarginLeft;
_YReal += _OffsetY; _YReal += _OffsetY;
//update all children elements //update all children elements
@ -1468,7 +1468,7 @@ namespace NLGUI
pIE->updateCoords(); pIE->updateCoords();
} }
_XReal -= _OffsetX; _XReal -= _OffsetX - _MarginLeft;
_YReal -= _OffsetY; _YReal -= _OffsetY;
} }
@ -1958,9 +1958,9 @@ namespace NLGUI
newSciH = newSciH - ((newSciY+newSciH)-(oldSciY+oldSciH)); newSciH = newSciH - ((newSciY+newSciH)-(oldSciY+oldSciH));
} }
newSciXDest = newSciX; newSciXDest = newSciX - _MarginLeft;
newSciYDest = newSciY; newSciYDest = newSciY;
newSciWDest = newSciW; newSciWDest = newSciW + _MarginLeft;
newSciHDest = newSciH; newSciHDest = newSciH;
} }

View file

@ -2494,7 +2494,7 @@ namespace NLGUI
} }
// *************************************************************************** // ***************************************************************************
void CViewText::setFirstLineX(uint firstLineX) void CViewText::setFirstLineX(sint firstLineX)
{ {
_FirstLineX = firstLineX; _FirstLineX = firstLineX;
} }