From bc5e7c1bdc353992835cb38dfa15b536a77b4d94 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Mon, 26 Oct 2020 12:26:25 +0100 Subject: [PATCH] Fix changing preview size to be smoother in fullscreen --- .../ui/modules/Common/Helpers/DragBox.qml | 2 ++ .../App/Calls/IncallFullscreenWindow.qml | 34 ++++++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/linphone-app/ui/modules/Common/Helpers/DragBox.qml b/linphone-app/ui/modules/Common/Helpers/DragBox.qml index a3ff370f3..8a948bb91 100644 --- a/linphone-app/ui/modules/Common/Helpers/DragBox.qml +++ b/linphone-app/ui/modules/Common/Helpers/DragBox.qml @@ -21,6 +21,7 @@ Item { // --------------------------------------------------------------------------- signal clicked (var mouse) + signal doubleClicked (var mouse) signal pressed (var mouse) signal released (var mouse) signal wheel (var wheel) @@ -102,6 +103,7 @@ Item { axis: Drag.XandYAxis target: parent } + onDoubleClicked: dragBox.doubleClicked(mouse) onClicked:dragBox.clicked(mouse) onPressed: { dragBox.pressed(mouse) diff --git a/linphone-app/ui/views/App/Calls/IncallFullscreenWindow.qml b/linphone-app/ui/views/App/Calls/IncallFullscreenWindow.qml index d6c5a2b01..a2aa86185 100644 --- a/linphone-app/ui/views/App/Calls/IncallFullscreenWindow.qml +++ b/linphone-app/ui/views/App/Calls/IncallFullscreenWindow.qml @@ -441,9 +441,8 @@ Window { call: window.call isPreview: true - height: (CallStyle.actionArea.userVideo.height * window.height/CallStyle.actionArea.userVideo.heightReference) * scale - width: (CallStyle.actionArea.userVideo.width * window.width/CallStyle.actionArea.userVideo.widthReference) * scale - + height: Math.min(window.height, (CallStyle.actionArea.userVideo.height * window.height/CallStyle.actionArea.userVideo.heightReference) * scale) + width: Math.min(window.width, (CallStyle.actionArea.userVideo.width * window.width/CallStyle.actionArea.userVideo.widthReference) * scale ) DragBox { container: window draggable: parent @@ -457,14 +456,33 @@ Window { var acceleration = 0.1; if(startTime == 0){ startTime = new Date().getTime(); - }else - acceleration = Math.max(0.005,10/(new Date().getTime() - startTime)); - parent.scale = Math.max(0.5 , parent.scale+acceleration*(wheel.angleDelta.y >0 ? 1 : -1) ); - updateBoundaries(); + }else{ + var delay = new Date().getTime() - startTime; + if(delay>0) + acceleration = Math.max(0.1, Math.min(2, 10/delay)); + else + acceleration = 2 + } + var newScale = Math.max(0.1 , parent.scale+acceleration*(wheel.angleDelta.y >0 ? 1 : -1) ); + if( window.height > (CallStyle.actionArea.userVideo.height * window.height/CallStyle.actionArea.userVideo.heightReference) * newScale + && window.width > (CallStyle.actionArea.userVideo.width * window.width/CallStyle.actionArea.userVideo.widthReference) * newScale){ + parent.scale = newScale + var point = mapToItem(cameraPreviewItem.parent, wheel.x, wheel.y); + parent.x = point.x-parent.width/2; + parent.y = point.y-parent.height/2; + updateBoundaries(); + } startTime = new Date().getTime(); } + onDoubleClicked:{ + parent.scale = 1; + resetPosition(); + } onClicked: if(mouse.button == Qt.RightButton) { - parent.scale = 1; + if( parent.scale>1) + parent.scale = 1; + else + parent.scale = 2; resetPosition(); } }