~unity-team/unity8/ota9.5

« back to all changes in this revision

Viewing changes to tests/qmltests/Components/RevealingRectangle.qml

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU 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 General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
import QtQuick 2.0
 
18
import Ubuntu.Components 0.1
 
19
import "../../../Components"
 
20
 
 
21
Item {
 
22
    id: revealingRectangle
 
23
 
 
24
    property int orientation: Qt.Vertical
 
25
    property int direction: Qt.LeftToRight
 
26
    property Revealer revealer: __revealer
 
27
    property Showable showable: __showable
 
28
 
 
29
    Revealer {
 
30
        id: __revealer
 
31
 
 
32
        target: __showable
 
33
        width: target.width
 
34
        height: target.height
 
35
        x: orientation == Qt.Vertical ? 0 : direction == Qt.LeftToRight ? 0 : parent.width - width
 
36
        y: orientation == Qt.Horizontal ? 0 : direction == Qt.LeftToRight ? 0 : parent.height - height
 
37
        handleSize: orientation == Qt.Vertical ? handle.height : handle.width
 
38
        hintDisplacement: handleSize
 
39
        orientation: revealingRectangle.orientation
 
40
        direction: revealingRectangle.direction
 
41
    }
 
42
 
 
43
    Showable {
 
44
        id: __showable
 
45
 
 
46
        width: orientation == Qt.Horizontal ? units.gu(24) : parent.width
 
47
        height: orientation == Qt.Vertical ? units.gu(24) : parent.height
 
48
 
 
49
        shown: false
 
50
        showAnimation: SmoothedAnimation {
 
51
            property: orientation == Qt.Horizontal ? "x" : "y"
 
52
            velocity: __revealer.dragVelocity
 
53
            duration: 200
 
54
            to: __revealer.openedValue
 
55
        }
 
56
        hideAnimation: SmoothedAnimation {
 
57
            property: orientation == Qt.Horizontal ? "x" : "y"
 
58
            velocity: __revealer.dragVelocity
 
59
            duration: 200
 
60
            to: __revealer.closedValue
 
61
        }
 
62
 
 
63
        Rectangle {
 
64
            anchors.fill: parent
 
65
            color: "red"
 
66
        }
 
67
 
 
68
        Rectangle {
 
69
            id: handle
 
70
 
 
71
            x: orientation == Qt.Vertical ? 0 : direction == Qt.LeftToRight ? parent.width - width : 0
 
72
            y: orientation == Qt.Horizontal ? 0 : direction == Qt.LeftToRight ? parent.height - height : 0
 
73
            width: orientation == Qt.Horizontal ? units.gu(2) : parent.width
 
74
            height: orientation == Qt.Vertical ? units.gu(2) : parent.height
 
75
            color: "black"
 
76
        }
 
77
    }
 
78
}