Commit e4f2220b authored by Jacob Walser's avatar Jacob Walser

Click and drag to resize PiP window instead of grow and shrink buttons

parent 17770480
...@@ -107,6 +107,7 @@ ...@@ -107,6 +107,7 @@
<file alias="compassInstrumentDial.svg">src/FlightMap/Images/compassInstrumentDial.svg</file> <file alias="compassInstrumentDial.svg">src/FlightMap/Images/compassInstrumentDial.svg</file>
<file alias="crossHair.svg">src/FlightMap/Images/crossHair.svg</file> <file alias="crossHair.svg">src/FlightMap/Images/crossHair.svg</file>
<file alias="PiP.svg">src/FlightMap/Images/PiP.svg</file> <file alias="PiP.svg">src/FlightMap/Images/PiP.svg</file>
<file alias="pipResize.svg">src/FlightMap/Images/pipResize.svg</file>
<file alias="rollDialWhite.svg">src/FlightMap/Images/rollDialWhite.svg</file> <file alias="rollDialWhite.svg">src/FlightMap/Images/rollDialWhite.svg</file>
<file alias="rollPointerWhite.svg">src/FlightMap/Images/rollPointerWhite.svg</file> <file alias="rollPointerWhite.svg">src/FlightMap/Images/rollPointerWhite.svg</file>
<file alias="scale.png">src/FlightMap/Images/scale.png</file> <file alias="scale.png">src/FlightMap/Images/scale.png</file>
......
...@@ -311,23 +311,8 @@ QGCView { ...@@ -311,23 +311,8 @@ QGCView {
onHideIt: { onHideIt: {
setPipVisibility(!state) setPipVisibility(!state)
} }
onGrow: { onNewWidth: {
if (_pipSize >= 825) { _pipSize = newWidth
return
}
_pipSize += 50
_flightVideoPipControl.width = _pipSize
_flightVideoPipControl.height= _pipSize * (9/16)
}
onShrink: {
if (_pipSize <= 225) {
return
}
_pipSize -= 50
_flightVideoPipControl.width = _pipSize
_flightVideoPipControl.height= _pipSize * (9/16)
} }
} }
......
This diff is collapsed.
...@@ -22,43 +22,98 @@ Item { ...@@ -22,43 +22,98 @@ Item {
property bool isHidden: false property bool isHidden: false
property bool isDark: 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 activated()
signal hideIt(bool state) signal hideIt(bool state)
signal grow() signal newWidth(real newWidth)
signal shrink()
MouseArea { MouseArea {
id: pipMouseArea
anchors.fill: parent anchors.fill: parent
enabled: !isHidden enabled: !isHidden
hoverEnabled: true
onClicked: { onClicked: {
pip.activated() pip.activated()
} }
} }
QGCButton { // MouseArea to drag in order to resize the PiP area
id: growButton MouseArea {
visible: !isHidden && !ScreenTools.isShortScreen && !ScreenTools.isTinyScreen id: pipResize
anchors.left: parent.left anchors.top: parent.top
anchors.bottom: shrinkButton.top anchors.right: parent.right
height: 20 height: ScreenTools.minTouchPixels
width: height width: height
anchors.margins: 5 property var initialX: 0
text: "+" property var initialWidth: 0
opacity: 0.5
onClicked: pip.grow() 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)
}
}
}
} }
QGCButton { // Resize icon
id: shrinkButton Image {
visible: !isHidden && !ScreenTools.isShortScreen && !ScreenTools.isTinyScreen source: "/qmlimages/pipResize.svg"
anchors.left: parent.left fillMode: Image.PreserveAspectFit
anchors.bottom: closePIP.top mipmap: true
height: 20 anchors.right: parent.right
width: height anchors.top: parent.top
anchors.margins: 5 visible: !isHidden && pipMouseArea.containsMouse
text: "-" height: ScreenTools.defaultFontPixelHeight * 2.5
opacity: 0.5 width: ScreenTools.defaultFontPixelHeight * 2.5
onClicked: pip.shrink() 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 //-- PIP Corner Indicator
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment