[ui] Viewer2D: allow to change the size of the Fisheye circle with Ctrl+Wheel

* also add forceActiveFocus() to release other focus areas
This commit is contained in:
Fabien Castan 2020-03-18 20:23:37 +01:00
parent e933e1adf6
commit e88651ba01
2 changed files with 22 additions and 9 deletions

View file

@ -4,6 +4,7 @@ Rectangle {
id: root
signal moved()
signal incrementRadius(real radiusOffset)
width: radius * 2
height: width
@ -32,21 +33,30 @@ Rectangle {
MouseArea {
id: mArea
anchors.fill: parent
cursorShape: Qt.OpenHandCursor
cursorShape: controlModifierEnabled ? Qt.SizeBDiagCursor : (pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor)
property bool controlModifierEnabled: false
onPositionChanged: {
mArea.controlModifierEnabled = (mouse.modifiers & Qt.ControlModifier)
}
acceptedButtons: Qt.LeftButton
hoverEnabled: true
drag.target: parent
drag.onActiveChanged:
{
if(!drag.active)
{
cursorShape = Qt.OpenHandCursor;
drag.onActiveChanged: {
if(!drag.active) {
moved();
}
else
{
cursorShape = Qt.ClosedHandCursor;
}
onPressed: {
forceActiveFocus();
}
onWheel: {
mArea.controlModifierEnabled = (wheel.modifiers & Qt.ControlModifier)
if (wheel.modifiers & Qt.ControlModifier) {
incrementRadius(wheel.angleDelta.y / 120.0);
wheel.accepted = true;
} else {
wheel.accepted = false;
}
}
}

View file

@ -260,6 +260,9 @@ FocusScope {
_reconstruction.setAttribute(_reconstruction.panoramaInit.attribute("fisheyeCenterOffset.fisheyeCenterOffset_x"), x)
_reconstruction.setAttribute(_reconstruction.panoramaInit.attribute("fisheyeCenterOffset.fisheyeCenterOffset_y"), y)
}
onIncrementRadius: {
_reconstruction.setAttribute(_reconstruction.panoramaInit.attribute("fisheyeRadius"), _reconstruction.panoramaInit.attribute("fisheyeRadius").value + radiusOffset)
}
}
}
}