Merge with develop

This commit is contained in:
Nimetu 2016-06-12 12:49:14 +03:00
parent 8da49a8189
commit 8f9d7078bd
5 changed files with 136 additions and 19 deletions

View file

@ -94,6 +94,7 @@ namespace NLGUI
void setMultiLineClipEndSpace (bool state); // use it for multiline edit box for instance
void setFirstLineX (uint firstLineX);
void setMultiMaxLine(uint l) { _MultiMaxLine = l; }
void setMultiMinLine(uint l) { _MultiMinLine = l; }
// Force only a subset of letter to be displayed. Default is 0/0xFFFFFFFF
void enableStringSelection(uint start, uint end);
@ -114,6 +115,8 @@ namespace NLGUI
sint getMultiLineSpace() const { return _MultiLineSpace; }
bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; }
uint32 getMultiMaxLine() const { return _MultiMaxLine; }
uint32 getMultiMinLine() const { return _MultiMinLine; }
uint32 getMultiMinOffsetY() const;
// get current Hint font width, in pixels
uint getFontWidth() const;
@ -259,6 +262,7 @@ namespace NLGUI
sint _MultiLineSpace;
sint _LastMultiLineMaxW;
uint32 _MultiMaxLine;
uint32 _MultiMinLine;
/// FormatTag handling

View file

