0.9.3-1 release
[ubi] / qml / ubi / components / Showable.qml
1 import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
2 //import "../UIConstants.js" as Const
3
4 Item {
5     id: root
6
7     property bool hidden: false
8     property int easingType: Easing.InOutCubic
9     property int speed: 1
10
11     state: hidden ? "closed" : "opened"
12
13     Component.onCompleted: {
14         if(hidden) state = "closed";
15     }
16
17     function show() {
18         root.state = "opened";
19     }
20
21     function hide() {
22         root.state = "closed";
23     }
24
25     states: [
26         State {
27             name: "opened"
28             PropertyChanges { target: root; y: 0}
29             PropertyChanges { target: root; visible: true }
30         },
31         State {
32             name: "closed"
33             PropertyChanges { target: root; y: root.height }
34         }
35     ]
36
37     transitions: Transition {
38         NumberAnimation { properties: "y"; easing.type: root.easingType;
39             duration: root.speed*root.height/2;
40         }
41     }
42
43     onStateChanged: {
44         if(state=="closed") time.start()
45     }
46
47     Timer {
48         id: time
49         interval: root.speed*root.height/2
50         onTriggered: {
51             root.visible = false;
52         }
53     }
54
55 }