lock the UI when user starts to drag the reticle.
authorMohammed Sameer <msameer@foolab.org>
Sun, 21 Jul 2013 19:34:56 +0000 (22:34 +0300)
committerMohammed Sameer <msameer@foolab.org>
Sun, 21 Jul 2013 19:34:56 +0000 (22:34 +0300)
qml/CameraView.qml
qml/FocusReticle.qml

index 48b2855..8ce012e 100644 (file)
@@ -28,7 +28,7 @@ import CameraPlus 1.0
 Camera {
     id: cam
 
-    property bool pressed: loader.item ? loader.item.pressed : false
+    property bool pressed: focusReticle.locked || (loader.item ? loader.item.pressed : false)
     property int policyMode: loader.item ? loader.item.policyMode : CameraResources.None
 
     renderingEnabled: mainView.currentItem == cam
index 40fa7c1..82d267b 100644 (file)
@@ -38,6 +38,8 @@ MouseArea {
     drag.maximumX: width - reticle.width
     drag.maximumY: height - reticle.height
 
+    property bool locked: false
+
     property int cafStatus: AutoFocus.None
     property int status: AutoFocus.None
     property Camera cam
@@ -56,13 +58,28 @@ MouseArea {
 
     property variant __initialPos
     onPressed: {
+
+        if (mouse.x >= reticle.x &&
+            mouse.y >= reticle.y &&
+            mouse.x <= reticle.x + reticle.width &&
+            mouse.y <= reticle.y + reticle.height) {
+            locked = true
+        }
+
         __initialPos = touchPoint
         calculateTouchPoint(mouse.x, mouse.y)
     }
 
-    onReleased: calculateTouchPoint(mouse.x, mouse.y)
+    onReleased: {
+        calculateTouchPoint(mouse.x, mouse.y)
+        locked = false
+    }
+
     onPositionChanged: calculateTouchPoint(mouse.x, mouse.y)
-    onCanceled: calculateTouchPoint(__initialPos.x, __initialPos.y)
+    onCanceled: {
+        calculateTouchPoint(__initialPos.x, __initialPos.y)
+        locked = false
+    }
 
     function resetReticle() {
         calculateTouchPoint(centerRect.x, centerRect.y)