10#include <QtCore/qloggingcategory.h>
11#include <QtQml/qqmlinfo.h>
12#include <QtQuick/private/qquickitem_p.h>
91 bool widthAdjusted =
false;
92 bool heightAdjusted =
false;
95 const QQuickItem *centerInParent =
p->anchors ?
p->getAnchors()->centerIn() :
nullptr;
96 const QQuickOverlay *centerInOverlay = qobject_cast<const QQuickOverlay*>(centerInParent);
97 QRectF rect(!centerInParent ?
p->allowHorizontalMove ?
p->x : popupItem->
x() : 0,
98 !centerInParent ?
p->allowVerticalMove ?
p->y : popupItem->
y() : 0,
99 !
p->hasWidth && iw > 0 ? iw :
w,
100 !
p->hasHeight && ih > 0 ? ih :
h);
101 bool relaxEdgeConstraint =
p->relaxEdgeConstraint;
106 if (centerInParent) {
107 if (centerInParent !=
parentItem() && !centerInOverlay) {
108 qmlWarning(
m_popup) <<
"Popup can only be centered within its immediate parent or Overlay.overlay";
112 if (centerInOverlay) {
115 relaxEdgeConstraint =
false;
126 QRectF bounds(qMax<qreal>(0.0, margins.
left()),
127 qMax<qreal>(0.0, margins.
top()),
128 p->window->width() - qMax<qreal>(0.0, margins.
left()) - qMax<qreal>(0.0, margins.
right()),
129 p->window->height() - qMax<qreal>(0.0, margins.
top()) - qMax<qreal>(0.0, margins.
bottom()));
132 if (
p->allowHorizontalFlip && (
rect.left() < bounds.
left() ||
rect.right() > bounds.
right())) {
141 if (
p->allowVerticalFlip && (
rect.top() < bounds.
top() ||
rect.bottom() > bounds.
bottom())) {
150 if (
p->allowVerticalMove) {
151 if (margins.
top() >= 0 &&
rect.top() < bounds.
top())
156 if (
p->allowHorizontalMove) {
166 if (
p->allowHorizontalMove &&
p->allowHorizontalFlip) {
177 if (
p->allowHorizontalResize) {
178 if ((margins.
left() >= 0 || !relaxEdgeConstraint)
181 widthAdjusted =
true;
183 if ((margins.
right() >= 0 || !relaxEdgeConstraint)
186 widthAdjusted =
true;
189 }
else if (iw > 0 &&
rect.left() >= bounds.
left() &&
rect.right() <= bounds.
right()
193 widthAdjusted =
true;
199 if (
p->allowVerticalMove &&
p->allowVerticalFlip) {
210 if (
p->allowVerticalResize) {
211 if ((margins.
top() >= 0 || !relaxEdgeConstraint)
212 && (
rect.top() < bounds.
top())) {
214 heightAdjusted =
true;
216 if ((margins.
bottom() >= 0 || !relaxEdgeConstraint)
219 heightAdjusted =
true;
222 }
else if (ih > 0 &&
rect.top() >= bounds.
top() &&
rect.bottom() <= bounds.
bottom()
226 heightAdjusted =
true;
241 p->effectiveX = effectivePos.
x();
245 p->effectiveY = effectivePos.y();
249 if (!
p->hasWidth && widthAdjusted &&
rect.width() > 0) {
256 if (!
p->hasHeight && heightAdjusted &&
rect.height() > 0) {
262 qCDebug(lcPopupPositioner) <<
"- new popupItem geometry:"
263 << popupItem->
x() << popupItem->
y() << popupItem->
width() << popupItem->
height();
constexpr qreal right() const noexcept
Returns the right margin.
constexpr qreal left() const noexcept
Returns the left margin.
constexpr qreal top() const noexcept
Returns the top margin.
constexpr qreal bottom() const noexcept
Returns the bottom margin.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
static QQuickItemPrivate * get(QQuickItem *item)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Q_INVOKABLE QPointF mapToItem(const QQuickItem *item, const QPointF &point) const
Maps the given point in this item's coordinate system to the equivalent point within item's coordinat...
qreal x
\qmlproperty real QtQuick::Item::x \qmlproperty real QtQuick::Item::y \qmlproperty real QtQuick::Item...
QPointF mapFromScene(const QPointF &point) const
Maps the given point in the scene's coordinate system to the equivalent point within this item's coor...
qreal y
Defines the item's y position relative to its parent.
qreal width
This property holds the width of this item.
QQuickItem * parentItem() const
qreal height
This property holds the height of this item.
void setPosition(const QPointF &)
qreal scale
\qmlproperty real QtQuick::Item::scale This property holds the scale factor for this item.
void polish()
Schedules a polish event for this item.
\inmodule QtCore\reentrant
constexpr qreal bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr qreal left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
QRectF intersected(const QRectF &other) const noexcept
constexpr qreal right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
Combined button and popup list for selecting options.
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
int qRound(qfloat16 d) noexcept
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLfloat GLfloat GLfloat w
[0]
GLfloat GLfloat GLfloat GLfloat h
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)