From d3a626fbc543c6edb68b5fa206a26840c103f7c0 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 2 Oct 2020 10:39:21 +0200 Subject: Native style: ensure ScrollView contents doesn't go under the scrollbars On macOS the scrollbars are not transient. The contentItem of a ScrollView should therefore be aligned to the side of the scrollbars, rather than to the side of the ScrollView. Change-Id: Ie58753d61c04c979270995deb6e3b2650fa643db Reviewed-by: Mitch Curtis --- src/imports/controls/macos/ScrollView.qml | 3 +++ src/imports/controls/windows/ScrollView.qml | 3 +++ tests/manual/nativestyle/ControlContainer.qml | 2 +- tests/manual/nativestyle/TextAreas.qml | 2 -- tests/manual/nativestyle/main.qml | 4 ++-- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/imports/controls/macos/ScrollView.qml b/src/imports/controls/macos/ScrollView.qml index 7940bb95..aced3809 100644 --- a/src/imports/controls/macos/ScrollView.qml +++ b/src/imports/controls/macos/ScrollView.qml @@ -51,6 +51,9 @@ T.ScrollView { // (doesn't float on top), and in that case, the contents will show through them. contentItem.clip: clip && (ScrollBar.vertical.visible || ScrollBar.horizontal.visible) + rightPadding: ScrollBar.vertical.visible ? ScrollBar.vertical.width : 0 + bottomPadding: ScrollBar.horizontal.visible ? ScrollBar.horizontal.height : 0 + ScrollBar.vertical: ScrollBar { parent: control x: control.mirrored ? 0 : control.width - width diff --git a/src/imports/controls/windows/ScrollView.qml b/src/imports/controls/windows/ScrollView.qml index a6bba9de..fe56713c 100644 --- a/src/imports/controls/windows/ScrollView.qml +++ b/src/imports/controls/windows/ScrollView.qml @@ -46,6 +46,9 @@ T.ScrollView { implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, contentHeight + topPadding + bottomPadding) + rightPadding: ScrollBar.vertical.visible ? ScrollBar.vertical.width : 0 + bottomPadding: ScrollBar.horizontal.visible ? ScrollBar.horizontal.height : 0 + ScrollBar.vertical: ScrollBar { parent: control x: control.mirrored ? 0 : control.width - width diff --git a/tests/manual/nativestyle/ControlContainer.qml b/tests/manual/nativestyle/ControlContainer.qml index f528e994..5ac9f6bb 100644 --- a/tests/manual/nativestyle/ControlContainer.qml +++ b/tests/manual/nativestyle/ControlContainer.qml @@ -41,7 +41,7 @@ import QtQuick.Layouts Item { anchors.left: parent.left anchors.right: parent.right - anchors.rightMargin: 20 // make room for scrollbar + anchors.rightMargin: 7 implicitHeight: groupBox.height property alias title: groupBox.title diff --git a/tests/manual/nativestyle/TextAreas.qml b/tests/manual/nativestyle/TextAreas.qml index f411c3bd..e3911992 100644 --- a/tests/manual/nativestyle/TextAreas.qml +++ b/tests/manual/nativestyle/TextAreas.qml @@ -78,7 +78,6 @@ ControlContainer { + "mollit anim id est laborum." wrapMode: TextEdit.WordWrap selectByMouse: true - rightPadding: scrollView.ScrollBar.vertical.width } } } @@ -115,7 +114,6 @@ ControlContainer { + "mollit anim id est laborum." wrapMode: TextEdit.WordWrap selectByMouse: true - rightPadding: scrollView2.ScrollBar.vertical.width } } } diff --git a/tests/manual/nativestyle/main.qml b/tests/manual/nativestyle/main.qml index ef7c89a2..5e75e7a3 100644 --- a/tests/manual/nativestyle/main.qml +++ b/tests/manual/nativestyle/main.qml @@ -70,7 +70,7 @@ ApplicationWindow { anchors.margins: 20 ScrollView { - contentWidth: width + contentWidth: width - ScrollBar.vertical.width clip: true Column { @@ -96,7 +96,7 @@ ApplicationWindow { } ScrollView { - contentWidth: width + contentWidth: width - ScrollBar.vertical.width clip: true Column { -- cgit v1.2.3