~josephjamesmills/ubuntutv/mockup-ppa-branch

« back to all changes in this revision

Viewing changes to Unity-2d/ubuntu-tv/shell/dash/RendererCoverFlow.qml

  • Committer: Joseph Mills
  • Date: 2012-11-19 21:25:03 UTC
  • Revision ID: josephjamesmills@gmail.com-20121119212503-lwix013dozhb0ar4
adding Unity 2d stuff

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of unity-2d
 
3
 *
 
4
 * Copyright 2010-2011 Canonical Ltd.
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; version 3.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
import QtQuick 1.0
 
20
import Unity2d 1.0
 
21
import "../common"
 
22
import "../common/units.js" as Units
 
23
import "../common/utils.js" as Utils
 
24
 
 
25
Renderer {
 
26
    needHeader: true
 
27
    currentItem: flow.currentItem
 
28
    /* FIXME: should be defined as a property of Renderer */
 
29
    property int contentHeight: Units.tvPx(540)
 
30
 
 
31
    ListView {
 
32
        id: flow
 
33
 
 
34
        property real margin: Units.tvPx(90)
 
35
        property real itemWidth: Units.tvPx(210)
 
36
 
 
37
        property int duration: 120
 
38
 
 
39
        anchors.fill: parent
 
40
        anchors.topMargin: Units.tvPx(140)
 
41
        anchors.bottomMargin: Units.tvPx(60)
 
42
        /* Make sure the first and last items are offsetted by margin */
 
43
        anchors.leftMargin: margin
 
44
        anchors.rightMargin: margin
 
45
        cacheBuffer: margin*2
 
46
        focus: true
 
47
        orientation: ListView.Horizontal
 
48
        spacing: Units.tvPx(80)
 
49
        highlightMoveSpeed: -1
 
50
        highlightMoveDuration: 230
 
51
        highlightRangeMode: ListView.ApplyRange
 
52
        preferredHighlightBegin: margin + itemWidth
 
53
        preferredHighlightEnd: width - margin - itemWidth
 
54
        snapMode: ListView.SnapToItem
 
55
        model: category_model
 
56
 
 
57
        delegate: AbstractButton {
 
58
            id: button
 
59
 
 
60
            property string uri: column_0
 
61
            property string iconHint: column_1
 
62
            property string categoryIndex: column_2
 
63
            property string mimetype: column_3
 
64
            property string name: column_4
 
65
            property string comment: column_5
 
66
            property string dndUri: column_6
 
67
 
 
68
            width: flow.itemWidth
 
69
            height: flow.height
 
70
 
 
71
            property variant segments: [-flow.itemWidth, 0.0, flow.width-flow.itemWidth, flow.width-flow.itemWidth+flow.itemWidth]
 
72
            property real absoluteX: button.x-flow.contentX
 
73
 
 
74
            property real angle
 
75
            angle: Utils.segmentsLinearInterpolation(segments, [63.0, 0.0, 0.0, -63.0], absoluteX)
 
76
            property real origin
 
77
            origin: Utils.segmentsLinearInterpolation(segments, [width, width, 0.0, 0.0], absoluteX)
 
78
            //Behavior on angle {SmoothedAnimation {durshadowation: flow.duration; velocity: -1}}
 
79
            transform: Rotation { origin.x: button.origin; origin.y: height/2; axis { x: 0; y: 1; z: 0 } angle: button.angle}
 
80
 
 
81
            scale: Utils.segmentsLinearInterpolation(segments, [0.8, 1.0, 1.0, 0.8], absoluteX)
 
82
            //Behavior on scale {SmoothedAnimation {duration: flow.duration; velocity: -1}}
 
83
 
 
84
            onClicked: dash.activateUriWithLens(lens, categoryId, uri, mimetype)
 
85
 
 
86
            Item {
 
87
                id: iconImage
 
88
 
 
89
                anchors.top: parent.top
 
90
                anchors.topMargin: Units.tvPx(-10)
 
91
                height: Units.tvPx(225)
 
92
                anchors.left: parent.left
 
93
                anchors.right: parent.right
 
94
                Item {
 
95
                    width: parent.width
 
96
                    height: parent.height
 
97
//                    anchors.centerIn
 
98
 
 
99
                    Image {
 
100
                        //anchors.verticalCenter: parent.bottom
 
101
                        anchors.horizontalCenter: parent.horizontalCenter
 
102
                        anchors.top: parent.top
 
103
                        anchors.topMargin: Units.tvPx(350)
 
104
                        width: Units.tvPx(380)
 
105
                        height: Units.tvPx(120)
 
106
                        source: "artwork/coverflow_shadow.png"
 
107
                        fillMode: Image.Center
 
108
                    }
 
109
 
 
110
                    Image {
 
111
                        source: "artwork/selection_glow.png"
 
112
                        anchors.fill: image
 
113
//                        height: Units.tvPx(350)
 
114
                        anchors.margins: Units.tvPx(-45)
 
115
                        opacity: button.activeFocus ? 1.0 : 0.0
 
116
                        Behavior on opacity {NumberAnimation {duration: 200; easing.type: Easing.OutQuad}}
 
117
                    }
 
118
 
 
119
                    Rectangle {
 
120
                        id: outline
 
121
                        anchors.fill: parent
 
122
                        anchors.margins: Units.tvPx(-2)
 
123
                        color: "#00000000"
 
124
                        smooth: true
 
125
                        border.width: Units.tvPx(1)
 
126
                        border.color: "transparent"
 
127
                        radius: Units.tvPx(2)
 
128
                    }
 
129
 
 
130
                    Image {
 
131
                        id: image
 
132
 
 
133
                        anchors.centerIn: parent
 
134
                        anchors.top: parent.top
 
135
                        anchors.topMargin: Units.tvPx(120)
 
136
                        width: Units.tvPx(250)
 
137
                        height: Units.tvPx(400)
 
138
                        fillMode: Image.Stretch
 
139
                        clip: true
 
140
                        source:if(status == Image.Error ){
 
141
                                 source: iconHint
 
142
                               }else{
 
143
                                   source: "image://icons/"+iconHint;
 
144
}
 
145
//source:  status  == Image.Error ? iconHint : "image://icons/"+iconHint
 
146
                        sourceSize.width: width
 
147
                        sourceSize.height: height
 
148
                        smooth: true
 
149
                        asynchronous: true
 
150
//                        scale: status == Image.Ready ? 1.0 : 0.0
 
151
//                        Behavior on scale {
 
152
//                            NumberAnimation {
 
153
//                                duration: 1200;
 
154
//                                from: 0
 
155
//                                to: 1
 
156
//                                easing.type: Easing.OutBounce
 
157
//                            }
 
158
//                        }
 
159
                    }
 
160
 
 
161
                    Rectangle {
 
162
                        id: txtrectangle
 
163
                        anchors.fill: image.Center
 
164
                        anchors.top: parent.top
 
165
                        anchors.topMargin: Units.tvPx(250)
 
166
                        opacity: button.state == "hovered" || button.state == "selected-hovered" ? 0.4 : 0.0
 
167
                        Behavior on opacity { NumberAnimation { duration: 100 } }
 
168
                    }
 
169
 
 
170
                    TextMultiLine {
 
171
                        id: label
 
172
                        wrapMode: Text.WrapAtWordBoundaryOrAnywhere
 
173
                        anchors.top: txtrectangle.bottom
 
174
//                        anchors.bottom: parent.bottom
 
175
                        anchors.right: parent.right
 
176
                        anchors.left: parent.left
 
177
                        anchors.topMargin: Units.tvPx(80)
 
178
 
 
179
                        text: name
 
180
                        opacity: Utils.segmentsLinearInterpolation(segments, [0.0, 1.0, 1.0, 0.0], absoluteX)
 
181
                        //Behavior on opacity {SmoothedAnimation {duration: flow.duration; velocity: -1}}
 
182
                        color: "#ffffff"
 
183
                        horizontalAlignment: Text.AlignHCenter
 
184
                        fontSize: "small"
 
185
                        style: Text.Raised
 
186
                        styleColor: "#1e1e1e"
 
187
                    }
 
188
                }
 
189
            }
 
190
        }
 
191
    }
 
192
}