aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/items
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2011-05-09 16:59:37 +0200
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>2011-05-09 17:31:03 +0200
commit4fb6ee7d258049237db33da30ee08f106ae490af (patch)
tree059836951a9a896d054fb91e506ef84c1e0dbca9 /src/declarative/items
parent2002baaf680a4dd4637bd400161e29e0c0a0dc47 (diff)
Fix Rectangle implementation.
Diffstat (limited to 'src/declarative/items')
-rw-r--r--src/declarative/items/qsgrectangle.cpp60
-rw-r--r--src/declarative/items/qsgrectangle_p.h17
2 files changed, 50 insertions, 27 deletions
diff --git a/src/declarative/items/qsgrectangle.cpp b/src/declarative/items/qsgrectangle.cpp
index cba6527759..e97abe3e1c 100644
--- a/src/declarative/items/qsgrectangle.cpp
+++ b/src/declarative/items/qsgrectangle.cpp
@@ -55,64 +55,82 @@ QT_BEGIN_NAMESPACE
// XXX todo - should we change rectangle to draw entirely within its width/height?
QSGPen::QSGPen(QObject *parent)
-: QObject(parent), _width(1), _color("#000000"), _valid(false)
+ : QObject(parent)
+ , m_width(1)
+ , m_color("#000000")
+ , m_aligned(true)
+ , m_valid(false)
{
}
+qreal QSGPen::width() const
+{
+ return m_width;
+}
+
+void QSGPen::setWidth(qreal w)
+{
+ if (m_width == w && m_valid)
+ return;
+
+ m_width = w;
+ m_valid = m_color.alpha() && (qRound(m_width) >= 1 || (!m_aligned && m_width > 0));
+ emit penChanged();
+}
+
QColor QSGPen::color() const
{
- return _color;
+ return m_color;
}
void QSGPen::setColor(const QColor &c)
{
- _color = c;
- _valid = (_color.alpha() && _width >= 1) ? true : false;
+ m_color = c;
+ m_valid = m_color.alpha() && (qRound(m_width) >= 1 || (!m_aligned && m_width > 0));
emit penChanged();
}
-int QSGPen::width() const
-{
- return _width;
+bool QSGPen::aligned() const
+{
+ return m_aligned;
}
-void QSGPen::setWidth(int w)
+void QSGPen::setAligned(bool aligned)
{
- if (_width == w && _valid)
+ if (aligned == m_aligned)
return;
-
- _width = w;
- _valid = (_color.alpha() && _width >= 1) ? true : false;
+ m_aligned = aligned;
+ m_valid = m_color.alpha() && (qRound(m_width) >= 1 || (!m_aligned && m_width > 0));
emit penChanged();
}
bool QSGPen::isValid() const
{
- return _valid;
+ return m_valid;
}
QSGGradientStop::QSGGradientStop(QObject *parent)
-: QObject(parent)
+ : QObject(parent)
{
}
qreal QSGGradientStop::position() const
-{
+{
return m_position;
}
void QSGGradientStop::setPosition(qreal position)
-{
+{
m_position = position; updateGradient();
}
QColor QSGGradientStop::color() const
-{
+{
return m_color;
}
void QSGGradientStop::setColor(const QColor &color)
-{
+{
m_color = color; updateGradient();
}
@@ -128,12 +146,12 @@ QSGGradient::QSGGradient(QObject *parent)
}
QSGGradient::~QSGGradient()
-{
+{
delete m_gradient;
}
QDeclarativeListProperty<QSGGradientStop> QSGGradient::stops()
-{
+{
return QDeclarativeListProperty<QSGGradientStop>(this, m_stops);
}
@@ -257,8 +275,8 @@ QSGNode *QSGRectangle::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *da
if (d->pen && d->pen->isValid()) {
rectangle->setPenColor(d->pen->color());
rectangle->setPenWidth(d->pen->width());
+ rectangle->setAligned(d->pen->aligned());
} else {
- rectangle->setPenColor(QColor());
rectangle->setPenWidth(0);
}
diff --git a/src/declarative/items/qsgrectangle_p.h b/src/declarative/items/qsgrectangle_p.h
index 6cd5172f35..6157d82442 100644
--- a/src/declarative/items/qsgrectangle_p.h
+++ b/src/declarative/items/qsgrectangle_p.h
@@ -58,26 +58,31 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QSGPen : public QObject
{
Q_OBJECT
- Q_PROPERTY(int width READ width WRITE setWidth NOTIFY penChanged)
+ Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY penChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY penChanged)
+ Q_PROPERTY(bool aligned READ aligned WRITE setAligned NOTIFY penChanged)
public:
QSGPen(QObject *parent=0);
- int width() const;
- void setWidth(int w);
+ qreal width() const;
+ void setWidth(qreal w);
QColor color() const;
void setColor(const QColor &c);
+ bool aligned() const;
+ void setAligned(bool aligned);
+
bool isValid() const;
Q_SIGNALS:
void penChanged();
private:
- int _width;
- QColor _color;
- bool _valid;
+ qreal m_width;
+ QColor m_color;
+ bool m_aligned : 1;
+ bool m_valid : 1;
};
class Q_AUTOTEST_EXPORT QSGGradientStop : public QObject