7#include <QtQml/qqmlinfo.h>
9#include <QtQuick/private/qsgcontext_p.h>
10#include <private/qsgadaptationlayer_p.h>
12#include <private/qqmlmetatype_p.h>
14#include <QtGui/qpixmapcache.h>
15#include <QtCore/qmath.h>
16#include <QtCore/qmetaobject.h>
56 if (m_width ==
w && m_valid)
60 m_valid = m_color.
alpha() && (
qRound(m_width) >= 1 || (!m_aligned && m_width > 0));
73 m_valid = m_color.
alpha() && (
qRound(m_width) >= 1 || (!m_aligned && m_width > 0));
88 m_valid = m_color.
alpha() && (
qRound(m_width) >= 1 || (!m_aligned && m_width > 0));
131 m_position =
position; updateGradient();
141 m_color =
color; updateGradient();
144void QQuickGradientStop::updateGradient()
224 return QQmlListProperty<QQuickGradientStop>(
this, &m_stops);
251 for (
int i = 0;
i < m_stops.
size(); ++
i){
253 while (
j <
stops.size() &&
stops.at(
j).first < m_stops[
i]->position())
260void QQuickGradient::doUpdate()
269 bool implicitAA = (
radius != 0);
332#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
337void QQuickRectangle::doUpdate()
420 if (
d->doUpdateSlotIdx < 0)
421 d->doUpdateSlotIdx = QQuickRectangle::staticMetaObject.indexOfSlot(
"doUpdate()");
423 if (
auto oldGradient = qobject_cast<QQuickGradient*>(
d->gradient.toQObject()))
436 static const QMetaEnum gradientPresetMetaEnum = QMetaEnum::fromType<QGradient::Preset>();
437 Q_ASSERT(gradientPresetMetaEnum.isValid());
453 const auto presetInt = gradientPresetMetaEnum.keyToValue(
qPrintable(presetName), &
ok);
468 qmlWarning(
this) <<
"Unknown gradient type. Expected int, string, or Gradient";
504 d->maybeSetImplicitAntialiasing();
509 if (
d->extraRectangle.isAllocated()) {
510 if (
d->extraRectangle->topLeftRadius < 0.)
511 emit topLeftRadiusChanged();
512 if (
d->extraRectangle->topRightRadius < 0.)
513 emit topRightRadiusChanged();
514 if (
d->extraRectangle->bottomLeftRadius < 0.)
515 emit bottomLeftRadiusChanged();
516 if (
d->extraRectangle->bottomRightRadius < 0.)
517 emit bottomRightRadiusChanged();
519 emit topLeftRadiusChanged();
520 emit topRightRadiusChanged();
521 emit bottomLeftRadiusChanged();
522 emit bottomRightRadiusChanged();
542 if (
d->extraRectangle.isAllocated() &&
d->extraRectangle->topLeftRadius >= 0.)
543 return d->extraRectangle.value().topLeftRadius;
550 if (
d->extraRectangle.value().topLeftRadius ==
radius)
554 qmlWarning(
this) <<
"topLeftRadius (" <<
radius <<
") cannot be less than 0.";
557 d->extraRectangle.value().topLeftRadius =
radius;
558 d->maybeSetImplicitAntialiasing();
561 emit topLeftRadiusChanged();
567 if (!
d->extraRectangle.isAllocated())
569 if (
d->extraRectangle.value().topLeftRadius < 0)
572 d->extraRectangle.value().topLeftRadius = -1.;
573 d->maybeSetImplicitAntialiasing();
576 emit topLeftRadiusChanged();
595 if (
d->extraRectangle.isAllocated() &&
d->extraRectangle->topRightRadius >= 0.)
596 return d->extraRectangle.value().topRightRadius;
603 if (
d->extraRectangle.value().topRightRadius ==
radius)
607 qmlWarning(
this) <<
"topRightRadius (" <<
radius <<
") cannot be less than 0.";
610 d->extraRectangle.value().topRightRadius =
radius;
611 d->maybeSetImplicitAntialiasing();
614 emit topRightRadiusChanged();
620 if (!
d->extraRectangle.isAllocated())
622 if (
d->extraRectangle.value().topRightRadius < 0)
625 d->extraRectangle.value().topRightRadius = -1.;
626 d->maybeSetImplicitAntialiasing();
629 emit topRightRadiusChanged();
648 if (
d->extraRectangle.isAllocated() &&
d->extraRectangle->bottomLeftRadius >= 0.)
649 return d->extraRectangle.value().bottomLeftRadius;
656 if (
d->extraRectangle.value().bottomLeftRadius ==
radius)
660 qmlWarning(
this) <<
"bottomLeftRadius (" <<
radius <<
") cannot be less than 0.";
664 d->extraRectangle.value().bottomLeftRadius =
radius;
665 d->maybeSetImplicitAntialiasing();
668 emit bottomLeftRadiusChanged();
674 if (!
d->extraRectangle.isAllocated())
676 if (
d->extraRectangle.value().bottomLeftRadius < 0)
679 d->extraRectangle.value().bottomLeftRadius = -1.;
680 d->maybeSetImplicitAntialiasing();
683 emit bottomLeftRadiusChanged();
702 if (
d->extraRectangle.isAllocated() &&
d->extraRectangle->bottomRightRadius >= 0.)
703 return d->extraRectangle.value().bottomRightRadius;
710 if (
d->extraRectangle.value().bottomRightRadius ==
radius)
714 qmlWarning(
this) <<
"bottomRightRadius (" <<
radius <<
") cannot be less than 0.";
718 d->extraRectangle.value().bottomRightRadius =
radius;
719 d->maybeSetImplicitAntialiasing();
722 emit bottomRightRadiusChanged();
728 if (!
d->extraRectangle.isAllocated())
730 if (
d->extraRectangle.value().bottomRightRadius < 0)
733 d->extraRectangle.value().bottomRightRadius = -1.;
734 d->maybeSetImplicitAntialiasing();
737 emit bottomRightRadiusChanged();
783 || (
d->color.alpha() == 0 && (!
d->pen ||
d->pen->width() == 0 ||
d->pen->color().alpha() == 0))) {
789 if (!rectangle) rectangle =
d->sceneGraphContext()->createInternalRectangleNode();
794 if (
d->pen &&
d->pen->isValid()) {
796 qreal penWidth =
d->pen->width();
797 if (
d->pen->pixelAligned()) {
808 if (
d->extraRectangle.isAllocated()) {
822 bool vertical =
true;
823 if (
d->gradient.isQObject()) {
824 auto gradient = qobject_cast<QQuickGradient*>(
d->gradient.toQObject());
828 }
else if (
d->gradient.isNumber() ||
d->gradient.isString()) {
833 const QPointF end = linearGradient.finalStop();
835 stops = linearGradient.stops();
836 if ((vertical &&
start.y() >
end.y()) || (!vertical &&
start.x() >
end.x())) {
842 stop.first = 1 - stop.first;
843 reverseStops.append(stop);
845 stops = reverseStops;
859#include "moc_qquickrectangle_p.cpp"
The QColor class provides colors based on RGB, HSV or CMYK values.
int alpha() const noexcept
Returns the alpha color component of this color.
The QJSValue class acts as a container for Qt/JavaScript data types.
qint32 toInt() const
Returns the signed 32-bit integer value of this QJSValue, using the conversion rules described in \l{...
bool isQObject() const
Returns true if this QJSValue is a QObject; otherwise returns false.
bool isNumber() const
Returns true if this QJSValue is of the primitive type Number; otherwise returns false.
bool isUndefined() const
Returns true if this QJSValue is of the primitive type Undefined or if the managed value has been cle...
QObject * toQObject() const
If this QJSValue is a QObject, returns the QObject pointer that the QJSValue represents; otherwise,...
bool isNull() const
Returns true if this QJSValue is of the primitive type Null; otherwise returns false.
bool isString() const
Returns true if this QJSValue is of the primitive type String; otherwise returns false.
QString toString() const
Returns the string value of this QJSValue, as defined in \l{ECMA-262} section 9.8,...
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
reverse_iterator rbegin()
QObject * parent() const
Returns a pointer to the parent object.
\inmodule QtCore\reentrant
QQuickGradientStop(QObject *parent=nullptr)
\qmltype GradientStop \instantiates QQuickGradientStop \inqmlmodule QtQuick
void setColor(const QColor &color)
void setPosition(qreal position)
QQuickGradient(QObject *parent=nullptr)
\qmltype Gradient \instantiates QQuickGradient \inqmlmodule QtQuick
void setOrientation(Orientation orientation)
\qmlproperty enumeration QtQuick::Gradient::orientation
~QQuickGradient() override
QQmlListProperty< QQuickGradientStop > stops
QGradientStops gradientStops() const
void orientationChanged()
void setImplicitAntialiasing(bool antialiasing)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
void setAcceptTouchEvents(bool accept)
If enabled is true, this sets the item to accept touch events; otherwise, touch events are not accept...
QQuickWindow * window() const
Returns the window in which this item is rendered.
qreal width
This property holds the width of this item.
bool antialiasing
\qmlproperty bool QtQuick::Item::antialiasing
qreal height
This property holds the height of this item.
void update()
Schedules a call to updatePaintNode() for this item.
For specifying a pen used for drawing rectangle borders on a QQuickView.
void pixelAlignedChanged()
void setPixelAligned(bool aligned)
QQuickPen(QObject *parent=nullptr)
void setColor(const QColor &c)
void maybeSetImplicitAntialiasing()
static int doUpdateSlotIdx
QLazilyAllocated< ExtraData > extraRectangle
void setBottomRightRadius(qreal radius)
void resetTopRightRadius()
QQuickRectangle(QQuickItem *parent=nullptr)
\qmltype Rectangle \instantiates QQuickRectangle \inqmlmodule QtQuick \inherits Item
void setTopRightRadius(qreal radius)
void setBottomLeftRadius(qreal radius)
void resetTopLeftRadius()
void setTopLeftRadius(qreal radius)
void setColor(const QColor &)
FINALqreal topRightRadius
void setRadius(qreal radius)
void setGradient(const QJSValue &gradient)
QSGNode * updatePaintNode(QSGNode *, UpdatePaintNodeData *) override
Called on the render thread when it is time to sync the state of the item with the scene graph.
QQuickPen * border
\qmlproperty bool QtQuick::Rectangle::antialiasing
FINALqreal bottomRightRadius
void resetBottomRightRadius()
FINALqreal bottomLeftRadius
void resetBottomLeftRadius()
\inmodule QtCore\reentrant
virtual void setRadius(qreal radius)=0
virtual void setAntialiasing(bool antialiasing)
virtual void setGradientVertical(bool vertical)=0
virtual void setAligned(bool aligned)=0
virtual void setPenColor(const QColor &color)=0
virtual void setTopRightRadius(qreal radius)=0
virtual void setBottomRightRadius(qreal radius)=0
virtual void setBottomLeftRadius(qreal radius)=0
virtual void setPenWidth(qreal width)=0
virtual void setGradientStops(const QGradientStops &stops)=0
virtual void setRect(const QRectF &rect)=0
virtual void setTopLeftRadius(qreal radius)=0
virtual void setColor(const QColor &color)=0
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
QSet< QString >::iterator it
Combined button and popup list for selecting options.
QPair< qreal, QColor > QGradientStop
int qRound(qfloat16 d) noexcept
constexpr T qAbs(const T &t)
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
void QQml_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static QT_BEGIN_NAMESPACE qreal dpr(const QWindow *w)
Int aligned(Int v, Int byteAlign)
#define qPrintable(string)
QLatin1StringView QLatin1String