Merge with develop

--HG--
branch : compatibility-develop
hg/compatibility-develop
Nimetu 6 years ago
commit 6948adc0f7

@ -111,9 +111,19 @@ namespace NLGUI
sint32 getWMin() const { return _WMin; }
void setWMin( sint32 wmin ) { _WMin = wmin; }
sint32 getHMin() const { return _HMin; }
void setHMin( sint32 hmin ) { _HMin = hmin; }
// Compute Size according to bitmap and Text (Ensure as big as possible button)
sint32 getWMax() const;
// Set texture directly without _l.tga, _m.tga, _r.tga convention
// Texture size is only read from normal textures
// If updateHeight == false, then _BmpH will keep its value
void setTexture(const std::string &l, const std::string &m, const std::string &r, bool updateHeight = true);
void setTexturePushed(const std::string &l, const std::string &m, const std::string &r);
void setTextureOver(const std::string &l, const std::string &m, const std::string &r);
int luaGetViewText(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton)
@ -122,6 +132,7 @@ namespace NLGUI
REFLECT_SINT32("text_x", getTextX, setTextX)
REFLECT_SINT32("wmargin", getWMargin, setWMargin)
REFLECT_SINT32("wmin", getWMin, setWMin)
REFLECT_SINT32("hmin", getHMin, setHMin)
REFLECT_LUA_METHOD("getViewText", luaGetViewText)
REFLECT_EXPORT_END
@ -151,8 +162,8 @@ namespace NLGUI
sint32 _BmpLeftW, _BmpMiddleW, _BmpRightW, _BmpH;
// Value to add to TextW to get button W.
sint32 _WMargin;
// Min W Value
sint32 _WMin;
// Min W, H Value
sint32 _WMin, _HMin;
sint32 _TextY;
sint32 _TextX;
THotSpot _TextPosRef;

@ -85,6 +85,7 @@ namespace NLGUI
// view text
void setViewText(const ucstring & text);
ucstring getViewText() const;
CViewText *getViewText();
void setTexture(uint i, const ucstring &texture);

@ -33,6 +33,7 @@ typedef std::map<std::string, std::string> TStyle;
namespace NLGUI
{
class CCtrlButton;
class CCtrlTextButton;
class CCtrlScroll;
class CGroupList;
class CGroupMenu;
@ -105,6 +106,9 @@ namespace NLGUI
Height=-1;
MaxWidth=-1;
MaxHeight=-1;
BorderWidth=1;
BackgroundColor=NLMISC::CRGBA::Black;
BackgroundColorOver=NLMISC::CRGBA::Black;
}
uint FontSize;
uint FontWeight;
@ -119,6 +123,9 @@ namespace NLGUI
sint32 Height;
sint32 MaxWidth;
sint32 MaxHeight;
sint32 BorderWidth;
NLMISC::CRGBA BackgroundColor;
NLMISC::CRGBA BackgroundColorOver;
};
// ImageDownload system
@ -350,6 +357,9 @@ namespace NLGUI
// Get Home URL
virtual std::string home();
// Clear style stack and restore default style
void resetCssStyle();
// Parse style html tag
TStyle parseStyle(const std::string &str_styles);
@ -793,7 +803,7 @@ namespace NLGUI
static TGroupHtmlByUIDMap _GroupHtmlByUID;
// read style attribute
void getStyleParams(const std::string &styleString, CStyleParams &style, bool inherit = true);
void getStyleParams(const std::string &styleString, CStyleParams &style, const CStyleParams &current);
void applyCssMinMax(sint32 &width, sint32 &height, sint32 minw=0, sint32 minh=0, sint32 maxw=0, sint32 maxh=0);
// load and render local html file (from bnp for example)
@ -859,6 +869,9 @@ namespace NLGUI
void setImage(CViewBase *view, const std::string &file, const TImageType type);
void setImageSize(CViewBase *view, const CStyleParams &style = CStyleParams());
void setTextButtonStyle(CCtrlTextButton *ctrlButton, const CStyleParams &style);
void setTextStyle(CViewText *pVT, const CStyleParams &style);
// BnpDownload system
void initBnpDownload();
void checkBnpDownload();

@ -351,6 +351,9 @@ namespace NLGUI
void setMinW(sint32 minW);
void setMinH(sint32 minH);
// change fontsize for new menu items
void setFontSize(uint32 fontSize);
// Gray a line on the RootMenu
void setGrayedLine(uint line, bool g);