@ -55,6 +55,7 @@ using namespace NLMISC;
// Allow up to 10 redirects, then give up
#define DEFAULT_RYZOM_REDIRECT_LIMIT (10)
//
#define FONT_WEIGHT_NORMAL 400
#define FONT_WEIGHT_BOLD 700
namespace NLGUI
@ -1417,14 +1418,24 @@ namespace NLGUI
if (present[MY_HTML_INPUT_ALT] && value[MY_HTML_INPUT_ALT])
tooltip = value[MY_HTML_INPUT_ALT];
// by default not inherited
CStyleParams style;
style.TextColor = TextColor;
style.FontSize = TextFontSize;
style.FontWeight = FONT_WEIGHT_NORMAL;
style.FontOblique = false;
if (present[MY_HTML_INPUT_STYLE] && value[MY_HTML_INPUT_STYLE])
getStyleParams(value[MY_HTML_INPUT_STYLE], style);
_TextColor.push_back(style.TextColor);
_FontSize.push_back(style.FontSize);
_FontWeight.push_back(style.FontWeight);
_FontOblique.push_back(style.FontOblique);
string type = toLower(value[MY_HTML_INPUT_TYPE]);
if (type == "image")
{
CStyleParams style;
// width, height from inline css
if (present[MY_HTML_INPUT_STYLE] && value[MY_HTML_INPUT_STYLE])
getStyleParams(value[MY_HTML_INPUT_STYLE], style);
// The submit button
string name;
string normal;
@ -1632,6 +1643,11 @@ namespace NLGUI
_Forms.back().Entries.push_back (entry);
}
}
popIfNotEmpty(_FontSize);
popIfNotEmpty(_TextColor);
popIfNotEmpty(_FontWeight);
popIfNotEmpty(_FontOblique);
}
}
break;
@ -1868,9 +1884,26 @@ namespace NLGUI
}
break;
case HTML_TEXTAREA:
_PRE.push_back(true);
// Got one form ?
if (!(_Forms.empty()))
{
// not inherited by default
CStyleParams style;
style.TextColor = TextColor;
style.FontWeight = FONT_WEIGHT_NORMAL;
style.FontOblique = false;
style.FontSize = TextFontSize;
if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE])
getStyleParams(value[MY_HTML_TEXTAREA_STYLE], style);
_TextColor.push_back(style.TextColor);
_FontSize.push_back(style.FontSize);
_FontWeight.push_back(style.FontWeight);
_FontOblique.push_back(style.FontOblique);
// read general property
string templateName;
@ -2187,7 +2220,14 @@ namespace NLGUI
entry.TextArea = textArea;
_Forms.back().Entries.push_back (entry);
}
popIfNotEmpty (_FontSize);
popIfNotEmpty (_FontWeight);
popIfNotEmpty (_FontOblique);
popIfNotEmpty (_TextColor);
}
popIfNotEmpty (_PRE);
}
break;
case HTML_TITLE:
@ -3973,7 +4013,7 @@ namespace NLGUI
// ***************************************************************************
CInterfaceGroup *CGroupHTML::addTextArea(const std::string &templateName, const char *name, uint /* rows */, uint cols, bool multiLine, const ucstring &content, uint maxlength)
CInterfaceGroup *CGroupHTML::addTextArea(const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content, uint maxlength)
{
// In a paragraph ?
if (!_Paragraph)
@ -3988,11 +4028,18 @@ namespace NLGUI
{
// Not added ?
std::vector<std::pair<std::string,std::string> > templateParams;
templateParams.push_back (std::pair<std::string,std::string> ("w", toString (cols*12)));
//templateParams.push_back (std::pair<std::string,std::string> ("h", toString (rows*12)));
templateParams.push_back (std::pair<std::string,std::string> ("w", toString (cols*getFontSize())));
templateParams.push_back (std::pair<std::string,std::string> ("id", name));
templateParams.push_back (std::pair<std::string,std::string> ("prompt", ""));
templateParams.push_back (std::pair<std::string,std::string> ("multiline", multiLine?"true":"false"));
templateParams.push_back (std::pair<std::string,std::string> ("fontsize", toString (getFontSize())));
templateParams.push_back (std::pair<std::string,std::string> ("color", getTextColor().toString()));
if (getFontWeight() >= FONT_WEIGHT_BOLD)
templateParams.push_back (std::pair<std::string,std::string> ("fontweight", "bold"));
if (getFontOblique())
templateParams.push_back (std::pair<std::string,std::string> ("fontstyle", "oblique"));
if (multiLine)
templateParams.push_back (std::pair<std::string,std::string> ("multi_min_line", toString(rows)));
templateParams.push_back (std::pair<std::string,std::string> ("want_return", multiLine?"true":"false"));
templateParams.push_back (std::pair<std::string,std::string> ("enter_recover_focus", "false"));
if (maxlength > 0)
@ -5545,15 +5592,23 @@ namespace NLGUI
{
if (it->first == "font-size")
{
float tmp;
sint size = 0;
getPercentage (size, tmp, it->second.c_str());
if (size > 0)
style.FontSize = size;
if (it->second == "inherit")
style.FontSize = getFontSize();
else
{
float tmp;
sint size = 0;
getPercentage (size, tmp, it->second.c_str());
if (size > 0)
style.FontSize = size;
}
}
else
if (it->first == "font-style")
{
if (it->second == "inherit")
style.FontOblique = getFontOblique();
else
if (it->second == "italic" || it->second == "oblique")
style.FontOblique = true;
}
@ -5562,6 +5617,9 @@ namespace NLGUI
{
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
uint weight = 400;
if (it->second == "inherit")
weight = getFontWeight();
else
if (it->second == "normal")
weight = 400;
else
@ -5594,7 +5652,10 @@ namespace NLGUI
}
else
if (it->first == "color")
scanHTMLColor(it->second.c_str(), style.TextColor);
if (it->second == "inherit")
style.TextColor = getTextColor();
else
scanHTMLColor(it->second.c_str(), style.TextColor);
else
if (it->first == "text-decoration" || it->first == "text-decoration-line")
{

View file

@ -75,6 +75,7 @@ namespace NLGUI
_MultiLineMaxWOnly = false;
_MultiLineClipEndSpace = false;
_LastMultiLineMaxW = 0;
_MultiMinLine = 0;
_MultiMaxLine = 0;
_Index = 0xFFFFFFFF;
@ -305,6 +306,11 @@ namespace NLGUI
return toString( _MultiMaxLine );
}
else
if( name == "multi_min_line" )
{
return toString( _MultiMinLine );
}
else
if( name == "underlined" )
{
return toString( _Underlined );
@ -479,6 +485,14 @@ namespace NLGUI
return true;
}
else
if( name == "multi_min_line" )
{
uint32 i;
if( fromString( value, i ) )
_MultiMinLine = i;
return true;
}
else
if( name == "underlined" )
{
bool b;
@ -621,6 +635,7 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "multi_line_space", BAD_CAST toString( _MultiLineSpace ).c_str() );
xmlSetProp( node, BAD_CAST "multi_line_maxw_only", BAD_CAST toString( _MultiLineMaxWOnly ).c_str() );
xmlSetProp( node, BAD_CAST "multi_max_line", BAD_CAST toString( _MultiMaxLine ).c_str() );
xmlSetProp( node, BAD_CAST "multi_min_line", BAD_CAST toString( _MultiMinLine ).c_str() );
xmlSetProp( node, BAD_CAST "underlined", BAD_CAST toString( _Underlined ).c_str() );
xmlSetProp( node, BAD_CAST "strikethrough", BAD_CAST toString( _StrikeThrough ).c_str() );
xmlSetProp( node, BAD_CAST "case_mode", BAD_CAST toString( uint32( _CaseMode ) ).c_str() );
@ -741,6 +756,11 @@ namespace NLGUI
if (prop)
fromString((const char*)prop, _MultiMaxLine);
prop = (char*) xmlGetProp( cur, (xmlChar*)"multi_min_line" );
_MultiMinLine = 0;
if (prop)
fromString((const char*)prop, _MultiMinLine);
prop = (char*) xmlGetProp( cur, (xmlChar*)"underlined" );
_Underlined = false;
if (prop)
@ -981,6 +1001,13 @@ namespace NLGUI
sint y_line = _YReal+_FontLegHeight-2;
if (_MultiMinLine > _Lines.size())
{
uint dy = getMultiMinOffsetY();
y += dy * ooh;
y_line += dy;
}
// special selection code
if(_TextSelection)
{
@ -1360,6 +1387,19 @@ namespace NLGUI
return _FontLegHeight;
}
// ***************************************************************************
uint CViewText::getMultiMinOffsetY() const
{
uint dy = 0;
if (_MultiMinLine > _Lines.size())
{
// first line is always present even if _Lines is empty
uint nbLines = _MultiMinLine - std::max((sint)1, (sint)_Lines.size());
dy = nbLines * _FontHeight + (nbLines - 1) * _MultiLineSpace;
}
return dy;
}
// ***************************************************************************
void CViewText::flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat)
{
@ -1836,6 +1876,10 @@ namespace NLGUI
_W = (sint)rTotalW;
_H = std::max(_FontHeight, uint(_FontHeight * _Lines.size() + std::max(0, sint(_Lines.size()) - 1) * _MultiLineSpace));
// See if we should pretend to have at least X lines
if (_MultiMinLine > 1)
_H = std::max(_H, sint(_FontHeight * _MultiMinLine + (_MultiMinLine - 1) * _MultiLineSpace));
// Compute tooltips size
if (_Tooltips.size() > 0)
for (uint i=0 ; i<_Lines.size() ; ++i)
@ -2118,11 +2162,13 @@ namespace NLGUI
//
if (_MultiLine)
{
uint dy = getMultiMinOffsetY();
uint charIndex = 0;
// special case for end of text
if (index == (sint) _Text.length())
{
y = 0;
y = dy;
if (_Lines.empty())
{
x = 0;
@ -2142,7 +2188,7 @@ namespace NLGUI
{
// should display the character at the end of previous line
CLine &currLine = *_Lines[i - 1];
y = (sint) ((_FontHeight + _MultiLineSpace) * (_Lines.size() - i));
y = (sint) ((_FontHeight + _MultiLineSpace) * (_Lines.size() - i) + dy);
x = (sint) (currLine.getWidth() + currLine.getEndSpaces() * currLine.getSpaceWidth());
sint nMaxWidth = getCurrentMultiLineMaxW();
x = std::min(x, nMaxWidth);
@ -2153,7 +2199,7 @@ namespace NLGUI
if ((sint) newCharIndex > index)
{
// ok, this line contains the character, now, see which word contains it.
y = (sint) ((_FontHeight + _MultiLineSpace) * (_Lines.size() - 1 - i));
y = (sint) ((_FontHeight + _MultiLineSpace) * (_Lines.size() - 1 - i) + dy);
// see if the index is in the spaces at the end of line
if (index - charIndex >= currLine.getNumChars())
{
@ -2252,6 +2298,7 @@ namespace NLGUI
uint charPos = 0;
if (_MultiLine)
{
y -= getMultiMinOffsetY();
// seek the line
float py = 0.f;
if (py > y)

View file

@ -111,17 +111,20 @@
entry_type="text"
keep="true"
max_historic="40"
fontsize="10"
fontsize="10"
fontweight=""
fontstyle=""
backup_father_container_pos="false"
want_return="false"
color="255 255 255 255"
sizeref_eb="w"
render_layer="0"
multi_min_line="0"
>
<group id="#id" posref="#posref" x="#x" y="#y" posparent="#posparent" child_resize_h="#child_resize_h" sizeref="#sizeref" w="#w" h="#h" render_layer="#render_layer">
<group type="edit_box" sizeref="#sizeref_eb" w="-16" id="eb" posref="TL TL" x="8" y="-8" child_resize_h="#child_resize_h" onenter="#onenter" params="#params" onchange="#onchange" onchange_params="#onchange_params" max_num_chars="#max_num_chars" prompt="#prompt" enter_loose_focus="#enter_loose_focus" enter_recover_focus="#enter_recover_focus" entry_type="#entry_type" reset_focus_on_hide="#reset_focus_on_hide" menu_r="#menu_r" max_historic="#max_historic" want_return="#want_return" backup_father_container_pos="#backup_father_container_pos" render_layer="#render_layer">
<view type="bitmap" id="bg" scale="true" sizeref="hw" h="0" w="0" texture="log_eb_m.tga" inherit_gc_alpha="false" render_layer="#render_layer"/>
<view id="edit_text" type="text" x="#text_x" y="#text_y" posref="#text_ref" multi_line="#multi_line" multi_line_space="0" fontsize="#fontsize" color="#color" shadow="true" hardtext="" global_color="false" render_layer="#render_layer"/>
<view id="edit_text" type="text" x="#text_x" y="#text_y" posref="#text_ref" multi_line="#multi_line" multi_line_space="0" multi_min_line="#multi_min_line" fontsize="#fontsize" color="#color" fontweight="#fontweight" fontstyle="#fontstyle" shadow="true" hardtext="" global_color="false" render_layer="#render_layer"/>
</group>
<!-- border around the list -->

View file

@ -2793,6 +2793,7 @@
text_ref="BL BL"
child_resize_h="true"
multi_line="true"
multi_min_line="0"
x="0"
y="0"
w="0"
@ -2872,6 +2873,7 @@
posref="#text_ref"
multi_line="#multi_line"
multi_line_space="0"
multi_min_line="#multi_min_line"
fontsize="#fontsize"
color="#color"
shadow="true"