[vlc-commits] qml: apply margintop and marginBottom properties when laying out items

Prince Gupta git at videolan.org
Fri Jul 24 11:45:30 CEST 2020


vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Mon Jul  6 21:15:12 2020 +0530| [6d272069eb6a46c3d5559ce3adc898d94ecc8ea4] | committer: Pierre Lamot

qml: apply margintop and marginBottom properties when laying out items

previously they were only used in positionViewAtIndex calls

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6d272069eb6a46c3d5559ce3adc898d94ecc8ea4
---

 modules/gui/qt/medialibrary/qml/MusicAlbums.qml         |  4 ++--
 modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml |  2 ++
 modules/gui/qt/widgets/qml/ExpandGridView.qml           | 14 +++++++-------
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
index 807fb8b1b4..ff83ab4a47 100644
--- a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
@@ -41,7 +41,7 @@ Widgets.NavigableFocusScope {
     readonly property var currentIndex: view.currentItem.currentIndex
     //the index to "go to" when the view is loaded
     property var initialIndex: 0
-
+    property int gridViewMarginTop: VLCStyle.margin_large
 
     navigationCancel: function() {
         if (view.currentItem.currentIndex <= 0) {
@@ -101,7 +101,7 @@ Widgets.NavigableFocusScope {
             id: gridView_id
 
             activeFocusOnTab:true
-
+            marginTop: root.gridViewMarginTop
             cellWidth: VLCStyle.gridItem_music_width
             cellHeight: VLCStyle.gridItem_music_height
 
diff --git a/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
index 7a675d7fa8..71474c99c2 100644
--- a/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
@@ -172,7 +172,9 @@ Widgets.NavigableFocusScope {
 
             MusicAlbums {
                 id: albumSubView
+
                 anchors.fill: parent
+                gridViewMarginTop: 0
 
                 header: ArtistTopBanner {
                     id: artistBanner
diff --git a/modules/gui/qt/widgets/qml/ExpandGridView.qml b/modules/gui/qt/widgets/qml/ExpandGridView.qml
index b7c72b94ba..eb13646b12 100644
--- a/modules/gui/qt/widgets/qml/ExpandGridView.qml
+++ b/modules/gui/qt/widgets/qml/ExpandGridView.qml
@@ -29,8 +29,8 @@ NavigableFocusScope {
     property int cellHeight: 100
 
     //margin to apply
-    property int marginBottom: root.cellHeight / 2
-    property int marginTop: root.cellHeight / 3
+    property int marginBottom: 0
+    property int marginTop: 0
 
     property int horizontalSpacing: VLCStyle.column_margin_width
     property int verticalSpacing: VLCStyle.column_margin_width
@@ -117,7 +117,7 @@ NavigableFocusScope {
         var colCount = root.getNbItemsPerRow()
         var remainingSpace = flickable.width - (colCount * root._effectiveCellWidth) + root.horizontalSpacing
         var rowCol = getItemRowCol(id)
-        return [(rowCol[0] * root._effectiveCellWidth) + (remainingSpace / 2), rowCol[1] * root._effectiveCellHeight + headerHeight]
+        return [(rowCol[0] * root._effectiveCellWidth) + (remainingSpace / 2), rowCol[1] * root._effectiveCellHeight + headerHeight + marginTop]
     }
 
     //use the same signature as Gridview.positionViewAtIndex(index, PositionMode mode)
@@ -186,7 +186,7 @@ NavigableFocusScope {
     }
 
     function _getFirstAndLastInstanciatedItemIds() {
-        var myContentY = flickable.contentY - root.headerHeight
+        var myContentY = flickable.contentY - root.headerHeight - marginTop
 
         var contentYWithoutExpand = myContentY
         var heightWithoutExpand = flickable.height
@@ -322,7 +322,7 @@ NavigableFocusScope {
         Loader {
             id: headerItemLoader
             //load the header early (when the first row is visible)
-            visible: flickable.contentY < root.headerHeight + root._effectiveCellHeight
+            visible: flickable.contentY < (root.headerHeight + root._effectiveCellHeight + root.marginTop)
             sourceComponent: headerDelegate
             focus: item.focus
             onFocusChanged: {
@@ -336,7 +336,7 @@ NavigableFocusScope {
             }
             onLoaded: {
                 item.x = 0
-                item.y = 0
+                item.y = root.marginTop
             }
         }
 
@@ -425,7 +425,7 @@ NavigableFocusScope {
 
             // Calculate and set the contentHeight
             var newContentHeight = root.getItemPos(_count - 1)[1] + root._effectiveCellHeight + _expandItemVerticalSpace
-            contentHeight = newContentHeight
+            contentHeight = newContentHeight + root.marginBottom // marginTop is included from root.getItemPos
             contentWidth = root._effectiveCellWidth * root.getNbItemsPerRow() - root.horizontalSpacing
 
             _updateSelected()



More information about the vlc-commits mailing list