import CameraPlus 1.0
// TODO: I've seen the reticle color changing to red while dragging it but failed to reproduce :(
+// TODO: hide all controls when we are focusing
+// TODO: hide all controls when we are dragging
+
MouseArea {
property int cafStatus: AutoFocus.None
property int status: AutoFocus.None
+ property Camera cam: null
id: mouse
// A 100x100 central "rectangle"
property alias touchMode: reticle.touchMode
- x: cam.renderArea.x
- y: cam.renderArea.y
- width: cam.renderArea.width
- height: cam.renderArea.height
-
- // Changing mode (which implies changing pages) will not reset ROI thus we do it here
- Component.onCompleted: cam.autoFocus.setRegionOfInterest(Qt.rect(0, 0, 0, 0));
+ x: cam ? cam.renderArea.x : 0
+ y: cam ? cam.renderArea.y : 0
+ width: cam ? cam.renderArea.width : 0
+ height: cam ? cam.renderArea.height : 0
+
+ Connections {
+ target: settings
+ // Changing mode (which implies changing pages) will not reset ROI
+ // thus we do it here
+ onModeChanged: {
+ moveToCenter();
+ cam.autoFocus.setRegionOfInterest(Qt.rect(0, 0, 0, 0));
+ }
+ }
+ Connections {
+ target: cam
+ onRunningChanged: {
+ if (cam.running) {
+ setRegionOfInterest();
+ }
+ }
+ }
/*
// This is for debugging
Rectangle {
}
}
+ function moveToCenter() {
+ reticle.anchors.centerIn = reticle.parent;
+ reticle.touchMode = false;
+ }
+
function moveReticle(x, y) {
var xPos = x - ((reticle.width * 1) / 2);
var yPos = y - ((reticle.height * 1) / 2);
yPos = Math.min(Math.max(yPos, drag.minimumY), drag.maximumY);
reticle.x = xPos;
reticle.y = yPos;
+ reticle.anchors.centerIn = undefined;
+ reticle.touchMode = true;
}
function moveToCenterIfNeeded(x, y) {
if (x >= centerRect.x && y >= centerRect.y &&
x <= centerRect.x + centerRect.width &&
y <= centerRect.y + centerRect.height) {
- reticle.x = reticle.center.x
- reticle.y = reticle.center.y
+ moveToCenter();
+ }
+ else {
+ reticle.anchors.centerIn = undefined;
+ reticle.touchMode = true;
}
}
function setRegionOfInterest() {
if (!reticle.touchMode) {
+// console.log("resetting ROI");
cam.autoFocus.setRegionOfInterest(Qt.rect(0, 0, 0, 0));
return;
}
y = y / cam.videoResolution.height;
height = height / cam.videoResolution.height;
+// console.log("Setting ROI to: " + x + " " + y);
cam.autoFocus.setRegionOfInterest(Qt.rect(x, y, width, height));
}
}
onPressed: {
+ reticle.anchors.centerIn = undefined;
moveReticle(mouse.x, mouse.y);
}
FocusRectangle {
id: reticle
property variant center: Qt.point((mouse.width - width) / 2, (mouse.height - height) / 2);
- property bool touchMode: !(reticle.x == center.x && reticle.y == center.y)
+ property bool touchMode: false
scale: mouse.pressed ? 0.6 : touchMode ? 0.8 : 1.0
width: 250
height: 150
- x: center.x
- y: center.y
+
+ anchors.centerIn: parent
color: predictColor(cafStatus, status);
+
+ Behavior on x {
+ PropertyAnimation { duration: 100; }
+ }
+
+ Behavior on y {
+ PropertyAnimation { duration: 100; }
+ }
+
+ Behavior on scale {
+ PropertyAnimation { duration: 100; }
+ }
}
Timer {