[vlc-commits] [Git][videolan/vlc][master] qml/ExpandGridView: Update 'getItemPos' to integers

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Fri Oct 1 12:03:25 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
7ff2c1aa by Benjamin Arnaud at 2021-10-01T10:13:49+00:00
qml/ExpandGridView: Update 'getItemPos' to integers

This is useful to avoid visual artifacts like wrong alignments and blurry texture rendering.

- - - - -


1 changed file:

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


Changes:

=====================================
modules/gui/qt/widgets/qml/ExpandGridView.qml
=====================================
@@ -161,10 +161,18 @@ FocusScope {
     }
 
     function getItemPos(id) {
-        var colCount = root.getNbItemsPerRow()
-        var remainingSpace = (flickable.width - root.rightMargin - root.leftMargin) - (colCount * root._effectiveCellWidth) + root.horizontalSpacing
-        var rowCol = getItemRowCol(id)
-        return [(rowCol[0] * root._effectiveCellWidth) + (remainingSpace / 2) + root.leftMargin, rowCol[1] * root._effectiveCellHeight + headerHeight + topMargin]
+        var remainingSpace = (flickable.width - rightMargin - leftMargin)
+                             - getNbItemsPerRow() * _effectiveCellWidth + horizontalSpacing;
+
+        var rowCol = getItemRowCol(id);
+
+        var x = rowCol[0] * _effectiveCellWidth + remainingSpace / 2 + leftMargin;
+
+        var y = rowCol[1] * _effectiveCellHeight + headerHeight + topMargin;
+
+        // NOTE: Position needs to be integer based if we want to avoid visual artifacts like
+        //       wrong alignments or blurry texture rendering.
+        return [Math.round(x), Math.round(y)];
     }
 
     //use the same signature as Gridview.positionViewAtIndex(index, PositionMode mode)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/7ff2c1aa9f7582671292c237ec9a864ebada9ae1

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/7ff2c1aa9f7582671292c237ec9a864ebada9ae1
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list