Unity 8
 All Classes Functions
CardCarousel.qml
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 DashRenderer {
22  id: cardCarousel
23 
24  expandedHeight: carousel.implicitHeight + units.gu(6)
25  collapsedHeight: expandedHeight
26 
27  Carousel {
28  id: carousel
29  anchors.fill: parent
30  tileAspectRatio: cardTool.components && cardTool.components["art"]["aspect-ratio"] || 1.0
31  // FIXME we need to "reverse" the carousel to make the selected item the size
32  // and push others back.
33  minimumTileWidth: cardTool.cardWidth / selectedItemScaleFactor
34  selectedItemScaleFactor: cardTool.carouselSelectedItemScaleFactor
35  cacheBuffer: 1404 // 18px * 13gu * 6
36  model: cardCarousel.model
37 
38  property real fontScale: 1 / selectedItemScaleFactor
39  property real headerHeight: cardTool.headerHeight / selectedItemScaleFactor
40 
41  itemComponent: Loader {
42  id: loader
43 
44  property bool explicitlyScaled
45  property var model
46  property int index
47  enabled: false
48 
49  objectName: "carouselDelegate" + index
50 
51  function clicked() { cardCarousel.clicked(index, model.result, loader.item, model) }
52  function pressAndHold() { cardCarousel.pressAndHold(index, model) }
53 
54  sourceComponent: cardTool.cardComponent
55  onLoaded: {
56  item.fixedHeaderHeight = Qt.binding(function() { return carousel.headerHeight; });
57  item.height = Qt.binding(function() { return cardTool.cardHeight; });
58  item.cardData = Qt.binding(function() { return model; });
59  item.template = Qt.binding(function() { return cardTool.template; });
60  item.components = Qt.binding(function() { return cardTool.components; });
61  item.fontScale = Qt.binding(function() { return carousel.fontScale; });
62  item.showHeader = Qt.binding(function() { return loader.explicitlyScaled; });
63  item.artShapeBorderSource = "none";
64  item.scopeStyle = cardCarousel.scopeStyle;
65  }
66 
67  BorderImage {
68  anchors {
69  fill: parent
70  margins: -units.gu(1)
71  }
72  z: -1
73  source: "graphics/carousel_dropshadow.sci"
74  }
75  }
76  }
77 }