@ -49,6 +49,14 @@ namespace NLGUI
#undef HTML_ATTR
#define HTML_ATTR(t,a) MY_HTML_##t##_##a
enum
{
HTML_ATTR(HTML,DIR) = 0,
HTML_ATTR(HTML,LANG),
HTML_ATTR(HTML,VERSION),
HTML_ATTR(HTML,STYLE),
};
enum
{
HTML_ATTR(A,ACCESSKEY) = 0,
@ -272,6 +280,9 @@ namespace NLGUI
#undef HTML_ATTR
// ***************************************************************************
// Read a CSS length value, return true if one of supported units '%, rem, em, px, pt'
// On failure: 'value' and 'unit' values are undefined
bool getCssLength (float &value, std::string &unit, const std::string &str);
// Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false
bool getPercentage (sint32 &width, float &percent, const char *str);

@ -46,6 +46,7 @@ namespace NLGUI
_BmpLeftW= _BmpMiddleW= _BmpRightW= _BmpH= 0;
_WMargin= 0;
_WMin= 0;
_HMin= 0;
_TextX= 0;
_TextY= 0;
_Setuped= false;
@ -124,6 +125,11 @@ namespace NLGUI
return toString( _WMin );
}
else
if( name == "hmin" )
{
return toString( _HMin );
}
else
if( name == "hardtext" )
{
if( _ViewText != NULL )
@ -296,6 +302,14 @@ namespace NLGUI
return;
}
else
if( name == "hmin" )
{
sint32 i;
if( fromString( value, i ) )
_HMin = i;
return;
}
else
if( name == "hardtext" )
{
if( _ViewText != NULL )
@ -469,6 +483,7 @@ namespace NLGUI
xmlNewProp( node, BAD_CAST "wmargin", BAD_CAST toString( _WMargin ).c_str() );
xmlNewProp( node, BAD_CAST "wmin", BAD_CAST toString( _WMin ).c_str() );
xmlNewProp( node, BAD_CAST "hmin", BAD_CAST toString( _HMin ).c_str() );
xmlNewProp( node, BAD_CAST "hardtext", BAD_CAST _ViewText->getText().toString().c_str() );
xmlNewProp( node, BAD_CAST "text_y", BAD_CAST toString( _TextY ).c_str() );
xmlNewProp( node, BAD_CAST "text_x", BAD_CAST toString( _TextX ).c_str() );
@ -519,7 +534,6 @@ namespace NLGUI
return false;
}
// *** Read Textures.
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_normal" );
if (prop)
@ -604,6 +618,15 @@ namespace NLGUI
// _WMin is at least the size of All W Bitmaps
_WMin= max(_WMin, _BmpLeftW + _BmpMiddleW + _BmpRightW);
// hmin
_HMin= 0;
prop = (char*) xmlGetProp( cur, (xmlChar*)"hmin" );
if (prop)
{
fromString((const char *) prop, _HMin);
}
_HMin= max(_HMin, _BmpH);
// TextY
_TextY= 0;
prop = (char*) xmlGetProp( cur, (xmlChar*)"text_y" );
@ -705,6 +728,43 @@ namespace NLGUI
return true;
}
// ***************************************************************************
void CCtrlTextButton::setTexture(const std::string &l, const std::string &m, const std::string &r, bool updateHeight)
{
nlctassert(NumTexture==3);
_TextureIdNormal[0].setTexture(l.c_str());
_TextureIdNormal[1].setTexture(m.c_str());
_TextureIdNormal[2].setTexture(r.c_str());
sint32 newH;
// Compute Bmp Sizes
CViewRenderer &rVR = *CViewRenderer::getInstance();
rVR.getTextureSizeFromId(_TextureIdNormal[0], _BmpLeftW, newH);
rVR.getTextureSizeFromId(_TextureIdNormal[1], _BmpMiddleW, newH);
rVR.getTextureSizeFromId(_TextureIdNormal[2], _BmpRightW, newH);
if (updateHeight) _BmpH = newH;
}
// ***************************************************************************
void CCtrlTextButton::setTexturePushed(const std::string &l, const std::string &m, const std::string &r)
{
nlctassert(NumTexture==3);
_TextureIdPushed[0].setTexture(l.c_str());
_TextureIdPushed[1].setTexture(m.c_str());
_TextureIdPushed[2].setTexture(r.c_str());
}
// ***************************************************************************
void CCtrlTextButton::setTextureOver(const std::string &l, const std::string &m, const std::string &r)
{
nlctassert(NumTexture==3);
_TextureIdOver[0].setTexture(l.c_str());
_TextureIdOver[1].setTexture(m.c_str());
_TextureIdOver[2].setTexture(r.c_str());
}
// ***************************************************************************
void CCtrlTextButton::draw ()
{
@ -900,6 +960,7 @@ namespace NLGUI
if (!(_SizeRef & 2))
{
_H= max(_BmpH, _ViewText->getH());
_H= max(_H, _HMin);
}
CViewBase::updateCoords();

@ -473,6 +473,12 @@ namespace NLGUI
return _ViewText->getText();
}
// ***************************************************************************
CViewText *CDBGroupComboBox::getViewText()
{
return _ViewText;
}
// ***************************************************************************
std::string CDBGroupComboBox::getSelectionText() const
{
@ -633,6 +639,9 @@ namespace NLGUI
{
nlassert(groupMenu);
if (_ViewText)
groupMenu->setFontSize(_ViewText->getFontSize());
// Setup the menu with combo action.
groupMenu->reset();
for(uint i=0; i<getNumTexts(); i++)

@ -381,7 +381,61 @@ namespace NLGUI
}
}
}
void CGroupHTML::setTextButtonStyle(CCtrlTextButton *ctrlButton, const CStyleParams &style)
{
// this will also set size for <a class="ryzom-ui-button"> treating it like "display: inline-block;"
if (style.Width > 0) ctrlButton->setWMin(_Style.Width);
if (style.Height > 0) ctrlButton->setHMin(_Style.Height);
CViewText *pVT = ctrlButton->getViewText();
if (pVT)
{
setTextStyle(pVT, _Style);
}
if (_Style.BackgroundColor.A > 0)
{
if (_Style.BackgroundColorOver.A == 0)
_Style.BackgroundColorOver = _Style.BackgroundColor;
ctrlButton->setColor(_Style.BackgroundColor);
ctrlButton->setColorOver(_Style.BackgroundColorOver);
ctrlButton->setTexture("", "blank.tga", "", false);
ctrlButton->setTextureOver("", "blank.tga", "");
ctrlButton->setProperty("force_text_over", "true");
}
else if (_Style.BackgroundColorOver.A > 0)
{
ctrlButton->setColorOver(_Style.BackgroundColorOver);
ctrlButton->setProperty("force_text_over", "true");
ctrlButton->setTextureOver("blank.tga", "blank.tga", "blank.tga");
}
}
void CGroupHTML::setTextStyle(CViewText *pVT, const CStyleParams &style)
{
if (pVT)
{
pVT->setFontSize(style.FontSize);
pVT->setColor(style.TextColor);
pVT->setColor(style.TextColor);
pVT->setFontName(style.FontFamily);
pVT->setFontSize(style.FontSize);
pVT->setEmbolden(style.FontWeight >= FONT_WEIGHT_BOLD);
pVT->setOblique(style.FontOblique);
pVT->setUnderlined(style.Underlined);
pVT->setStrikeThrough(style.StrikeThrough);
if (style.TextShadow.Enabled)
{
pVT->setShadow(true);
pVT->setShadowColor(style.TextShadow.Color);
pVT->setShadowOutline(style.TextShadow.Outline);
pVT->setShadowOffset(style.TextShadow.X, style.TextShadow.Y);
}
}
}
// Get an url and return the local filename with the path where the url image should be
string CGroupHTML::localImageName(const string &url)
{
@ -1489,6 +1543,13 @@ namespace NLGUI
// Paragraph ?
switch(element_number)
{
case HTML_HTML:
if (present[MY_HTML_HTML_STYLE] && value[MY_HTML_HTML_STYLE])
getStyleParams(value[MY_HTML_HTML_STYLE], _StyleDefault, _StyleDefault);
_Style = _StyleDefault;
setBackgroundColor(_Style.BackgroundColor);
break;
case HTML_HEAD:
_ReadingHeadTag = !_IgnoreHeadTag;
_IgnoreHeadTag = true;
@ -1549,9 +1610,13 @@ namespace NLGUI
_Style.TextColor = LinkColor;
_Style.Underlined = true;
_Style.GlobalColor = LinkColorGlobalColor;
_Style.BackgroundColor.A = 0;
_Style.BackgroundColorOver.A = 0;
_Style.Width = -1;
_Style.Height = -1;
if (present[HTML_A_STYLE] && value[HTML_A_STYLE])
getStyleParams(value[HTML_A_STYLE], _Style);
getStyleParams(value[HTML_A_STYLE], _Style, _StyleParams.back());
_A.push_back(true);
_Link.push_back ("");
@ -1604,7 +1669,7 @@ namespace NLGUI
style = value[MY_HTML_DIV_STYLE];
if (!style.empty())
getStyleParams(style, _Style);
getStyleParams(style, _Style, _StyleParams.back());
// use generic template system
if (_TrustedDomain && !instClass.empty() && instClass == "ryzom-ui-grouptemplate")
@ -1708,18 +1773,22 @@ namespace NLGUI
break;
case HTML_BODY:
{
if (present[HTML_BODY_BGCOLOR] && value[HTML_BODY_BGCOLOR])
{
CRGBA bgColor;
if (scanHTMLColor(value[HTML_BODY_BGCOLOR], bgColor))
setBackgroundColor (bgColor);
}
pushStyle();
string style;
if (present[HTML_BODY_STYLE] && value[HTML_BODY_STYLE])
style = value[HTML_BODY_STYLE];
if (!style.empty())
getStyleParams(style, _Style, _StyleParams.back());
CRGBA bgColor = _Style.BackgroundColor;
if (present[HTML_BODY_BGCOLOR] && value[HTML_BODY_BGCOLOR])
scanHTMLColor(value[HTML_BODY_BGCOLOR], bgColor);
if (bgColor != _Style.BackgroundColor)
setBackgroundColor(bgColor);
if (!style.empty())
{
TStyle styles = parseStyle(style);
@ -1743,10 +1812,6 @@ namespace NLGUI
image = image.substr(4, image.size()-5);
setBackground (image, scale, repeat);
}
// set default text style from <body>
getStyleParams(style, _StyleDefault);
_Style = _StyleDefault;
}
}
break;
@ -1776,7 +1841,7 @@ namespace NLGUI
_Style.TextColor = H1Color;
_Style.GlobalColor = H1ColorGlobalColor;
if (present[MY_HTML_H1_STYLE] && value[MY_HTML_H1_STYLE])
getStyleParams(value[MY_HTML_H1_STYLE], _Style);
getStyleParams(value[MY_HTML_H1_STYLE], _Style, _StyleParams.back());
}
break;
case HTML_H2:
@ -1788,7 +1853,7 @@ namespace NLGUI
_Style.TextColor = H2Color;
_Style.GlobalColor = H2ColorGlobalColor;
if (present[MY_HTML_H2_STYLE] && value[MY_HTML_H2_STYLE])
getStyleParams(value[MY_HTML_H2_STYLE], _Style);
getStyleParams(value[MY_HTML_H2_STYLE], _Style, _StyleParams.back());
}
break;
case HTML_H3:
@ -1800,7 +1865,7 @@ namespace NLGUI
_Style.TextColor = H3Color;
_Style.GlobalColor = H3ColorGlobalColor;
if (present[MY_HTML_H3_STYLE] && value[MY_HTML_H3_STYLE])
getStyleParams(value[MY_HTML_H3_STYLE], _Style);
getStyleParams(value[MY_HTML_H3_STYLE], _Style, _StyleParams.back());
}
break;
case HTML_H4:
@ -1812,7 +1877,7 @@ namespace NLGUI
_Style.TextColor = H4Color;
_Style.GlobalColor = H4ColorGlobalColor;
if (present[MY_HTML_H4_STYLE] && value[MY_HTML_H4_STYLE])
getStyleParams(value[MY_HTML_H4_STYLE], _Style);
getStyleParams(value[MY_HTML_H4_STYLE], _Style, _StyleParams.back());
}
break;
case HTML_H5:
@ -1824,7 +1889,7 @@ namespace NLGUI
_Style.TextColor = H5Color;
_Style.GlobalColor = H5ColorGlobalColor;
if (present[MY_HTML_H5_STYLE] && value[MY_HTML_H5_STYLE])
getStyleParams(value[MY_HTML_H5_STYLE], _Style);
getStyleParams(value[MY_HTML_H5_STYLE], _Style, _StyleParams.back());
}
break;
case HTML_H6:
@ -1836,7 +1901,7 @@ namespace NLGUI
_Style.TextColor = H6Color;
_Style.GlobalColor = H6ColorGlobalColor;
if (present[MY_HTML_H6_STYLE] && value[MY_HTML_H6_STYLE])
getStyleParams(value[MY_HTML_H6_STYLE], _Style);
getStyleParams(value[MY_HTML_H6_STYLE], _Style, _StyleParams.back());
}
break;
case HTML_IMG:
@ -1844,10 +1909,11 @@ namespace NLGUI
// Get the string name
if (present[MY_HTML_IMG_SRC] && value[MY_HTML_IMG_SRC])
{
CStyleParams style;
float tmpf;
std::string id;
CStyleParams style;
style.FontSize = _Style.FontSize;
if (present[MY_HTML_IMG_ID] && value[MY_HTML_IMG_ID])
id = value[MY_HTML_IMG_ID];
@ -1862,7 +1928,7 @@ namespace NLGUI
// width, height from inline css
if (present[MY_HTML_IMG_STYLE] && value[MY_HTML_IMG_STYLE])
getStyleParams(value[MY_HTML_IMG_STYLE], style);
getStyleParams(value[MY_HTML_IMG_STYLE], style, _Style);
// Tooltip
const char *tooltip = NULL;
@ -1948,6 +2014,13 @@ namespace NLGUI
_Style.FontSize = TextFontSize;
_Style.FontWeight = FONT_WEIGHT_NORMAL;
_Style.FontOblique = false;
_Style.TextShadow = STextShadow(true);
_Style.Width = -1;
_Style.Height = -1;
// by default background texture is transparent,
// using alpha value to decide if to change it to 'blank.tga' for coloring
_Style.BackgroundColor.A = 0;
_Style.BackgroundColorOver.A = 0;
// Global color flag
if (present[MY_HTML_INPUT_GLOBAL_COLOR])
@ -1959,7 +2032,7 @@ namespace NLGUI
tooltip = value[MY_HTML_INPUT_ALT];
if (present[MY_HTML_INPUT_STYLE] && value[MY_HTML_INPUT_STYLE])
getStyleParams(value[MY_HTML_INPUT_STYLE], _Style);
getStyleParams(value[MY_HTML_INPUT_STYLE], _Style, _StyleParams.back());
string type = toLower(value[MY_HTML_INPUT_TYPE]);
if (type == "image")
@ -2050,6 +2123,8 @@ namespace NLGUI
}
ctrlButton->setText(ucstring::makeFromUtf8(text));
setTextButtonStyle(ctrlButton, _Style);
}
getParagraph()->addChild (buttonGroup);
paragraphChange ();
@ -2196,7 +2271,7 @@ namespace NLGUI
if (present[HTML_SELECT_MULTIPLE] && value[HTML_SELECT_MULTIPLE])
multiple = true;
if (present[HTML_SELECT_STYLE] && value[HTML_SELECT_STYLE])
getStyleParams(value[HTML_SELECT_STYLE], style);
getStyleParams(value[HTML_SELECT_STYLE], style, _Style);
CGroupHTML::CForm::CEntry entry;
entry.Name = name;
@ -2217,6 +2292,7 @@ namespace NLGUI
sb->setMinH(style.Height);
sb->setMaxVisibleLine(size);
sb->setFontSize(style.FontSize);
}
entry.SelectBox = sb;
@ -2225,6 +2301,14 @@ namespace NLGUI
{
CDBGroupComboBox *cb = addComboBox(DefaultFormSelectGroup, name.c_str());
entry.ComboBox = cb;
if (cb)
{
// create view text
cb->updateCoords();
if (cb->getViewText())
setTextStyle(cb->getViewText(), style);
}
}
_Forms.back().Entries.push_back (entry);
}
@ -2271,7 +2355,7 @@ namespace NLGUI
pushStyle();
if (present[HTML_LI_STYLE] && value[HTML_LI_STYLE])
getStyleParams(value[HTML_LI_STYLE], _Style);
getStyleParams(value[HTML_LI_STYLE], _Style, _StyleParams.back());
ucstring str;
str.fromUtf8(_UL.back().getListMarkerText());
@ -2294,7 +2378,7 @@ namespace NLGUI
newParagraph(PBeginSpace);
pushStyle();
if (present[MY_HTML_P_STYLE] && value[MY_HTML_P_STYLE])
getStyleParams(value[MY_HTML_P_STYLE], _Style);
getStyleParams(value[MY_HTML_P_STYLE], _Style, _StyleParams.back());
}
break;
case HTML_PRE:
@ -2303,7 +2387,7 @@ namespace NLGUI
_Style.FontFamily = "monospace";
if (present[HTML_PRE_STYLE] && value[HTML_PRE_STYLE])
getStyleParams(value[HTML_PRE_STYLE], _Style);
getStyleParams(value[HTML_PRE_STYLE], _Style, _StyleParams.back());
_PRE.push_back(true);
@ -2331,7 +2415,7 @@ namespace NLGUI
if (present[MY_HTML_TABLE_CELLPADDING] && value[MY_HTML_TABLE_CELLPADDING])
fromString(value[MY_HTML_TABLE_CELLPADDING], table->CellPadding);
if (present[MY_HTML_TABLE_STYLE] && value[MY_HTML_TABLE_STYLE])
getStyleParams(value[MY_HTML_TABLE_STYLE], _Style);
getStyleParams(value[MY_HTML_TABLE_STYLE], _Style, _StyleParams.back());
table->setMarginLeft(getIndent());
addHtmlGroup (table, 0);
@ -2361,7 +2445,7 @@ namespace NLGUI
}
if (present[MY_HTML_TD_STYLE] && value[MY_HTML_TD_STYLE])
getStyleParams(value[MY_HTML_TD_STYLE], _Style);
getStyleParams(value[MY_HTML_TD_STYLE], _Style, _StyleParams.back());
CGroupTable *table = getTable();
if (table)
@ -2451,9 +2535,12 @@ namespace NLGUI
_Style.FontOblique = false;
_Style.FontSize = TextFontSize;
_Style.TextShadow = STextShadow(true);
_Style.Width = -1;
_Style.Height = -1;
_Style.BackgroundColor.A = 0;
if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE])
getStyleParams(value[MY_HTML_TEXTAREA_STYLE], _Style);
getStyleParams(value[MY_HTML_TEXTAREA_STYLE], _Style, _StyleParams.back());
// Got one form ?
if (!(_Forms.empty()))
@ -2509,7 +2596,7 @@ namespace NLGUI
pushStyle();
if (present[MY_HTML_TR_STYLE] && value[MY_HTML_TR_STYLE])
getStyleParams(value[MY_HTML_TR_STYLE], _Style);
getStyleParams(value[MY_HTML_TR_STYLE], _Style, _StyleParams.back());
}
break;
case HTML_UL:
@ -2526,7 +2613,7 @@ namespace NLGUI
pushStyle();
if (present[HTML_UL_STYLE] && value[HTML_UL_STYLE])
getStyleParams(value[HTML_UL_STYLE], _Style);
getStyleParams(value[HTML_UL_STYLE], _Style, _StyleParams.back());
break;
case HTML_OBJECT:
_ObjectType.clear();
@ -2549,7 +2636,7 @@ namespace NLGUI
pushStyle();
if (present[MY_HTML_SPAN_STYLE] && value[MY_HTML_SPAN_STYLE])
getStyleParams(value[MY_HTML_SPAN_STYLE], _Style);
getStyleParams(value[MY_HTML_SPAN_STYLE], _Style, _StyleParams.back());
}
break;
case HTML_DEL:
@ -2593,7 +2680,7 @@ namespace NLGUI
endParagraph();
pushStyle();
if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE])
getStyleParams(value[HTML_GEN_STYLE], _Style);
getStyleParams(value[HTML_GEN_STYLE], _Style, _StyleParams.back());
}
break;
case HTML_DT:
@ -2616,7 +2703,7 @@ namespace NLGUI
pushStyle();
_Style.FontWeight = FONT_WEIGHT_BOLD;
if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE])
getStyleParams(value[HTML_GEN_STYLE], _Style);
getStyleParams(value[HTML_GEN_STYLE], _Style, _StyleParams.back());
if (!_LI)
{
@ -2651,7 +2738,7 @@ namespace NLGUI
pushStyle();
if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE])
getStyleParams(value[HTML_GEN_STYLE], _Style);
getStyleParams(value[HTML_GEN_STYLE], _Style, _StyleParams.back());
if (!_LI)
{
@ -2675,7 +2762,7 @@ namespace NLGUI
if (present[HTML_OL_TYPE] && value[HTML_OL_TYPE])
type = value[HTML_OL_TYPE];
if (present[HTML_OL_STYLE] && value[HTML_OL_STYLE])
getStyleParams(value[HTML_OL_STYLE], _Style);
getStyleParams(value[HTML_OL_STYLE], _Style, _StyleParams.back());
_UL.push_back(HTMLOListElement(start, type));
// if LI is already present
@ -2692,12 +2779,13 @@ namespace NLGUI
if (sep)
{
CStyleParams style;
style.FontSize = _Style.FontSize;
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);
getStyleParams(value[HTML_HR_STYLE], style, _Style);
CViewBitmap *bitmap = dynamic_cast<CViewBitmap*>(sep->getView("hr"));
if (bitmap)
@ -2737,6 +2825,9 @@ namespace NLGUI
case HTML_HEAD:
_ReadingHeadTag = false;
break;
case HTML_BODY:
popStyle();
break;
case HTML_FONT:
popStyle();
break;
@ -4483,6 +4574,8 @@ namespace NLGUI
// Translate the tooltip
ctrlButton->setDefaultContextHelp(ucstring::makeFromUtf8(getLinkTitle()));
ctrlButton->setText(tmpStr);
setTextButtonStyle(ctrlButton, _Style);
}
getParagraph()->addChild (buttonGroup);
paragraphChange ();
@ -4505,23 +4598,10 @@ namespace NLGUI
}
}
newLink->setText(tmpStr);
newLink->setColor(_Style.TextColor);
newLink->setFontName(_Style.FontFamily);
newLink->setFontSize(_Style.FontSize);
newLink->setEmbolden(embolden);
newLink->setOblique(_Style.FontOblique);
newLink->setUnderlined(_Style.Underlined);
newLink->setStrikeThrough(_Style.StrikeThrough);
newLink->setMultiLineSpace((uint)((float)(_Style.FontSize)*LineSpaceFontFactor));
newLink->setMultiLine(true);
newLink->setModulateGlobalColor(_Style.GlobalColor);
if (_Style.TextShadow.Enabled)
{
newLink->setShadow(true);
newLink->setShadowColor(_Style.TextShadow.Color);
newLink->setShadowOutline(_Style.TextShadow.Outline);
newLink->setShadowOffset(_Style.TextShadow.X, _Style.TextShadow.Y);
}
setTextStyle(newLink, _Style);
// newLink->setLineAtBottom (true);
registerAnchor(newLink);
@ -4627,6 +4707,10 @@ namespace NLGUI
_CurrentViewLink = NULL;
{
// override cols/rows values from style
if (_Style.Width > 0) cols = _Style.Width / _Style.FontSize;
if (_Style.Height > 0) rows = _Style.Height / _Style.FontSize;
// Not added ?
std::vector<std::pair<std::string,std::string> > templateParams;
templateParams.push_back (std::pair<std::string,std::string> ("w", toString (cols*_Style.FontSize)));
@ -4664,7 +4748,18 @@ namespace NLGUI
// Set the content
CGroupEditBox *eb = dynamic_cast<CGroupEditBox*>(textArea->getGroup("eb"));
if (eb)
{
eb->setInputString(decodeHTMLEntities(content));
if (_Style.BackgroundColor.A > 0)
{
CViewBitmap *bg = dynamic_cast<CViewBitmap*>(eb->getView("bg"));
if (bg)
{
bg->setTexture("blank.tga");
bg->setColor(_Style.BackgroundColor);
}
}
}
textArea->invalidateCoords();
getParagraph()->addChild (textArea);
@ -4917,9 +5012,7 @@ namespace NLGUI
_IgnoreBaseUrlTag = false;
// reset style
_StyleDefault = CStyleParams();
_Style = _StyleDefault;
_StyleParams.clear();
resetCssStyle();
// TR
@ -6277,40 +6370,82 @@ namespace NLGUI
return uri.toString();
}
// ***************************************************************************
void CGroupHTML::resetCssStyle()
{
_StyleDefault = CStyleParams();
_StyleDefault.TextColor = TextColor;
_StyleDefault.FontSize = TextFontSize;
_StyleDefault.BackgroundColor = BgColor;
_Style = _StyleDefault;
_StyleParams.clear();
}
// ***************************************************************************
// CGroupHTML::CStyleParams style;
// style.FontSize; // font-size: 10px;
// style.TextColor; // color: #ABCDEF;
// style.Underlined; // text-decoration: underline; text-decoration-line: underline;
// style.StrikeThrough; // text-decoration: line-through; text-decoration-line: line-through;
void CGroupHTML::getStyleParams(const std::string &styleString, CStyleParams &style, bool inherit)
void CGroupHTML::getStyleParams(const std::string &styleString, CStyleParams &style, const CStyleParams &current)
{
const CStyleParams current = _Style;
if (inherit)
{
style.Underlined = current.Underlined;
style.StrikeThrough = current.StrikeThrough;
}
float tmpf;
TStyle styles = parseStyle(styleString);
TStyle::iterator it;
// first pass: get font-size for 'em' sizes
for (it=styles.begin(); it != styles.end(); ++it)
{
if (it->first == "font")
{
if (it->second == "inherit")
{
style.FontSize = current.FontSize;
style.FontFamily = current.FontFamily;
style.FontWeight = current.FontWeight;
style.FontOblique = current.FontOblique;
}
}
else
if (it->first == "font-size")
{
if (it->second == "inherit")
{
style.FontSize = current.FontSize;
}
else
{
float tmp;
sint size = 0;
getPercentage (size, tmp, it->second.c_str());
if (size > 0)
style.FontSize = size;
std::string unit;
if (getCssLength(tmpf, unit, it->second.c_str()))
{
if (unit == "rem")
style.FontSize = _StyleDefault.FontSize * tmpf;
else if (unit == "em")
style.FontSize = current.FontSize * tmpf;
else if (unit == "pt")
style.FontSize = tmpf / 0.75f;
else if (unit == "%")
style.FontSize = current.FontSize * tmpf / 100.f;
else
style.FontSize = tmpf;
}
}
}
}
// second pass: rest of style
for (it=styles.begin(); it != styles.end(); ++it)
{
if (it->first == "border")
{
sint32 b;
if (it->second == "none")
style.BorderWidth = 0;
else
if (fromString(it->second, b))
style.BorderWidth = b;
}
else
if (it->first == "font-style")
{
@ -6490,16 +6625,68 @@ namespace NLGUI
}
else
if (it->first == "width")
getPercentage(style.Width, tmpf, it->second.c_str());
{
std::string unit;
if (getCssLength(tmpf, unit, it->second.c_str()))
{
if (unit == "rem")
style.Width = tmpf * _StyleDefault.FontSize;
else if (unit == "em")
style.Width = tmpf * style.FontSize;
else if (unit == "pt")
style.FontSize = tmpf / 0.75f;
else
style.Width = tmpf;
}
}
else
if (it->first == "height")
getPercentage(style.Height, tmpf, it->second.c_str());
{
std::string unit;
if (getCssLength(tmpf, unit, it->second.c_str()))
{
if (unit == "rem")
style.Height = tmpf * _StyleDefault.FontSize;
else if (unit == "em")
style.Height = tmpf * style.FontSize;
else if (unit == "pt")
style.FontSize = tmpf / 0.75f;
else
style.Height = tmpf;
}
}
else
if (it->first == "max-width")
getPercentage(style.MaxWidth, tmpf, it->second.c_str());
{
std::string unit;
if (getCssLength(tmpf, unit, it->second.c_str()))
{
if (unit == "rem")
style.MaxWidth = tmpf * _StyleDefault.FontSize;
else if (unit == "em")
style.MaxWidth = tmpf * style.FontSize;
else if (unit == "pt")
style.FontSize = tmpf / 0.75f;
else
style.MaxWidth = tmpf;
}
}
else
if (it->first == "max-height")
getPercentage(style.MaxHeight, tmpf, it->second.c_str());
{
std::string unit;
if (getCssLength(tmpf, unit, it->second.c_str()))
{
if (unit == "rem")
style.MaxHeight = tmpf * _StyleDefault.FontSize;
else if (unit == "em")
style.MaxHeight = tmpf * style.FontSize;
else if (unit == "pt")
style.FontSize = tmpf / 0.75f;
else
style.MaxHeight = tmpf;
}
}
else
if (it->first == "-ryzom-modulate-color")
{
@ -6510,7 +6697,31 @@ namespace NLGUI
if (fromString(it->second, b))
style.GlobalColor = b;
}
else
if (it->first == "background-color")
{
if (it->second == "inherit")
style.BackgroundColor = current.BackgroundColor;
else
scanHTMLColor(it->second.c_str(), style.BackgroundColor);
}
else
if (it->first == "-ryzom-background-color-over")
{
if (it->second == "inherit")
style.BackgroundColorOver = current.BackgroundColorOver;
else
scanHTMLColor(it->second.c_str(), style.BackgroundColorOver);
}
}
// if outer element has underline set, then inner element cannot remove it
if (current.Underlined)
style.Underlined = current.Underlined;
// if outer element has line-through set, then inner element cannot remove it
if (current.StrikeThrough)
style.StrikeThrough = current.StrikeThrough;
}
// ***************************************************************************

