Acceleration sensor control and basic vision framework
[mardrone] / mardrone / JoyStick.qml
1 import Qt 4.7
2
3 Item {
4         id:joystick
5         property int xv:(knob.x-(width-knob.width)/2)*(200/(width-knob.width))
6         property int yv:(knob.y-(height-knob.height)/2)*(200/(height-knob.height))
7         property bool pressed:mouse_area.pressed
8         width: 200
9         height: 200
10
11         Rectangle {
12             id:knob
13             x:parent.width/2-width/2
14             y:parent.width/2-height/2
15             width:20;
16             height:20;
17             Image {
18                 anchors.centerIn:parent
19                 id: knobimage
20                 source: "joyknob.png"
21             }
22
23             //color:"black"
24         }
25         MouseArea {
26             id:mouse_area
27             anchors.fill:parent
28             drag.minimumX:0
29             drag.minimumY:0
30             drag.maximumX:parent.width-knob.width
31             drag.maximumY:parent.height-knob.height
32             drag.target:knob;
33             onReleased:{
34                 knob.x=parent.width/2-knob.width/2;
35                 knob.y=parent.height/2-knob.height/2;
36             }
37         }
38   }