on bbbdccd help sign in
unity8/tests/plugins/Dash/organicgridtry.qml
114 lines 3.3 kB history raw
1/*
2 * Copyright (C) 2014 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.4
18import Dash 0.1
20Item {
21 id: root
22 signal add()
23 signal remove()
25 ListViewWithPageHeader {
26 id: lvwph
27 model: listModel
28 height: parent.height
29 width: parent.width - controls.width
31 delegate: OrganicGrid {
32 id: grid
33 model: gridModel
34 smallDelegateSize: Qt.size(90, 90)
35 bigDelegateSize: Qt.size(180, 180)
36 columnSpacing: 10
37 rowSpacing: 10
38 width: parent.width
39 height: implicitHeight > 100 ? implicitHeight : 100
40 displayMarginBeginning: {
41 if (grid.y + grid.height <= 0) {
42 // Not visible (item at top of the list viewport)
43 return -grid.height;
44 } else if (grid.y >= lvwph.height) {
45 // Not visible (item at bottom of the list viewport)
46 return 0;
47 } else {
48 return -Math.max(-grid.y, 0);
49 }
50 }
51 displayMarginEnd: {
52 if (grid.y + grid.height <= 0) {
53 // Not visible (item at top of the list viewport)
54 return 0;
55 } else if (grid.y >= lvwph.height) {
56 // Not visible (item at bottom of the list viewport)
57 return -grid.height;
58 } else {
59 return -Math.max(grid.height - lvwph.height + grid.y, 0)
60 }
61 }
63 delegate: Rectangle {
64 width: 100
65 color: "red";
66 border.width: 3
68 Text {
69 text: index
70 x: 10
71 y: 10
72 }
73 }
74 }
75 }
77 Rectangle {
78 id: controls
79 height: parent.height
80 width: 100
81 anchors.right: parent.right
82 color: "gray"
83 opacity: 0.4
85 Rectangle {
86 id: addButton
87 height: 50
88 width: parent.width
89 color: "blue"
90 Text {
91 text: "Add"
92 anchors.centerIn: parent
93 }
94 MouseArea {
95 anchors.fill: parent
96 onClicked: root.add()
97 }
98 }
99 Rectangle {
100 anchors.top: addButton.bottom
101 height: 50
102 width: parent.width
103 color: "red"
104 Text {
105 text: "Remove"
106 anchors.centerIn: parent
107 }
108 MouseArea {
109 anchors.fill: parent
110 onClicked: root.remove()
111 }
112 }
113 }