~mterry/+junk/u8.2

« back to all changes in this revision

Viewing changes to qml/Dash/Previews/PreviewImageGallery.qml

  • Committer: Michael Terry
  • Date: 2014-11-17 14:56:04 UTC
  • mfrom: (1317.1.118 unity8)
  • Revision ID: michael.terry@canonical.com-20141117145604-96dn9p5nwkifq2f4
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import QtQuick 2.0
18
18
import Ubuntu.Components 1.1
19
19
import "../../Components"
20
 
import "../../Components/Flickables" as Flickables
21
20
 
22
21
/*! This preview widget shows a horizontal list of images.
23
22
 *  The URIs for the images should be an array in widgetData["sources"].
29
28
 
30
29
    property Item rootItem: QuickUtils.rootItem(root)
31
30
 
32
 
    Flickables.ListView {
 
31
    ListView {
33
32
        id: previewImageListView
34
33
        objectName: "previewImageListView"
35
34
        spacing: units.gu(1)
66
65
                id: mouseArea
67
66
                anchors.fill: parent
68
67
                onClicked: {
69
 
                    slideShowListView.currentIndex = index;
70
 
                    slideShow.initialX = rootItem.mapFromItem(parent, 0, 0).x
71
 
                    slideShow.initialY = rootItem.mapFromItem(parent, 0, 0).y
72
 
                    slideShow.visible = true;
 
68
                    overlay.delegateItem.currentIndex = index;
 
69
                    overlay.initialX = rootItem.mapFromItem(parent, 0, 0).x;
 
70
                    overlay.initialY = rootItem.mapFromItem(parent, 0, 0).y;
 
71
                    overlay.show();
73
72
                }
74
73
            }
75
74
        }
76
75
    }
77
76
 
78
 
    Rectangle {
79
 
        id: slideShow
80
 
        objectName: "slideShow"
81
 
 
82
 
        readonly property real initialScale: previewImageListView.height / rootItem.height
83
 
        readonly property real scaleProgress: (scale - initialScale) / (1.0 - initialScale)
84
 
        property real initialX: 0
85
 
        property real initialY: 0
86
 
 
 
77
    PreviewOverlay {
 
78
        id: overlay
 
79
        objectName: "overlay"
87
80
        parent: rootItem
88
81
        width: parent.width
89
82
        height: parent.height
90
 
        visible: false
91
 
        clip: visible && scale < 1.0
92
 
        scale: visible ? 1.0 : initialScale
93
 
        transformOrigin: Item.TopLeft
94
 
        transform: Translate {
95
 
            x: slideShow.initialX - slideShow.initialX * slideShow.scaleProgress
96
 
            y: slideShow.initialY - slideShow.initialY * slideShow.scaleProgress
97
 
        }
98
 
        color: "black"
99
 
        radius: units.gu(1) - units.gu(1) * slideShow.scaleProgress
100
 
 
101
 
        Behavior on scale {
102
 
            enabled: !slideShow.visible
103
 
            UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
104
 
        }
105
 
 
106
 
        Flickables.ListView {
107
 
            id: slideShowListView
108
 
            objectName: "slideShowListView"
 
83
        initialScale: previewImageListView.height / rootItem.height
 
84
 
 
85
        delegate: ListView {
 
86
            id: overlayListView
 
87
            objectName: "overlayListView"
109
88
            anchors.fill: parent
110
89
            orientation: ListView.Horizontal
111
90
            highlightRangeMode: ListView.StrictlyEnforceRange
120
99
                    top: parent.top
121
100
                    bottom: parent.bottom
122
101
                }
123
 
                width: slideShow.width
 
102
                width: overlay.width
124
103
                source: modelData ? modelData : ""
125
104
                fillMode: Image.PreserveAspectFit
126
105
                sourceSize { width: screenshot.width; height: screenshot.height }
128
107
 
129
108
            MouseArea {
130
109
                anchors.fill: parent
131
 
                onClicked: slideShowHeader.shown = !slideShowHeader.shown
132
 
            }
133
 
        }
134
 
 
135
 
        Rectangle {
136
 
            id: slideShowHeader
137
 
 
138
 
            property bool shown: true
139
 
 
140
 
            anchors {
141
 
                left: parent.left
142
 
                right: parent.right
143
 
            }
144
 
            height: units.gu(7)
145
 
            visible: opacity > 0
146
 
            opacity: slideShow.scaleProgress > 0.6 && shown ? 0.8 : 0
147
 
            color: "black"
148
 
 
149
 
            Behavior on opacity {
150
 
                UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
151
 
            }
152
 
 
153
 
            AbstractButton {
154
 
                id: slideShowCloseButton
155
 
                objectName: "slideShowCloseButton"
156
 
                anchors {
157
 
                    top: parent.top
158
 
                    bottom: parent.bottom
159
 
                }
160
 
                width: units.gu(8)
161
 
                height: width
162
 
 
163
 
                onClicked: slideShow.visible = false
164
 
 
165
 
                Rectangle {
166
 
                    anchors.fill: parent
167
 
                    color: Qt.rgba(1.0, 1.0, 1.0, 0.3)
168
 
                    visible: slideShowCloseButton.pressed
169
 
                }
170
 
 
171
 
                Icon {
172
 
                    id: icon
173
 
                    anchors.centerIn: parent
174
 
                    width: units.gu(2.5)
175
 
                    height: width
176
 
                    color: Theme.palette.normal.foregroundText
177
 
                    name: "close"
178
 
                }
 
110
                onClicked: overlay.headerShown = !overlay.headerShown
179
111
            }
180
112
        }
181
113
    }