diff --git a/nel/include/nel/gui/css_background.h b/nel/include/nel/gui/css_background.h
new file mode 100644
index 000000000..87ce87d0e
--- /dev/null
+++ b/nel/include/nel/gui/css_background.h
@@ -0,0 +1,83 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010-2019 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#ifndef CL_CSS_BACKGROUND_H
+#define CL_CSS_BACKGROUND_H
+
+#include "nel/misc/types_nl.h"
+#include "nel/misc/rgba.h"
+#include "nel/gui/css_types.h"
+#include "nel/gui/css_length.h"
+
+namespace NLGUI
+{
+ /**
+ * \brief CSS background info
+ * \date 2021-07-02 11:36 GMT
+ * \author Meelis Mägi (Nimetu)
+ */
+ class CSSBackground
+ {
+ public:
+ CSSBackground()
+ :color(NLMISC::CRGBA::Transparent),
+ repeatX(CSS_VALUE_REPEAT), repeatY(CSS_VALUE_REPEAT), attachment(CSS_VALUE_SCROLL),
+ xAnchor(CSS_VALUE_LEFT), yAnchor(CSS_VALUE_TOP),
+ clip(CSS_VALUE_BORDER_BOX), origin(CSS_VALUE_PADDING_BOX), size(CSS_VALUE_AUTO)
+ {}
+
+ void setImage(const std::string &value);
+ void setPosition(const std::string &value);
+ void setSize(const std::string &value);
+ void setRepeat(const std::string &value);
+ void setOrigin(const std::string &value);
+ void setClip(const std::string &value);
+ void setAttachment(const std::string &value);
+ void setColor(const std::string &value);
+
+ public:
+ // TODO: only final layer has color
+ NLMISC::CRGBA color;
+ std::string image;
+
+ CSSValueType repeatX;
+ CSSValueType repeatY;
+ CSSValueType attachment;
+
+ CSSValueType xAnchor;
+ CSSValueType yAnchor;
+ CSSLength xPosition;
+ CSSLength yPosition;
+
+ CSSValueType clip;
+ CSSValueType origin;
+
+ CSSValueType size;
+ CSSLength width;
+ CSSLength height;
+
+ private:
+ void positionFromOne(const std::vector &parts);
+ void positionFromTwo(const std::vector &parts);
+ void positionFromThree(const std::vector &parts);
+ void positionFromFour(const std::vector &parts);
+ };
+
+}//namespace
+
+#endif // CL_CSS_BACKGROUND_H
+
+
diff --git a/nel/include/nel/gui/css_background_renderer.h b/nel/include/nel/gui/css_background_renderer.h
new file mode 100644
index 000000000..86b31cb3d
--- /dev/null
+++ b/nel/include/nel/gui/css_background_renderer.h
@@ -0,0 +1,193 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010-2019 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+
+#ifndef NL_CSS_BACKGROUND_RENDERER_H
+#define NL_CSS_BACKGROUND_RENDERER_H
+
+#include "nel/misc/types_nl.h"
+#include "nel/misc/rgba.h"
+#include "nel/misc/geom_ext.h"
+#include "nel/gui/css_types.h"
+#include "nel/gui/css_background.h"
+
+namespace NLGUI
+{
+class CInterfaceElement;
+
+/**
+ * \brief Border renderer for GUI classes
+ * \date 2021-06-29 15:17 GMT
+ * \author Meelis Mägi (Nimetu)
+ */
+class CSSBackgroundRenderer
+{
+public:
+ // alpha value from parent
+ uint8 CurrentAlpha;
+
+ // TODO: should be moved to CSSBackground
+ sint32 TextureId;
+
+public:
+ CSSBackgroundRenderer();
+ ~CSSBackgroundRenderer();
+
+ // return true if no background is set
+ bool isEmpty() const
+ {
+ return m_Background.image.empty() && m_Background.color.A == 0;
+ }
+
+ void setModulateGlobalColor(bool m) { m_ModulateGlobalColor = m; }
+
+ void updateCoords();
+ void invalidateCoords() { m_Dirty = true; }
+ void invalidateContent() { m_Dirty = true; };
+
+ void clear();
+ void setBackground(const CSSBackground &bg);
+
+ // helper function to change background image
+ void setImage(const std::string &bgtex);
+ void setImageRepeat(bool b);
+ void setImageCover(bool b);
+
+ // helper function to change background color
+ void setColor(const NLMISC::CRGBA &color)
+ {
+ m_Dirty = true;
+ m_Background.color = color;
+ }
+
+ NLMISC::CRGBA getColor() const
+ {
+ return m_Background.color;
+ }
+
+ // override painting area to be at least the size of viewport (ie, background)
+ void setFillViewport(bool b) {
+ m_Dirty = true;
+ m_FillViewport = b;
+ }
+
+ void setViewport(CInterfaceElement *root)
+ {
+ m_Dirty = true;
+ m_Viewport = root;
+ }
+
+ void setBorderArea(sint32 x, sint32 y, sint32 w, sint32 h)
+ {
+ m_Dirty = true;
+ m_BorderX = x;
+ m_BorderY = y;
+ m_BorderW = w;
+ m_BorderH = h;
+ }
+
+ void setPaddingArea(sint32 x, sint32 y, sint32 w, sint32 h)
+ {
+ m_Dirty = true;
+ m_PaddingX = x;
+ m_PaddingY = y;
+ m_PaddingW = w;
+ m_PaddingH = h;
+ }
+
+ void setContentArea(sint32 x, sint32 y, sint32 w, sint32 h)
+ {
+ m_Dirty = true;
+ m_ContentX = x;
+ m_ContentY = y;
+ m_ContentW = w;
+ m_ContentH = h;
+ }
+
+ // sizes for em, rem units
+ void setFontSize(float rootFontSize, float fontSize)
+ {
+ m_Dirty = true;
+ m_RootFontSize = rootFontSize;
+ m_FontSize = fontSize;
+ }
+
+ void draw();
+
+private:
+ sint32 m_BorderX, m_BorderY, m_BorderW, m_BorderH;
+ sint32 m_PaddingX, m_PaddingY, m_PaddingW, m_PaddingH;
+ sint32 m_ContentX, m_ContentY, m_ContentW, m_ContentH;
+
+ // font size for 'rem'
+ float m_RootFontSize;
+
+ // font size for 'em'
+ float m_FontSize;
+
+ // viewport element for vw,wh,vmin,vmax
+ CInterfaceElement* m_Viewport;
+
+ struct SDrawQueue
+ {
+ sint32 TextureId;
+ NLMISC::CQuadUV Quad;
+ NLMISC::CRGBA Color;
+ };
+ std::vector m_DrawQueue;
+
+ const sint8 m_RenderLayer;
+ bool m_ModulateGlobalColor;
+ // if true, painting area returns area at least the size of viewport (ie, background)
+ bool m_FillViewport;
+
+ // if true, then updateCoords() is called from draw()
+ bool m_Dirty;
+
+ CSSBackground m_Background;
+
+ // get clip area based on background-clip
+ void getPaintingArea(const CSSBackground &bg, sint32 &areaX, sint32 &areaY, sint32 &areaW, sint32 &areaH) const;
+
+ // get positioning area based on background-origin
+ void getPositioningArea(const CSSBackground &bg, sint32 &areaX, sint32 &areaY, sint32 &areaW, sint32 &areaH) const;
+
+ // calculate image size based on background-size
+ void calculateSize(const CSSBackground &bg, sint32 &texW, sint32 &texH) const;
+
+ // calculate image position based on background-position
+ void calculatePosition(const CSSBackground &bg, sint32 &texX, sint32 &texY, sint32 &texW, sint32 &texH) const;
+
+ // calculate image tile position, size, count, and spacing based on background-repeat
+ void calculateTiles(const CSSBackground &bg, sint32 &texX, sint32 &texY, sint32 &texW, sint32 &texH, sint32 &tilesX, sint32 &tilesY, sint32 &spacingX, sint32 &spacingY) const;
+
+ // position, size, and count for first tile to cover an area
+ void getImageTile(sint32 &tilePos, sint32 &tileSize, sint32 &spacing, sint32 &tiles, sint32 areaPos, sint32 areaSize, CSSValueType repeat) const;
+
+ // push background color to draw queue
+ void buildColorQuads(const CSSBackground &bg);
+
+ // push background image to draw quque
+ void buildImageQuads(const CSSBackground &bg, sint32 textureId);
+
+}; // CSSBackgroundRenderer
+
+}//namespace
+
+#endif // NL_CSS_BACKGROUND_RENDERER_H
+
+
diff --git a/nel/include/nel/gui/css_border.h b/nel/include/nel/gui/css_border.h
new file mode 100644
index 000000000..787b71710
--- /dev/null
+++ b/nel/include/nel/gui/css_border.h
@@ -0,0 +1,72 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010-2019 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#ifndef CL_CSS_BORDER_H
+#define CL_CSS_BORDER_H
+
+#include "nel/misc/types_nl.h"
+#include "nel/misc/rgba.h"
+#include "nel/gui/css_types.h"
+#include "nel/gui/css_length.h"
+
+namespace NLGUI
+{
+ /**
+ * \brief CSS border info
+ * \date 2021-07-23 09:51 GMT
+ * \author Meelis Mägi (Nimetu)
+ */
+ class CSSBorder
+ {
+ public:
+ CSSBorder()
+ {
+ reset();
+ }
+
+ CSSBorder(uint width, CSSLineStyle style, NLMISC::CRGBA color)
+ {
+ set(width, style, color);
+ }
+
+ void reset()
+ {
+ set(CSS_LINE_WIDTH_MEDIUM, CSS_LINE_STYLE_NONE, NLMISC::CRGBA::Transparent);
+ }
+
+ void set(uint width, CSSLineStyle style, NLMISC::CRGBA color)
+ {
+ Width.setFloatValue(width, "px");
+ Style = style;
+ Color = color;
+ }
+
+ bool empty() const
+ {
+ return Style == CSS_LINE_STYLE_NONE || Style == CSS_LINE_STYLE_HIDDEN
+ || Width.getFloat() == 0;
+ }
+
+ CSSLength Width;
+ CSSLineStyle Style;
+ NLMISC::CRGBA Color;
+ };
+
+}//namespace
+
+#endif // CL_CSS_BORDER_H
+
+
diff --git a/nel/include/nel/gui/css_border_renderer.h b/nel/include/nel/gui/css_border_renderer.h
index 1c5db47d4..54505a686 100644
--- a/nel/include/nel/gui/css_border_renderer.h
+++ b/nel/include/nel/gui/css_border_renderer.h
@@ -23,9 +23,12 @@
#include "nel/misc/rgba.h"
#include "nel/misc/geom_ext.h"
#include "nel/gui/css_types.h"
+#include "nel/gui/css_border.h"
namespace NLGUI
{
+ class CInterfaceElement;
+
/**
* \brief Border renderer for GUI classes
* \date 2019-09-03 10:50 GMT
@@ -34,29 +37,76 @@ namespace NLGUI
class CSSBorderRenderer
{
private:
+ enum EBorderSide
+ {
+ BORDER_TOP_LEFT = 0,
+ BORDER_TOP_RIGHT,
+ BORDER_BOTTOM_LEFT,
+ BORDER_BOTTOM_RIGHT,
+ BORDER_LEFT_TOP,
+ BORDER_RIGHT_TOP,
+ BORDER_LEFT_BOTTOM,
+ BORDER_RIGHT_BOTTOM,
+ BORDER_TOP,
+ BORDER_RIGHT,
+ BORDER_BOTTOM,
+ BORDER_LEFT,
+ BORDER_INVALID
+ };
// parent element screen coordinates
- sint32 _XReal, _YReal;
- sint32 _WReal, _HReal;
+ sint32 m_XReal, m_YReal;
+ sint32 m_WReal, m_HReal;
- NLMISC::CQuadUV _QuadT;
- NLMISC::CQuadUV _QuadR;
- NLMISC::CQuadUV _QuadB;
- NLMISC::CQuadUV _QuadL;
+ struct SDrawBorder
+ {
+ NLMISC::CQuadUV Quad;
+ NLMISC::CRGBA Color;
+ };
+ std::vector m_DrawBorders;
- uint8 _RenderLayer;
- bool _ModulateGlobalColor;
+ sint8 m_RenderLayer;
+ bool m_ModulateGlobalColor;
// if true, then updateCoords() is called from draw()
- bool _Dirty;
- // if true, then at least one border is set
- bool _Border;
- bool _BorderTop, _BorderRight, _BorderBottom, _BorderLeft;
+ bool m_Dirty;
+ // UI scale, used to calculate number of segments to draw for circle
+ float m_Scale;
- public:
- uint32 TopWidth, RightWidth, BottomWidth, LeftWidth;
- NLMISC::CRGBA TopColor, RightColor, BottomColor, LeftColor;
- CSSLineStyle TopStyle, RightStyle, BottomStyle, LeftStyle;
+ CSSRect m_Border;
+ CSSRect m_Computed;
+
+ // font size for 'rem'
+ float m_RootFontSize;
+
+ // font size for 'em'
+ float m_FontSize;
+
+ // if true, then CSSLength values are recomputed
+ bool m_MustComputeValues;
+
+ // viewport element for vw,wh,vmin,vmax
+ CInterfaceElement* m_Viewport;
+ // update CSSLength values
+ void computeValues();
+
+ void getAdjacentBorders(EBorderSide side, EBorderSide &adjBorderL, EBorderSide &adjBorderR) const;
+ void getAdjacentBorderWidth(EBorderSide side, sint32 &adjWidthL, sint32 &adjWidthR) const;
+ // dot
+ void buildDotCornerStart(EBorderSide side, SDrawBorder shape, float x1, float y1, float radius);
+ void buildDotCornerEnd(EBorderSide side, SDrawBorder shape, float x1, float y1, float radius);
+ void buildDotCorner(SDrawBorder shape, float x, float y, float r, const NLMISC::CLine &line);
+ // draw circle, angle is CCW between 0..1 (3'o'clock being 0deg).
+ void buildDotSegments(SDrawBorder shape, float x, float y, float radius, float fromAngle=0.f, float toAngle=1.f);
+ // dash
+ void makeBorderQuad(EBorderSide side, SDrawBorder &shape, float x, float y, float width, float thickness) const;
+ void makeCornerQuad(EBorderSide side, SDrawBorder &shape) const;
+ void buildDashedBorder(EBorderSide side);
+ void buildSolidBorder(EBorderSide side);
+
+ bool hasInnerShape(CSSLineStyle style) const;
+
+ public:
// alpha value from parent
uint8 CurrentAlpha;
@@ -68,21 +118,67 @@ namespace NLGUI
void setRect(sint32 x, sint32 y, sint32 w, sint32 h);
- void setWidth(uint32 top, uint32 right, uint32 bottom, uint32 left);
- void setStyle(CSSLineStyle top, CSSLineStyle right, CSSLineStyle bottom, CSSLineStyle left);
- void setColor(const NLMISC::CRGBA &top, const NLMISC::CRGBA &right, const NLMISC::CRGBA &bottom, const NLMISC::CRGBA &left);
+ void setBorder(const CSSRect &b) { m_Dirty = true; m_Border = b; }
void updateCoords();
- void invalidateCoords() { _Dirty = _Border = true; }
- void invalidateContent() { _Dirty = _Border = true; };
-
- uint32 getTopWidth() const;
- uint32 getRightWidth() const;
- uint32 getBottomWidth() const;
- uint32 getLeftWidth() const;
-
- uint32 getLeftRightWidth() const;
- uint32 getTopBottomWidth() const;
+ void invalidateCoords() { m_Dirty = true; }
+ void invalidateContent() { m_Dirty = true; }
+
+ bool isEmpty() const {
+ return (m_Border.Top.Width.getFloat() +
+ m_Border.Right.Width.getFloat() +
+ m_Border.Bottom.Width.getFloat() +
+ m_Border.Left.Width.getFloat()) == 0;
+ }
+
+ uint32 getTopWidth() { if (m_MustComputeValues) computeValues(); return m_Computed.Top; }
+ uint32 getRightWidth() { if (m_MustComputeValues) computeValues(); return m_Computed.Right; }
+ uint32 getBottomWidth() { if (m_MustComputeValues) computeValues(); return m_Computed.Bottom; }
+ uint32 getLeftWidth() { if (m_MustComputeValues) computeValues(); return m_Computed.Left; }
+
+ uint32 getLeftRightWidth() { if (m_MustComputeValues) computeValues(); return m_Computed.Left + m_Computed.Right; }
+ uint32 getTopBottomWidth() { if (m_MustComputeValues) computeValues(); return m_Computed.Top + m_Computed.Bottom; }
+
+ NLMISC::CRGBA getTopColor() const { return m_Border.Top.Color; }
+ NLMISC::CRGBA getRightColor() const { return m_Border.Right.Color; }
+ NLMISC::CRGBA getBottomColor() const { return m_Border.Bottom.Color; }
+ NLMISC::CRGBA getLeftColor() const { return m_Border.Left.Color; }
+
+
+ void setWidth(uint width)
+ {
+ m_Dirty = true;
+ m_MustComputeValues = true;
+ m_Border.Top.Width.setFloatValue(width, "px");
+ m_Border.Right.Width.setFloatValue(width, "px");
+ m_Border.Bottom.Width.setFloatValue(width, "px");
+ m_Border.Left.Width.setFloatValue(width, "px");
+ }
+
+ void setColor(const NLMISC::CRGBA &color)
+ {
+ m_Dirty = true;
+ m_Border.Top.Color = color;
+ m_Border.Right.Color = color;
+ m_Border.Bottom.Color = color;
+ m_Border.Left.Color = color;
+ }
+
+ // sizes for em, rem units
+ void setFontSize(float rootFontSize, float fontSize)
+ {
+ m_Dirty = true;
+ m_MustComputeValues = true;
+ m_RootFontSize = rootFontSize;
+ m_FontSize = fontSize;
+ }
+
+ void setViewport(CInterfaceElement *root)
+ {
+ m_Dirty = true;
+ m_MustComputeValues = true;
+ m_Viewport = root;
+ }
void draw();
}; // CSSBorderRenderer
diff --git a/nel/include/nel/gui/css_length.h b/nel/include/nel/gui/css_length.h
new file mode 100644
index 000000000..d7b8c657b
--- /dev/null
+++ b/nel/include/nel/gui/css_length.h
@@ -0,0 +1,76 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010-2021 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#ifndef CL_CSS_LENGTH_H
+#define CL_CSS_LENGTH_H
+
+#include "nel/misc/types_nl.h"
+#include "nel/gui/css_types.h"
+
+namespace NLGUI
+{
+ /**
+ * \brief CSS types used in GUI classes
+ * \date 2021-07-02 11:36 GMT
+ * \author Meelis Mägi (Nimetu)
+ */
+
+ class CSSLength
+ {
+ public:
+ enum Kind {
+ Auto, Relative, Fixed
+ };
+
+ CSSLength(float value = 0, CSSUnitType unit = CSS_UNIT_NONE, Kind kind = Auto)
+ : m_Value(value), m_Unit(unit), m_Kind(Auto)
+ {}
+
+ void setAuto() { m_Kind = Auto; }
+ bool parseValue(const std::string &value, bool allowPercent = true, bool allowNegative = false);
+ void setFloatValue(float f, const std::string &unit);
+
+ float getValue() const;
+ float getFloat() const { return m_Value; }
+
+ bool isPercent() const { return m_Unit == CSS_UNIT_PERCENT; }
+
+ bool isAuto() const { return m_Kind == Auto; }
+ bool isRelative() const { return m_Kind == Relative; }
+
+ // % uses relValue
+ // em uses emSize
+ // rem uses remSize
+ // vw,vh,vi,vb,vmin,vmax uses vwSize/vhSize
+ float calculate(uint32 relValue, uint32 emSize, uint32 remSize, uint32 vwSize, uint32 whSize) const;
+
+ CSSUnitType getUnit() const { return m_Unit; }
+
+ std::string toString() const;
+
+ private:
+ void setUnit(const std::string &unit);
+
+ float m_Value;
+ CSSUnitType m_Unit;
+ Kind m_Kind;
+ };
+
+}//namespace
+
+#endif // CL_CSS_LENGTH_H
+
+
diff --git a/nel/include/nel/gui/css_style.h b/nel/include/nel/gui/css_style.h
index 7a1d11ee5..042486d17 100644
--- a/nel/include/nel/gui/css_style.h
+++ b/nel/include/nel/gui/css_style.h
@@ -21,6 +21,9 @@
#include "nel/misc/rgba.h"
#include "nel/gui/css_selector.h"
#include "nel/gui/css_types.h"
+#include "nel/gui/css_length.h"
+#include "nel/gui/css_background.h"
+#include "nel/gui/css_border.h"
namespace NLGUI
{
@@ -65,13 +68,9 @@ namespace NLGUI
Height=-1;
MaxWidth=-1;
MaxHeight=-1;
- // border style
- BorderTopWidth = BorderRightWidth = BorderBottomWidth = BorderLeftWidth = CSS_LINE_WIDTH_MEDIUM;
- BorderTopStyle = BorderRightStyle = BorderBottomStyle = BorderLeftStyle = CSS_LINE_STYLE_NONE;
- BorderTopColor = BorderRightColor = BorderBottomColor = BorderLeftColor = NLMISC::CRGBA::Transparent;
// background
- BackgroundColor=NLMISC::CRGBA::Black;
BackgroundColorOver=NLMISC::CRGBA::Black;
+ MarginTop = MarginRight = MarginBottom = MarginLeft = 0;
PaddingTop = PaddingRight = PaddingBottom = PaddingLeft = 0;
}
@@ -101,11 +100,10 @@ namespace NLGUI
sint32 Height;
sint32 MaxWidth;
sint32 MaxHeight;
- uint32 BorderTopWidth, BorderRightWidth, BorderBottomWidth, BorderLeftWidth;
- CSSLineStyle BorderTopStyle, BorderRightStyle, BorderBottomStyle, BorderLeftStyle;
- NLMISC::CRGBA BorderTopColor, BorderRightColor, BorderBottomColor, BorderLeftColor;
- NLMISC::CRGBA BackgroundColor;
+ CSSRect Border;
+ CSSBackground Background;
NLMISC::CRGBA BackgroundColorOver;
+ uint32 MarginTop, MarginRight, MarginBottom, MarginLeft;
uint32 PaddingTop, PaddingRight, PaddingBottom, PaddingLeft;
std::string WhiteSpace;
@@ -177,16 +175,18 @@ namespace NLGUI
// parse 'padding' into 'padding-top', 'padding-left', etc
void expandPaddingShorthand(const std::string &value, TStyle &style) const;
+ void expandMarginShorthand(const std::string &value, TStyle &style) const;
// expand shorthand rule, ie "border", into longhand names, ie "border-top-width"
// if shorthand is present in style, then its removed
void expandShorthand(const std::string &prop, const std::string &value, TStyle &style) const;
// parse string value into corresponding value
- void applyBorderWidth(const std::string &value, uint32 *dest, const uint32 currentWidth, const uint32 fontSize) const;
+ void applyBorderWidth(const std::string &value, CSSLength *dest, const CSSLength ¤tWidth) const;
void applyBorderColor(const std::string &value, NLMISC::CRGBA *dest, const NLMISC::CRGBA ¤tColor, const NLMISC::CRGBA &textColor) const;
void applyLineStyle(const std::string &value, CSSLineStyle *dest, const CSSLineStyle ¤tStyle) const;
void applyPaddingWidth(const std::string &value, uint32 *dest, const uint32 currentPadding, uint32 fontSize) const;
+ void applyMarginWidth(const std::string &value, uint32 *dest, const uint32 current, uint32 fontSize) const;
// parse and replace var(--name, fallback) function
// return false if property should be ignored
@@ -221,9 +221,15 @@ namespace NLGUI
Current.MaxWidth=-1;
Current.MaxHeight=-1;
- Current.BorderTopWidth = Current.BorderRightWidth = Current.BorderBottomWidth = Current.BorderLeftWidth = CSS_LINE_WIDTH_MEDIUM;
- Current.BorderTopStyle = Current.BorderRightStyle = Current.BorderBottomStyle = Current.BorderLeftStyle = CSS_LINE_STYLE_NONE;
- Current.BorderTopColor = Current.BorderRightColor = Current.BorderBottomColor = Current.BorderLeftColor = Current.TextColor;
+ Current.Border.Top.reset();
+ Current.Border.Right.reset();
+ Current.Border.Bottom.reset();
+ Current.Border.Left.reset();
+
+ Current.Background = CSSBackground();
+ Current.BackgroundColorOver = NLMISC::CRGBA::Transparent;
+
+ Current.MarginTop = Current.MarginRight = Current.MarginBottom = Current.MarginLeft = 0;
Current.PaddingTop = Current.PaddingRight = Current.PaddingBottom = Current.PaddingLeft = 0;
Current.StyleRules.clear();
diff --git a/nel/include/nel/gui/css_types.h b/nel/include/nel/gui/css_types.h
index fd526858e..172c21d18 100644
--- a/nel/include/nel/gui/css_types.h
+++ b/nel/include/nel/gui/css_types.h
@@ -30,7 +30,12 @@ namespace NLGUI
enum CSSLineStyle {
CSS_LINE_STYLE_NONE = 0,
CSS_LINE_STYLE_HIDDEN,
+ CSS_LINE_STYLE_DOTTED,
+ CSS_LINE_STYLE_DASHED,
CSS_LINE_STYLE_SOLID,
+ CSS_LINE_STYLE_DOUBLE,
+ CSS_LINE_STYLE_GROOVE,
+ CSS_LINE_STYLE_RIDGE,
CSS_LINE_STYLE_INSET,
CSS_LINE_STYLE_OUTSET
};
@@ -42,6 +47,53 @@ namespace NLGUI
CSS_LINE_WIDTH_THICK = 5
};
+ enum CSSUnitType {
+ CSS_UNIT_NONE = 0,
+ CSS_UNIT_EM,
+ CSS_UNIT_REM,
+ CSS_UNIT_PERCENT,
+ CSS_UNIT_PX,
+ CSS_UNIT_PT,
+ CSS_UNIT_VW,
+ CSS_UNIT_VH,
+ CSS_UNIT_VI,
+ CSS_UNIT_VB,
+ CSS_UNIT_VMIN,
+ CSS_UNIT_VMAX
+ };
+
+ enum CSSValueType {
+ CSS_VALUE_NONE = 0,
+ CSS_VALUE_REPEAT,
+ CSS_VALUE_SPACE,
+ CSS_VALUE_ROUND,
+ CSS_VALUE_NOREPEAT,
+ CSS_VALUE_FIXED,
+ CSS_VALUE_LOCAL,
+ CSS_VALUE_SCROLL,
+ CSS_VALUE_LEFT,
+ CSS_VALUE_CENTER,
+ CSS_VALUE_RIGHT,
+ CSS_VALUE_TOP,
+ CSS_VALUE_BOTTOM,
+ CSS_VALUE_BORDER_BOX,
+ CSS_VALUE_PADDING_BOX,
+ CSS_VALUE_CONTENT_BOX,
+ CSS_VALUE_LENGTH,
+ CSS_VALUE_AUTO,
+ CSS_VALUE_COVER,
+ CSS_VALUE_CONTAIN
+ };
+
+ template
+ struct CSSRect
+ {
+ T Top;
+ T Right;
+ T Bottom;
+ T Left;
+ };
+
}//namespace
#endif // CL_CSS_TYPES_H
diff --git a/nel/include/nel/gui/group_html.h b/nel/include/nel/gui/group_html.h
index bb75624ff..31c85c4cd 100644
--- a/nel/include/nel/gui/group_html.h
+++ b/nel/include/nel/gui/group_html.h
@@ -30,6 +30,7 @@
#include "nel/gui/html_element.h"
#include "nel/gui/html_parser.h"
#include "nel/gui/css_style.h"
+#include "nel/gui/css_background_renderer.h"
// forward declaration
typedef void CURLM;
@@ -47,6 +48,20 @@ namespace NLGUI
extern std::string CurrentCookie;
+ class ICurlDownloadCB
+ {
+ public:
+ ICurlDownloadCB(const std::string &url)
+ : url(url)
+ {}
+
+ virtual ~ICurlDownloadCB() {};
+
+ virtual void finish() = 0;
+
+ std::string url;
+ };
+
// HTML group
/**
* Widget to have a resizable scrolltext and its scrollbar
@@ -136,9 +151,9 @@ namespace NLGUI
void endParagraph();
// add image download (used by view_bitmap.cpp to load web images)
- void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage, const std::string &placeholder = "web_del.tga");
- // remove image from download list if present
- void removeImageDownload(CViewBase *img);
+ ICurlDownloadCB *addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage, const std::string &placeholder = "web_del.tga");
+ ICurlDownloadCB *addTextureDownload(const std::string &url, sint32 &texId, CViewBase *view);
+ void removeImageDownload(ICurlDownloadCB *handle, CViewBase *img);
std::string localImageName(const std::string &url);
// Timeout
@@ -168,6 +183,7 @@ namespace NLGUI
std::string DefaultRadioButtonBitmapNormal;
std::string DefaultRadioButtonBitmapPushed;
std::string DefaultRadioButtonBitmapOver;
+ // TODO: remove from interface xml and code
std::string DefaultBackgroundBitmapView;
struct TFormField {
@@ -332,6 +348,9 @@ namespace NLGUI
const std::string &overBitmap, const char *actionHandler, const char *actionHandlerParams, const std::string &tooltip,
const CStyleParams &style = CStyleParams());
+ // Set the background color
+ void setupBackground(CSSBackgroundRenderer *bg);
+
// Set the background color
void setBackgroundColor (const NLMISC::CRGBA &bgcolor);
@@ -371,6 +390,10 @@ namespace NLGUI
//