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()
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);
270 if (
extra.isAllocated() && !implicitAA) {
271 implicitAA =
extra.value().topLeftRadius > 0.0
272 ||
extra.value().topRightRadius > 0.0
273 ||
extra.value().bottomLeftRadius > 0.0
274 ||
extra.value().bottomRightRadius > 0.0;
332#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
337void QQuickRectangle::doUpdate()
415 if (
d->doUpdateSlotIdx < 0)
416 d->doUpdateSlotIdx = QQuickRectangle::staticMetaObject.indexOfSlot(
"doUpdate()");
418 if (
auto oldGradient = qobject_cast<QQuickGradient*>(
d->gradient.toQObject()))
431 static const QMetaEnum gradientPresetMetaEnum = QMetaEnum::fromType<QGradient::Preset>();
463 qmlWarning(
this) <<
"Unknown gradient type. Expected int, string, or Gradient";
499 d->maybeSetImplicitAntialiasing();
521 if (
d->extra.isAllocated())
522 return qMax(
d->extra.value().topLeftRadius, 0.);
529 if (
d->extra.value().topLeftRadius ==
radius)
533 qmlWarning(
this) <<
"topLeftRadius (" <<
radius <<
") cannot be less than 0.";
536 d->extra.value().topLeftRadius =
radius;
537 d->maybeSetImplicitAntialiasing();
540 emit topLeftRadiusChanged();
546 if (!
d->extra.isAllocated())
548 if (
d->extra.value().topLeftRadius < 0)
551 d->extra.value().topLeftRadius = -1.;
552 d->maybeSetImplicitAntialiasing();
555 emit topLeftRadiusChanged();
574 if (
d->extra.isAllocated())
575 return qMax(
d->extra.value().topRightRadius, 0.);
582 if (
d->extra.value().topRightRadius ==
radius)
586 qmlWarning(
this) <<
"topRightRadius (" <<
radius <<
") cannot be less than 0.";
589 d->extra.value().topRightRadius =
radius;
590 d->maybeSetImplicitAntialiasing();
593 emit topRightRadiusChanged();
599 if (!
d->extra.isAllocated())
601 if (
d->extra.value().topRightRadius < 0)
604 d->extra.value().topRightRadius = -1.;
605 d->maybeSetImplicitAntialiasing();
608 emit topRightRadiusChanged();
627 if (
d->extra.isAllocated())
628 return qMax(
d->extra.value().bottomLeftRadius, 0.);
635 if (
d->extra.value().bottomLeftRadius ==
radius)
639 qmlWarning(
this) <<
"bottomLeftRadius (" <<
radius <<
") cannot be less than 0.";
643 d->extra.value().bottomLeftRadius =
radius;
644 d->maybeSetImplicitAntialiasing();
647 emit bottomLeftRadiusChanged();
653 if (!
d->extra.isAllocated())
655 if (
d->extra.value().bottomLeftRadius < 0)
658 d->extra.value().bottomLeftRadius = -1.;
659 d->maybeSetImplicitAntialiasing();
662 emit bottomLeftRadiusChanged();
681 if (
d->extra.isAllocated())
682 return qMax(
d->extra.value().bottomRightRadius, 0.);
689 if (
d->extra.value().bottomRightRadius ==
radius)
693 qmlWarning(
this) <<
"bottomRightRadius (" <<
radius <<
") cannot be less than 0.";
697 d->extra.value().bottomRightRadius =
radius;
698 d->maybeSetImplicitAntialiasing();
701 emit bottomRightRadiusChanged();
707 if (!
d->extra.isAllocated())
709 if (
d->extra.value().bottomRightRadius < 0)
712 d->extra.value().bottomRightRadius = -1.;
713 d->maybeSetImplicitAntialiasing();
716 emit bottomRightRadiusChanged();
762 || (
d->color.alpha() == 0 && (!
d->pen ||
d->pen->width() == 0 ||
d->pen->color().alpha() == 0))) {
768 if (!rectangle) rectangle =
d->sceneGraphContext()->createInternalRectangleNode();
773 if (
d->pen &&
d->pen->isValid()) {
775 qreal penWidth =
d->pen->width();
776 if (
d->pen->pixelAligned()) {
787 if (
d->extra.isAllocated()) {
801 bool vertical =
true;
802 if (
d->gradient.isQObject()) {
803 auto gradient = qobject_cast<QQuickGradient*>(
d->gradient.toQObject());
807 }
else if (
d->gradient.isNumber() ||
d->gradient.isString()) {
812 const QPointF end = linearGradient.finalStop();
814 stops = linearGradient.stops();
815 if ((vertical &&
start.y() >
end.y()) || (!vertical &&
start.x() >
end.x())) {
821 stop.first = 1 - stop.first;
822 reverseStops.
append(stop);
824 stops = reverseStops;
838#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.
Type type() const
Returns the type of gradient.
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()
void append(parameter_type t)
QObject * parent() const
Returns a pointer to the parent object.
\inmodule QtCore\reentrant
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
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)
QLazilyAllocated< ExtraData > extra
void maybeSetImplicitAntialiasing()
static int doUpdateSlotIdx
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 const T & qMax(const T &a, const T &b)
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
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent