| 1 |
/* |
| 2 |
* Copyright 2015 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.4 |
| 18 |
import Lomiri.Components 1.3 |
| 19 |
|
| 20 |
Item { |
| 21 |
// style API |
| 22 |
property alias handPointer: pointer |
| 23 |
|
| 24 |
function handPreset(index, property) { |
| 25 |
switch (property) { |
| 26 |
case "width" : |
| 27 |
return (index === 0) ? units.gu(0.8) : units.gu(0.5); |
| 28 |
case "height": |
| 29 |
return (index === 0) ? dialer.handSpace /2 : |
| 30 |
(index === 2) ? dialer.handSpace + units.gu(1.5) : |
| 31 |
dialer.handSpace - units.gu(1.5); |
| 32 |
case "z": |
| 33 |
return (index === 2) ? -1 : 0; |
| 34 |
case "visible": |
| 35 |
case "draggable": |
| 36 |
return true; |
| 37 |
case "toCenterItem": |
| 38 |
return false; |
| 39 |
default: |
| 40 |
return undefined; |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
// style |
| 45 |
anchors.fill: parent |
| 46 |
transformOrigin: Item.Center |
| 47 |
|
| 48 |
Rectangle { |
| 49 |
id: pointer |
| 50 |
x: (parent.width - width) / 2 |
| 51 |
y: styledItem.dialer.handSpace - (styledItem.hand.toCenterItem ? 0 : styledItem.hand.height) |
| 52 |
width: styledItem.hand.width |
| 53 |
height: styledItem.hand.height |
| 54 |
radius: units.gu(1) |
| 55 |
color: styledItem.hand.visible ? theme.palette.normal.baseText : "#00000000" |
| 56 |
antialiasing: true |
| 57 |
} |
| 58 |
|
| 59 |
Behavior on rotation { |
| 60 |
enabled: !styledItem.hand.draggable |
| 61 |
RotationAnimation { direction: RotationAnimation.Shortest } |
| 62 |
} |
| 63 |
} |