aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/nativestyle
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-10-28 12:02:09 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-10-29 09:51:43 +0100
commitb5cc89450d2b211ed582c9c8001f072d7b9bf82d (patch)
tree72fb65812b224a05a2fcd281b9bbc02cc3467fed /src/imports/nativestyle
parentb5c902d51438c8e1fae77d5c04b14e88cc687703 (diff)
QuickStyleItem: refactor updatePaintNode()
Refactor the padding part, since there is no reason to go through all the if-tests if we don't use nine patch image scaling. Change-Id: If89c13aec0e6de955f032145ee325974c7169d6c Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/imports/nativestyle')
-rw-r--r--src/imports/nativestyle/items/qquickstyleitem.cpp43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/imports/nativestyle/items/qquickstyleitem.cpp b/src/imports/nativestyle/items/qquickstyleitem.cpp
index b5005a8b..6ca05f29 100644
--- a/src/imports/nativestyle/items/qquickstyleitem.cpp
+++ b/src/imports/nativestyle/items/qquickstyleitem.cpp
@@ -127,26 +127,29 @@ QSGNode *QQuickStyleItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePa
}
#endif
- QMargins padding = m_useNinePatchImage ? m_styleItemGeometry.ninePatchMargins : QMargins(0, 0, 0, 0);
- if (padding.right() == -1) {
- // Special case: a right padding of -1 means that
- // the image should not scale horizontally.
- bounds.setWidth(ninePatchImageSize.width());
- padding.setLeft(0);
- padding.setRight(0);
- } else if (boundingRect().width() < imageSize().width()) {
- // If the item size is smaller that the image, using nine-patch scaling
- // ends up wrapping it. In that case we scale the whole image instead.
- padding.setLeft(0);
- padding.setRight(0);
- }
- if (padding.bottom() == -1) {
- bounds.setHeight(ninePatchImageSize.height());
- padding.setTop(0);
- padding.setBottom(0);
- } else if (boundingRect().height() < imageSize().height()) {
- padding.setTop(0);
- padding.setBottom(0);
+ QMargins padding;
+ if (m_useNinePatchImage) {
+ padding = m_styleItemGeometry.ninePatchMargins;
+ if (padding.right() == -1) {
+ // Special case: a right padding of -1 means that
+ // the image should not scale horizontally.
+ bounds.setWidth(ninePatchImageSize.width());
+ padding.setLeft(0);
+ padding.setRight(0);
+ } else if (boundingRect().width() < imageSize().width()) {
+ // If the item size is smaller that the image, using nine-patch scaling
+ // ends up wrapping it. In that case we scale the whole image instead.
+ padding.setLeft(0);
+ padding.setRight(0);
+ }
+ if (padding.bottom() == -1) {
+ bounds.setHeight(ninePatchImageSize.height());
+ padding.setTop(0);
+ padding.setBottom(0);
+ } else if (boundingRect().height() < imageSize().height()) {
+ padding.setTop(0);
+ padding.setBottom(0);
+ }
}
node->setBounds(bounds);