~mterry/+junk/u8

« back to all changes in this revision

Viewing changes to qml/Stage/Spread/WindowedRightEdgeMaths.qml

  • Committer: Michael Zanetti
  • Date: 2016-11-30 13:28:07 UTC
  • mfrom: (2704 unity8)
  • mto: This revision was merged to the branch mainline in revision 2739.
  • Revision ID: michael.zanetti@canonical.com-20161130132807-c314dqdxenzwy69c
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2016 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.4
 
18
import Ubuntu.Components 1.3
 
19
import Unity.Application 0.1
 
20
import "MathUtils.js" as MathUtils
 
21
 
 
22
QtObject {
 
23
    id: root
 
24
 
 
25
    // Input
 
26
    property int itemIndex: 0
 
27
    property int normalZ: 0
 
28
    property real progress: 0
 
29
    property int startWidth: 0
 
30
    property int startHeight: 0
 
31
    property int startX: 0
 
32
    property int targetX: 0
 
33
    property int startY: 0
 
34
    property int targetY: 0
 
35
//    property real startAngle: 40
 
36
    property real targetAngle: 0
 
37
    property int targetHeight: 0
 
38
    property real targetScale: 0
 
39
 
 
40
    // Config
 
41
    property real breakPoint: 0.4
 
42
 
 
43
    // Output
 
44
 
 
45
    readonly property real scaleToPreviewProgress: {
 
46
        return progress < breakPoint ? 0 : MathUtils.clamp(MathUtils.linearAnimation(breakPoint, 1, 0, 1, progress), 0, 1)
 
47
    }
 
48
    readonly property int animatedWidth: {
 
49
        return progress < breakPoint ? root.startWidth : MathUtils.linearAnimation(breakPoint, 1, root.startWidth, targetHeight, progress)
 
50
    }
 
51
 
 
52
    readonly property int animatedHeight: {
 
53
        return progress < breakPoint ? root.startHeight : MathUtils.linearAnimation(breakPoint, 1, root.startHeight, targetHeight, progress)
 
54
    }
 
55
 
 
56
    readonly property int animatedX: {
 
57
        if (progress < breakPoint) {
 
58
            return startX;
 
59
        }
 
60
        return MathUtils.linearAnimation(breakPoint, 1, startX, targetX, progress)
 
61
    }
 
62
 
 
63
    readonly property int animatedY: progress < breakPoint ? startY : MathUtils.linearAnimation(breakPoint, 1, startY, targetY, progress)
 
64
 
 
65
    readonly property real animatedAngle: progress < breakPoint ? 0 : MathUtils.linearAnimation(breakPoint, 1, 0, targetAngle, progress);
 
66
 
 
67
    readonly property real decorationHeight: progress < breakPoint ? 1 : MathUtils.linearAnimation(breakPoint, 1, 1, 0, progress);
 
68
 
 
69
    readonly property int animatedZ: {
 
70
        if (progress < breakPoint + (1 - breakPoint) / 2) {
 
71
            return itemIndex == 1 ? normalZ + 2 : normalZ
 
72
        }
 
73
        return itemIndex
 
74
    }
 
75
 
 
76
    readonly property real opacityMask: itemIndex == 1 ? MathUtils.linearAnimation(0, breakPoint, 0, 1, progress) : 1
 
77
 
 
78
    readonly property real animatedScale: progress < breakPoint ? 1 : MathUtils.linearAnimation(breakPoint, 1, 1, targetScale, progress)
 
79
 
 
80
//    readonly property bool itemVisible: true //animatedX < sceneWidth
 
81
}