on 4e77f91 help sign in
unity8/qml/Dash/CardCarousel.qml
80 lines 3.2 kB history raw
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 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import "../Components"
21DashRenderer {
22 id: cardCarousel
24 property alias cacheBuffer: carousel.cacheBuffer
25 property alias itemComponent: carousel.itemComponent
26 property alias minimumTileWidth: carousel.minimumTileWidth
27 property alias selectedItemScaleFactor: carousel.selectedItemScaleFactor
28 property alias tileAspectRatio: carousel.tileAspectRatio
30 height: carousel.implicitHeight + units.gu(6)
32 Carousel {
33 id: carousel
34 anchors.fill: parent
35 tileAspectRatio: cardTool.components && cardTool.components["art"]["aspect-ratio"] || 1.0
36 // FIXME we need to "reverse" the carousel to make the selected item the size
37 // and push others back.
38 minimumTileWidth: cardTool.cardWidth / selectedItemScaleFactor
39 selectedItemScaleFactor: cardTool.carouselSelectedItemScaleFactor
40 cacheBuffer: 1404 // 18px * 13gu * 6
41 model: cardCarousel.model
43 property real fontScale: 1 / selectedItemScaleFactor
44 property real headerHeight: cardTool.headerHeight / selectedItemScaleFactor
46 itemComponent: Loader {
47 id: loader
49 property bool explicitlyScaled
50 property var model
51 enabled: false
53 function clicked() { cardCarousel.clicked(index, model.result) }
54 function pressAndHold() { cardCarousel.pressAndHold(index, model.result) }
56 sourceComponent: cardTool.cardComponent
57 onLoaded: {
58 item.objectName = "carouselDelegate" + index;
59 item.fixedHeaderHeight = Qt.binding(function() { return carousel.headerHeight; });
60 item.height = Qt.binding(function() { return cardTool.cardHeight; });
61 item.cardData = Qt.binding(function() { return model; });
62 item.template = Qt.binding(function() { return cardTool.template; });
63 item.components = Qt.binding(function() { return cardTool.components; });
64 item.fontScale = Qt.binding(function() { return carousel.fontScale; });
65 item.showHeader = Qt.binding(function() { return loader.explicitlyScaled; });
66 item.artShapeBorderSource = "none";
67 item.scopeStyle = cardCarousel.scopeStyle;
68 }
70 BorderImage {
71 anchors {
72 fill: parent
73 margins: -units.gu(1)
74 }
75 z: -1
76 source: "graphics/carousel_dropshadow.sci"
77 }
78 }
79 }