@ -2561,6 +2561,12 @@ namespace NLGUI
}
}
// ------------------------------------------------------------------------------------------------
void CGroupMenu::setFontSize(uint fontSize)
{
_FontSize = fontSize;
}
// ------------------------------------------------------------------------------------------------
uint CGroupMenu::getNumLine() const
{

@ -47,6 +47,15 @@ namespace NLGUI
#undef HTML_ATTR
#define HTML_ATTR(a,b) { (char*) #b }
HTAttr html_attr[] =
{
HTML_ATTR(HTML,DIR),
HTML_ATTR(HTML,LANG),
HTML_ATTR(HTML,VERSION),
HTML_ATTR(HTML,STYLE),
{ 0 }
};
HTAttr a_attr[] =
{
HTML_ATTR(A,ACCESSKEY),
@ -284,6 +293,37 @@ namespace NLGUI
};
// ***************************************************************************
bool getCssLength (float &value, std::string &unit, const std::string &str)
{
std::string::size_type pos = 0;
std::string::size_type len = str.size();
if (len == 1 && str[0] == '.')
{
return false;
}
while(pos < len)
{
bool isNumeric = (str[pos] >= '0' && str[pos] <= '9')
|| (pos == 0 && str[pos] == '.')
|| (pos > 0 && str[pos] == '.' && str[pos-1] >= '0' && str[pos-1] <= '9');
if (!isNumeric)
{
break;
}
pos++;
}
unit = toLower(str.substr(pos));
if (unit == "%" || unit == "rem" || unit == "em" || unit == "px" || unit == "pt")
{
std::string tmpstr = str.substr(0, pos);
return fromString(tmpstr, value);
}
return false;
}
// Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false
bool getPercentage (sint32 &width, float &percent, const char *str)
@ -469,6 +509,8 @@ namespace NLGUI
// Change the HTML DTD
SGML_dtd *HTML_DTD = HTML_dtd ();
HTML_DTD->tags[HTML_HTML].attributes = html_attr;
HTML_DTD->tags[HTML_HTML].number_of_attributes = sizeof(html_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TABLE].attributes = table_attr;
HTML_DTD->tags[HTML_TABLE].number_of_attributes = sizeof(table_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TR].attributes = tr_attr;

@ -1096,23 +1096,21 @@ void prelogInit()
UDriver::CMode mode;
bool forceWindowed1024x768 = true;
if (Driver->getCurrentScreenMode(mode))
{
// if screen mode lower than 1024x768, use same mode in fullscreen
if (mode.Width <= 1024 && mode.Height <= 768)
// use current mode if its smaller than 1024x768
// mode should be windowed already, but incase its not, use the mode as is
if (mode.Windowed && (mode.Width > 1024 && mode.Height > 768))
{
mode.Windowed = false;
forceWindowed1024x768 = false;
mode.Width = 1024;
mode.Height = 768;
}
}
if (forceWindowed1024x768)
else
{
mode.Width = 1024;
mode.Height = 768;
mode.Windowed = true;
mode.Width = 1024;
mode.Height = 768;
mode.Windowed = true;
}
// Disable Hardware Vertex Program.

Loading…
Cancel
Save