diff --git a/qgcresources.qrc b/qgcresources.qrc index 9b045fadf53d3d784b7570fa6186d039c13c795c..ea3c09c4a79ecdafd7089e00e46a9f67c2a27c04 100644 --- a/qgcresources.qrc +++ b/qgcresources.qrc @@ -107,6 +107,7 @@ src/FlightMap/Images/compassInstrumentDial.svg src/FlightMap/Images/crossHair.svg src/FlightMap/Images/PiP.svg + src/FlightMap/Images/pipResize.svg src/FlightMap/Images/rollDialWhite.svg src/FlightMap/Images/rollPointerWhite.svg src/FlightMap/Images/scale.png diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index f2550dc66c0e7df54afa6481151ee204b915e9f7..a76534d55bcee192eca9b9dd4776de5f27184f1e 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -49,7 +49,7 @@ QGCView { property bool _isPipVisible: QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_PIPVisibleKey, true) : false property real _savedZoomLevel: 0 property real _margins: ScreenTools.defaultFontPixelWidth / 2 - property real _pipSize: mainWindow.width * 0.2 + property real _pipSize: flightView.width * 0.2 property alias _guidedController: guidedActionsController property alias _altitudeSlider: altitudeSlider @@ -285,6 +285,9 @@ QGCView { onHideIt: { setPipVisibility(!state) } + onNewWidth: { + _pipSize = newWidth + } } Row { diff --git a/src/FlightMap/Images/pipResize.svg b/src/FlightMap/Images/pipResize.svg new file mode 100644 index 0000000000000000000000000000000000000000..94b3284faa4d890d87b474fb0de215217762ca9a --- /dev/null +++ b/src/FlightMap/Images/pipResize.svg @@ -0,0 +1,373 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/src/QmlControls/QGCPipable.qml b/src/QmlControls/QGCPipable.qml index 2294835a0ec304c1ae5437ef738e9d7c3fb2b832..3a84d47b81306bd46bf9c2a69002b88a4900e18e 100644 --- a/src/QmlControls/QGCPipable.qml +++ b/src/QmlControls/QGCPipable.qml @@ -22,17 +22,100 @@ Item { property bool isHidden: false property bool isDark: false + // As a percentage of the window width + property real maxSize: 0.75 + property real minSize: 0.10 + signal activated() signal hideIt(bool state) + signal newWidth(real newWidth) MouseArea { + id: pipMouseArea anchors.fill: parent enabled: !isHidden + hoverEnabled: true onClicked: { pip.activated() } } + // MouseArea to drag in order to resize the PiP area + MouseArea { + id: pipResize + anchors.top: parent.top + anchors.right: parent.right + height: ScreenTools.minTouchPixels + width: height + property var initialX: 0 + property var initialWidth: 0 + + onClicked: { + // TODO propagate + } + + // When we push the mouse button down, we un-anchor the mouse area to prevent a resizing loop + onPressed: { + pipResize.anchors.top = undefined // Top doesn't seem to 'detach' + pipResize.anchors.right = undefined // This one works right, which is what we really need + pipResize.initialX = mouse.x + pipResize.initialWidth = pip.width + } + + // When we let go of the mouse button, we re-anchor the mouse area in the correct position + onReleased: { + pipResize.anchors.top = pip.top + pipResize.anchors.right = pip.right + } + + // Drag + onPositionChanged: { + if (pipResize.pressed) { + var parentW = pip.parent.width // flightView + var newW = pipResize.initialWidth + mouse.x - pipResize.initialX + if (newW < parentW * maxSize && newW > parentW * minSize) { + newWidth(newW) + } + } + } + } + + // Resize icon + Image { + source: "/qmlimages/pipResize.svg" + fillMode: Image.PreserveAspectFit + mipmap: true + anchors.right: parent.right + anchors.top: parent.top + visible: !isHidden && (ScreenTools.isMobile || pipMouseArea.containsMouse) + height: ScreenTools.defaultFontPixelHeight * 2.5 + width: ScreenTools.defaultFontPixelHeight * 2.5 + sourceSize.height: height + } + + // Resize pip window if necessary when main window is resized + property var pipLock: 2 + + Connections { + target: pip.parent + onWidthChanged: { + // hackity hack... + // don't fire this while app is loading/initializing (it happens twice) + if (pipLock) { + pipLock-- + return + } + + var parentW = pip.parent.width + + if (pip.width > parentW * maxSize) { + newWidth(parentW * maxSize) + } else if (pip.width < parentW * minSize) { + newWidth(parentW * minSize) + } + } + } + //-- PIP Corner Indicator Image { id: closePIP @@ -41,7 +124,7 @@ Item { fillMode: Image.PreserveAspectFit anchors.left: parent.left anchors.bottom: parent.bottom - visible: !isHidden + visible: !isHidden && (ScreenTools.isMobile || pipMouseArea.containsMouse) height: ScreenTools.defaultFontPixelHeight * 2.5 width: ScreenTools.defaultFontPixelHeight * 2.5 sourceSize.height: height