10#include <QDomDocument>
56 int alphaMod, QRect clipRect)
65 area.translate(xoffset, yoffset);
67 p->SetClipRect(clipRect);
70 else if (
m_type ==
"roundbox")
72 else if (
m_type ==
"ellipse")
80 const QString &
filename, QDomElement &element,
bool showWarnings)
82 if (element.tagName() ==
"type")
86 if (
type ==
"box" ||
type ==
"roundbox" ||
type ==
"ellipse")
89 else if (element.tagName() ==
"fill")
91 QString style = element.attribute(
"style",
"solid");
92 QString color = element.attribute(
"color",
"");
93 int alpha = element.attribute(
"alpha",
"255").toInt();
95 if (style ==
"solid" && !color.isEmpty())
98 auto brushColor = QColor(color);
99 brushColor.setAlpha(alpha);
102 else if (style ==
"gradient")
104 for (QDomNode child = element.firstChild(); !child.isNull();
105 child = child.nextSibling())
107 QDomElement childElem = child.toElement();
109 if (childElem.tagName() ==
"gradient")
118 else if (element.tagName() ==
"line")
120 QString style = element.attribute(
"style",
"solid");
121 QString color = element.attribute(
"color",
"");
123 if (style ==
"solid" && !color.isEmpty())
125 int orig_width = element.attribute(
"width",
"1").toInt();
126 int width = (orig_width) ? std::max(
NormX(orig_width), 1) : 0;
127 int alpha = element.attribute(
"alpha",
"255").toInt();
128 auto lineColor = QColor(color);
129 lineColor.setAlpha(alpha);
139 else if (element.tagName() ==
"cornerradius")
160 LOG(VB_GENERAL, LOG_ERR,
"ERROR, bad parsing");
178 auto *shape =
new MythUIShape(parent, objectName());
179 shape->CopyFrom(
this);
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
void CalculateArea(QRect parentArea)
QRect toQRect(void) const
A widget for rendering primitive shapes and lines.
void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect) override
void SetFillBrush(QBrush fill)
MythUIShape(MythUIType *parent, const QString &name)
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
void SetLinePen(QPen pen)
void SetCropRect(int x, int y, int width, int height)
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings) override
Parse the xml definition of this widget setting the state of the object accordingly.
The base class on which all widgets and screens are based.
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
int CalcAlpha(int alphamod) const
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.
static int NormX(int width)
static QBrush parseGradient(const QDomElement &element)
static QString getFirstText(QDomElement &element)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)