Debian Codegraph @

documentation/snippets/layouts/layout2.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 //![row layout]
34 ConditionalLayout {
35 name: "row"
36 when: layouts.width > units.gu(50)
37 Row {
38 anchors.fill: parent
39 ItemLayout {
40 item: "blue"
41 width: parent.width / 3
42 anchors {
43 top: parent.top
44 bottom: parent.bottom
45 }
46 }
47 ItemLayout {
48 item: "red"
49 width: parent.width / 3
50 anchors {
51 top: parent.top
52 bottom: parent.bottom
53 }
54 }
55 ItemLayout {
56 item: "green"
57 width: parent.width / 3
58 anchors {
59 top: parent.top
60 bottom: parent.bottom
61 }
62 }
63 }
64 }
65 //![row layout]
66 ]
67 //![default layout]
68 Button {
69 id: redButton
70 text: "Item #1"
71 color: "red"
72 Layouts.item: "red"
73 anchors {
74 left: parent.left
75 top: parent.top
76 bottom: parent.bottom
77 }
78 width: units.gu(15)
79 }
80 Button {
81 id: greenButton
82 text: "Item #2"
83 color: "green"
84 Layouts.item: "green"
85 anchors {
86 top: parent.top
87 left: redButton.right
88 right: parent.right
89 }
90 height: units.gu(10)
91 }
92 Button {
93 id: blueButton
94 text: "Item #3"
95 color: "blue"
96 Layouts.item: "blue"
97 anchors{
98 left: redButton.right
99 right: parent.right
100 bottom: parent.bottom
101 }
102 height: units.gu(10)
103 }
104 //![default layout]
105 }
106 }
107 //![0]