[vlc-commits] qml: fit sliderbar into maininterface boundaries

Fatih Uzunoglu git at videolan.org
Thu Aug 27 12:44:36 CEST 2020


vlc | branch: master | Fatih Uzunoglu <fuzun54 at outlook.com> | Mon Jul 27 23:06:49 2020 +0300| [b55762a1f758ed2d655b09eb8c07277d54b87150] | committer: Pierre Lamot

qml: fit sliderbar into maininterface boundaries

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

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

 modules/gui/qt/maininterface/qml/MainInterface.qml |  1 +
 modules/gui/qt/player/qml/SliderBar.qml            | 28 +++++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/modules/gui/qt/maininterface/qml/MainInterface.qml b/modules/gui/qt/maininterface/qml/MainInterface.qml
index e7ffe949fb..ec7f95616f 100644
--- a/modules/gui/qt/maininterface/qml/MainInterface.qml
+++ b/modules/gui/qt/maininterface/qml/MainInterface.qml
@@ -36,6 +36,7 @@ Rectangle {
     property bool _interfaceReady: false
     property bool _playlistReady: false
 
+    property alias mainInterfaceRect: root
 
     Binding {
         target: VLCStyle.self
diff --git a/modules/gui/qt/player/qml/SliderBar.qml b/modules/gui/qt/player/qml/SliderBar.qml
index c747b56a9a..feae7e7c90 100644
--- a/modules/gui/qt/player/qml/SliderBar.qml
+++ b/modules/gui/qt/player/qml/SliderBar.qml
@@ -45,8 +45,31 @@ Slider {
         property real location: sliderRectMouseArea.mouseX
         property real position: location/control.width
 
+        width: childrenRect.width
+        height: childrenRect.height
+
+        function getX() {
+            var x = location - (timeTooltip.width / 2)
+            var diff = (x + timeTooltip.width) - (VLCStyle.appWidth)
+            var sliderRealX = mainInterfaceRect.mapFromItem(sliderRectMouseArea, sliderRectMouseArea.x, sliderRectMouseArea.y).x
+
+            if (x < -sliderRealX) {
+                arrow.diff = x
+                x = -sliderRealX
+            }
+            else if (diff > 0) {
+                arrow.diff = diff
+                x -= (diff)
+            }
+            else {
+                arrow.diff = 0
+            }
+
+            return x
+        }
+
         y: -(childrenRect.height)
-        x: location - (timeIndicatorRect.width / 2)
+        x: getX()
         visible: control.hovered
 
         Item {
@@ -66,6 +89,9 @@ Slider {
 
                 anchors.centerIn: parent
                 anchors.verticalCenterOffset: -(parent.height / 2)
+                anchors.horizontalCenterOffset: diff
+
+                property int diff: 0
 
                 color: VLCStyle.colors.bgAlt
 



More information about the vlc-commits mailing list