Debian Codegraph @

documentation/snippets/layouts/layout6.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 //![row 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 ItemLayout {
75 item: "green"
76 width: parent.width / 2
77 height: units.gu(20)
78 }
79 }
80 }
81 //![row layout]
82 ]
83 //![default layout]
84 Button {
85 id: redButton
86 text: "Item #1"
87 color: "red"
88 Layouts.item: "red"
89 anchors {
90 left: parent.left
91 top: parent.top
92 bottom: parent.bottom
93 }
94 width: units.gu(15)
95 }
96 Button {
97 id: greenButton
98 text: "Item #2"
99 color: "green"
100 Layouts.item: "green"
101 anchors {
102 top: parent.top
103 left: redButton.right
104 right: parent.right
105 }
106 height: units.gu(10)
107 }
108 Button {
109 id: blueButton
110 text: "Item #3"
111 color: "blue"
112 Layouts.item: "blue"
113 anchors{
114 left: redButton.right
115 right: parent.right
116 bottom: parent.bottom
117 }
118 height: units.gu(10)
119 }
120 //![default layout]
121 }
122 }
123 //![0]