Debian Codegraph @

documentation/snippets/layouts/layout7.qml

raw
1 /*
2 * Copyright 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 Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 //![0]
18 import QtQuick 2.4
19 import Lomiri.Components 1.2
20 import Lomiri.Layouts 1.0
21
22 Item {
23 id: root
24 width: units.gu(30)
25 height: units.gu(30)
26
27 Layouts {
28 objectName: "layouts"
29 id: layouts
30 anchors.fill: parent
31
32 layouts: [
33 //![flow layout]
34 ConditionalLayout {
35 name: "flow"
36 when: layouts.width > units.gu(70)
37 Flow {
38 anchors.fill: parent
39 ItemLayout {
40 item: "red"
41 width: units.gu(20)
42 height: units.gu(20)
43 }
44 ItemLayout {
45 item: "green"
46 width: units.gu(20)
47 height: units.gu(20)
48 }
49 ItemLayout {
50 item: "blue"
51 width: units.gu(20)
52 height: units.gu(20)
53 }
54 Button {
55 text: "Flow item"
56 width: units.gu(20)
57 height: units.gu(20)
58 }
59 }
60 }
61 //![flow layout]
62 ,
63 //![overlay layout]
64 ConditionalLayout {
65 name: "row"
66 when: layouts.width > units.gu(50)
67 Row {
68 anchors.fill: parent
69 ItemLayout {
70 item: "red"
71 width: parent.width / 2
72 height: units.gu(20)
73
74 Rectangle {
75 anchors{
76 left: parent.left
77 right: parent.right
78 bottom: parent.bottom
79 margins: units.dp(3)
80 }
81 radius: units.dp(1)
82 height: units.gu(8)
83 color: "#bbbbbb88"
84 Label {
85 anchors.centerIn: parent
86 text: "Overlay item"
87 }
88 }
89 }
90 ItemLayout {
91 item: "green"
92 width: parent.width / 2
93 height: units.gu(20)
94 }
95 }
96 }
97 //![overlay layout]
98 ]
99 //![default layout]
100 Button {
101 id: redButton
102 text: "Item #1"
103 color: "red"
104 Layouts.item: "red"
105 anchors {
106 left: parent.left
107 top: parent.top
108 bottom: parent.bottom
109 }
110 width: units.gu(15)
111 }
112 Button {
113 id: greenButton
114 text: "Item #2"
115 color: "green"
116 Layouts.item: "green"
117 anchors {
118 top: parent.top
119 left: redButton.right
120 right: parent.right
121 }
122 height: units.gu(10)
123 }
124 Button {
125 id: blueButton
126 text: "Item #3"
127 color: "blue"
128 Layouts.item: "blue"
129 anchors{
130 left: redButton.right
131 right: parent.right
132 bottom: parent.bottom
133 }
134 height: units.gu(10)
135 }
136 //![default layout]
137 }
138 }
139 //![0]