From 89495f409fcb04f5eeb1c1e06096fcb54065c969 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 2 May 2018 13:54:08 +0200 Subject: Label: add support for background insets Same as 5adce042 for QQuickControl. [ChangeLog][Controls][Label] Added topInset, bottomInset, leftInset, and rightInset properties to control the geometry of the background similarly to how paddings control the geometry of the contentItem. Change-Id: I853efcdd6be1d3acfb067128b6195c253350de8d Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicklabel_p_p.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/quicktemplates2/qquicklabel_p_p.h') diff --git a/src/quicktemplates2/qquicklabel_p_p.h b/src/quicktemplates2/qquicklabel_p_p.h index 00fea1d3..e1010698 100644 --- a/src/quicktemplates2/qquicklabel_p_p.h +++ b/src/quicktemplates2/qquicklabel_p_p.h @@ -75,6 +75,17 @@ public: return static_cast(QObjectPrivate::get(item)); } + inline QMarginsF getInset() const { return QMarginsF(getLeftInset(), getTopInset(), getRightInset(), getBottomInset()); } + inline qreal getTopInset() const { return extra.isAllocated() ? extra->topInset : 0; } + inline qreal getLeftInset() const { return extra.isAllocated() ? extra->leftInset : 0; } + inline qreal getRightInset() const { return extra.isAllocated() ? extra->rightInset : 0; } + inline qreal getBottomInset() const { return extra.isAllocated() ? extra->bottomInset : 0; } + + void setTopInset(qreal value, bool reset = false); + void setLeftInset(qreal value, bool reset = false); + void setRightInset(qreal value, bool reset = false); + void setBottomInset(qreal value, bool reset = false); + void resizeBackground(); void resolveFont(); @@ -105,16 +116,28 @@ public: void cancelBackground(); void executeBackground(bool complete = false); + void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override; void itemImplicitWidthChanged(QQuickItem *item) override; void itemImplicitHeightChanged(QQuickItem *item) override; void itemDestroyed(QQuickItem *item) override; struct ExtraData { + bool hasTopInset = false; + bool hasLeftInset = false; + bool hasRightInset = false; + bool hasBottomInset = false; + bool hasBackgroundWidth = false; + bool hasBackgroundHeight = false; + qreal topInset = 0; + qreal leftInset = 0; + qreal rightInset = 0; + qreal bottomInset = 0; QFont requestedFont; QPalette requestedPalette; }; QLazilyAllocated extra; + bool resizingBackground = false; QPalette resolvedPalette; QQuickDeferredPointer background; }; -- cgit v1.2.3