[vlc-commits] [Git][videolan/vlc][master] 8 commits: qml/ExpandGridView: remove stray variables

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Thu Jan 27 09:47:22 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
b51649f1 by Prince Gupta at 2022-01-27T09:23:06+00:00
qml/ExpandGridView: remove stray variables

- - - - -
043d79bc by Prince Gupta at 2022-01-27T09:23:06+00:00
qml/ExpandGridView: fix property update with incorrect value

- - - - -
f572fa0d by Prince Gupta at 2022-01-27T09:23:06+00:00
qml: fix Video expand panel retract animation

- - - - -
22ce0413 by Prince Gupta at 2022-01-27T09:23:06+00:00
qml/ExpandGridView: make properties aliases

- - - - -
0130de6b by Prince Gupta at 2022-01-27T09:23:06+00:00
qml/ExpandGridView: improve layout debouncing code

- - - - -
7361762a by Prince Gupta at 2022-01-27T09:23:06+00:00
qml/ExpandGridView: don't assume expand delegate position

in _calculateCurrentRange(), result of this function is used to layout
expand delegate, don't assume the expand delegate position inside this
function itself

- - - - -
c7f622c2 by Prince Gupta at 2022-01-27T09:23:06+00:00
qml/ExpandGridView: correctly check expandDelegate position

- - - - -
4dba94ce by Prince Gupta at 2022-01-27T09:23:06+00:00
qml/ExpanGridView: fix contentWidth

- - - - -


2 changed files:

- modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml
- modules/gui/qt/widgets/qml/ExpandGridView.qml


Changes:

