2 * Copyright (C) 2013 Canonical, Ltd.
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.
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.
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/>.
18import Ubuntu.Components 0.1
21 Essentially a GridView where you can specify the maximum number of columns it can have.
24 property int minimumHorizontalSpacing: units.gu(0.5)
25 // property int minimumNumberOfColumns: 2 // FIXME: not implemented
26 property int maximumNumberOfColumns: 6
27 readonly property int columns: gridView.columns
28 property alias verticalSpacing: gridView.verticalSpacing
29 property int delegateWidth
30 property int delegateHeight
31 property alias model: gridView.model
32 property alias delegate: gridView.delegate
33 readonly property int cellWidth: gridView.cellWidth
34 readonly property int cellHeight: gridView.cellHeight
35 readonly property int totalContentHeight: {
36 return contentHeightForRows(Math.ceil(gridView.model.count / columns))
38 property alias interactive: gridView.interactive
39 readonly property alias flicking: gridView.flicking
40 readonly property alias moving: gridView.moving
41 readonly property alias pressDelay: gridView.pressDelay
42 property alias delegateCreationBegin: gridView.delegateCreationBegin
43 property alias delegateCreationEnd: gridView.delegateCreationEnd
45 function contentHeightForRows(rows) {
46 return rows * cellHeight + verticalSpacing
51 objectName: "responsiveGridViewGrid"
56 topMargin: verticalSpacing
58 clip: parent.height != totalContentHeight
60 function pixelToGU(value) {
61 return Math.floor(value / units.gu(1));
64 function spacingForColumns(columns) {
65 // spacing between columns as an integer number of GU, the remainder goes in the margins
66 var spacingGU = pixelToGU(allocatableHorizontalSpace / columns);
67 return units.gu(spacingGU);
70 function columnsForSpacing(spacing) {
71 // minimum margin is half of the spacing
72 return Math.max(1, Math.floor((parent.width - spacing/2) / (delegateWidth + spacing)));
75 property real allocatableHorizontalSpace: parent.width - columns * delegateWidth
76 property int columns: Math.min(columnsForSpacing(minimumHorizontalSpacing), maximumNumberOfColumns)
77 property real horizontalSpacing: spacingForColumns(columns)
78 property real verticalSpacing: horizontalSpacing
79 property int margin: allocatableHorizontalSpace - columns * horizontalSpacing
81 cellWidth: delegateWidth + horizontalSpacing
82 cellHeight: delegateHeight + verticalSpacing
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list