[vlc-devel] [PATCH] qml: introduce spacing property for griditem

Prince Gupta guptaprince8832 at gmail.com
Sun Apr 12 16:33:33 CEST 2020


previously two corresponding items in gridview, one selected and another in zoomed state will have no space between them. This property adds extra space between content and item's boundary, basically creating spacing between individual items so that they never touch inside a GridView
---
 modules/gui/qt/widgets/qml/GridItem.qml | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt/widgets/qml/GridItem.qml b/modules/gui/qt/widgets/qml/GridItem.qml
index 680b36a..8d25e05 100644
--- a/modules/gui/qt/widgets/qml/GridItem.qml
+++ b/modules/gui/qt/widgets/qml/GridItem.qml
@@ -40,6 +40,7 @@ Item {
     property var labels: []
     property real pictureWidth: isVideo ? VLCStyle.video_normal_width : VLCStyle.cover_small
     property real pictureHeight: isVideo ? VLCStyle.video_normal_height : VLCStyle.cover_small
+    property real spacing: VLCStyle.margin_xsmall
 
     //space use for zoom
     readonly property real outterMargin: VLCStyle.margin_xxsmall
@@ -57,12 +58,12 @@ Item {
     Accessible.role: Accessible.Cell
     Accessible.name: title
 
-    implicitWidth: mouseArea.implicitWidth
-    implicitHeight: mouseArea.implicitHeight
+    implicitWidth: mouseArea.implicitWidth + 2*spacing
+    implicitHeight: mouseArea.implicitHeight + 2*spacing
 
     property bool _zoomed: mouseArea.containsMouse || root.activeFocus
-    property real _picWidth: pictureWidth + (_zoomed ? 2*outterMargin : 0)
-    property real _picHeight: pictureHeight + (_zoomed ? 2*outterMargin : 0)
+    property real _picWidth: pictureWidth + (_zoomed ? 2*outterMargin : 0) - spacing
+    property real _picHeight: pictureHeight + (_zoomed ? 2*outterMargin : 0) - spacing
 
 
     MouseArea {
@@ -70,6 +71,7 @@ Item {
         hoverEnabled: true
 
         anchors.fill: parent
+        anchors.margins: root.spacing
         implicitWidth: zoomArea.implicitWidth + (_zoomed ? 0 : 2*outterMargin)
         implicitHeight: zoomArea.implicitHeight + (_zoomed ? 0 : 2*outterMargin)
 
-- 
2.20.1



More information about the vlc-devel mailing list