=====================================
modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml
=====================================
@@ -39,11 +39,14 @@ FocusScope {
 
     implicitHeight: contentRect.implicitHeight
 
+    // otherwise produces artefacts on retract animation
+    clip: true
+
     Rectangle{
         id: contentRect
 
+        anchors.fill: parent
         implicitHeight: contentLayout.implicitHeight + ( VLCStyle.margin_normal * 2 )
-        width: parent.width
         color: VLCStyle.colors.expandDelegate
 
         Rectangle {


=====================================
modules/gui/qt/widgets/qml/ExpandGridView.qml
=====================================
@@ -83,9 +83,6 @@ FocusScope {
 
     //delegate to display the extended item
     property Component delegate: Item{}
-    property Component expandDelegate: Item{}
-
-    property Component headerDelegate: Item{}
 
     property var _idChildrenList: []
     property var _unusedItemList: []
@@ -98,13 +95,15 @@ FocusScope {
     property alias contentX: flickable.contentX
     property alias gridScrollBar: flickableScrollBar
 
+    property alias expandDelegate: expandItemLoader.sourceComponent
     property alias expandItem: expandItemLoader.item
 
+    property alias headerDelegate: headerItemLoader.sourceComponent
     property alias headerHeight: headerItemLoader.implicitHeight
     property alias headerItem: headerItemLoader.item
 
-    property alias footerItem: footerItemLoader.item
     property alias footerDelegate: footerItemLoader.sourceComponent
+    property alias footerItem: footerItemLoader.item
 
     // Signals
 
@@ -419,27 +418,29 @@ FocusScope {
     }
 
     function _calculateCurrentRange() {
-        var myContentY = flickable.contentY - headerHeight - topMargin
-
+        var myContentY = flickable.contentY
         var contentYWithoutExpand = myContentY
         var heightWithoutExpand = flickable.height + displayMarginEnd
+
         if (expandIndex !== -1) {
-            if (myContentY >= expandItem.y && myContentY < expandItem.y + _expandItemVerticalSpace)
-                contentYWithoutExpand = expandItem.y
-            if (myContentY >= expandItem.y + _expandItemVerticalSpace)
+            var expandItemY = getItemPos(flickable.getExpandItemGridId())[1]
+
+            if (myContentY >= expandItemY && myContentY < expandItemY + _expandItemVerticalSpace)
+                contentYWithoutExpand = expandItemY
+            if (myContentY >= expandItemY + _expandItemVerticalSpace)
                 contentYWithoutExpand = myContentY - _expandItemVerticalSpace
 
-            var expandYStart = Math.max(myContentY, expandItem.y)
-            var expandYEnd = Math.min(myContentY + height, expandItem.y + _expandItemVerticalSpace)
+            var expandYStart = Math.max(myContentY, expandItemY)
+            var expandYEnd = Math.min(myContentY + height, expandItemY + _expandItemVerticalSpace)
             var expandDisplayedHeight = Math.max(expandYEnd - expandYStart, 0)
             heightWithoutExpand -= expandDisplayedHeight
         }
 
-        var rowId = Math.floor(contentYWithoutExpand / _effectiveCellHeight)
+        var onlyGridContentY = contentYWithoutExpand - headerHeight - topMargin
+        var rowId = Math.floor(onlyGridContentY / _effectiveCellHeight)
         var firstId = Math.max(rowId * _nbItemPerRow, 0)
 
-
-        rowId = Math.ceil((contentYWithoutExpand + heightWithoutExpand) / _effectiveCellHeight)
+        rowId = Math.ceil((onlyGridContentY + heightWithoutExpand) / _effectiveCellHeight)
         var lastId = Math.min(rowId * _nbItemPerRow, _count)
 
         return [firstId, lastId]
@@ -591,9 +592,9 @@ FocusScope {
 
         Loader {
             id: headerItemLoader
+
             //load the header early (when the first row is visible)
             visible: flickable.contentY < (root.headerHeight + root._effectiveCellHeight + root.topMargin)
-            sourceComponent: headerDelegate
             focus: item.focus
             onFocusChanged: {
                 if (!focus)
@@ -634,7 +635,7 @@ FocusScope {
 
         Loader {
             id: expandItemLoader
-            sourceComponent: expandDelegate
+
             active: root.expandIndex !== -1
             focus: active
 
@@ -648,17 +649,7 @@ FocusScope {
 
         anchors.fill: parent
 
-        onContentYChanged: { scrollLayoutTimer.start() }
-
-        Timer {
-            id: scrollLayoutTimer
-
-            interval: 1
-            running: false
-            repeat: false
-            triggeredOnStart: false
-            onTriggered: flickable.layout(false)
-        }
+        onContentYChanged: { Qt.callLater(flickable.layout, false) }
 
         function getExpandItemGridId() {
             var ret
@@ -726,7 +717,6 @@ FocusScope {
 
             root.rowX = getItemPos(0)[0]
 
-            var i
             var expandItemGridId = getExpandItemGridId()
 
             var f_l = _calculateCurrentRange()
@@ -741,8 +731,6 @@ FocusScope {
 
             _updateChildrenMap(firstId, lastId)
 
-            var item
-            var pos
             // Place the delegates before the expandItem
             _setupIndexes(forceRelayout, [firstId, topGridEndId], 0)
 
@@ -756,11 +744,14 @@ FocusScope {
             // Place the delegates after the expandItem
             _setupIndexes(forceRelayout, [topGridEndId, lastId], root._expandItemVerticalSpace)
 
-            // Calculate and set the contentHeight
-            var newContentHeight = root.getItemPos(root._count - 1)[1] + root._effectiveCellHeight + root._expandItemVerticalSpace
-            contentHeight = newContentHeight + root.bottomMargin // topMargin is included from root.getItemPos
-            contentHeight += footerItemLoader.item ? footerItemLoader.item.height : 0
-            contentWidth = root._effectiveCellWidth * root._nbItemPerRow - root.horizontalSpacing
+            // update contentWidth and contentHeight
+            var gridContentWidth = root._effectiveCellWidth * root._nbItemPerRow - root.horizontalSpacing
+            contentWidth = root.leftMargin + gridContentWidth + root.rightMargin
+
+            var gridContentHeight = root.getItemPos(root._count - 1)[1] + root._effectiveCellHeight + root._expandItemVerticalSpace
+            contentHeight = gridContentHeight
+                    + (footerItemLoader.item ? footerItemLoader.item.height : 0)
+                    + root.bottomMargin // topMargin and headerHeight is included in root.getItemPos
         }
 
         Connections {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c7d3e928ad953a40c3c8f904264cc3a4f31ca10d...4dba94ce8f306d8ded9d4a70838d6487c31af7b4

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c7d3e928ad953a40c3c8f904264cc3a4f31ca10d...4dba94ce8f306d8ded9d4a70838d6487c31af7b4
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list