Debian Codegraph @

tests/unit/layouts13/NestedVisibility.qml

raw
1 /*
2 * Copyright 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 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 import QtQuick 2.0
18 import Lomiri.Components 1.1
19 import Lomiri.Layouts 1.0
20
21 MainView {
22 id: main
23 objectName: "mainView"
24 applicationName: "test-app"
25
26 /*
27 This property enables the application to change orientation
28 when the device is rotated. The default is false.
29 */
30 automaticOrientation: true // TODO: support wide aspect ratios, esp. on prepareGamePage
31
32 width: units.gu(40)
33 height: units.gu(75)
34
35 function phoneLayout() {
36 width = units.gu(50);
37 }
38 function tabletPortraitLayout() {
39 width = units.gu(70);
40 }
41 function tabletLandscapeLayout() {
42 width = units.gu(100);
43 }
44
45 PageStack {
46 Component.onCompleted: push(testPage)
47
48 Page {
49 title: i18n.tr("Conditional Layouts with PageStack")
50 id: testPage
51 visible: false
52
53 Layouts {
54 id: layouts
55 objectName: "mainLayout"
56 width: parent.width
57 height: parent.height
58 layouts: [
59 ConditionalLayout {
60 name: "tabletPortrait"
61 when: main.width > units.gu(50)
62 Layouts {
63 anchors.fill: parent
64 objectName: "nestedLayout"
65 layouts: [
66 ConditionalLayout {
67 name: "tabletLandscape"
68 when: main.width > units.gu(70)
69 Row {
70 objectName: "tabletLandscape"
71 anchors.fill: parent
72 Rectangle {
73 height: parent.height
74 color: "white"
75 width: parent.width / 5
76 }
77 Flow {
78 spacing: units.gu(2)
79 ItemLayout {
80 objectName: "nestedMagentaContainer"
81 item: "mainMagenta"
82 width: units.gu(20)
83 height: width
84 }
85 ItemLayout {
86 objectName: "nestedGreenContainer"
87 item: "mainGreen"
88 width: units.gu(60)
89 height: width
90 }
91 }
92 }
93 }
94 ]
95 // Default layout, but can have ItemLayouts
96 // as those will belong to the previous Layouts
97 // and attaching Layouts.item we can layout it further
98 Flow {
99 objectName: "tabletPortrait"
100 anchors.fill: parent
101 ItemLayout {
102 objectName: "greenContainer"
103 item: "mainGreen"
104 width: units.gu(40)
105 height: width
106 Layouts.item: item
107 }
108 ItemLayout {
109 objectName: "magentaContainer"
110 item: "mainMagenta"
111 width: units.gu(60)
112 height: width
113 Layouts.item: item
114 }
115 }
116 }
117 }
118 ]
119
120 // default layout for mainLayout
121 Flow {
122 objectName: "mainDefaultLayout"
123 anchors.fill: parent
124 Rectangle {
125 objectName: "mainRed"
126 width: units.gu(15)
127 height: width
128 color: "red"
129 Layouts.item: "mainRed"
130 }
131 Rectangle {
132 objectName: "mainGreen"
133 width: units.gu(15)
134 height: width
135 color: "green"
136 Layouts.item: "mainGreen"
137 }
138 Rectangle {
139 objectName: "mainBlue"
140 width: units.gu(15)
141 height: width
142 color: "blue"
143 Layouts.item: "mainBlue"
144 }
145 Rectangle {
146 objectName: "mainMagenta"
147 width: units.gu(15)
148 height: width
149 color: "magenta"
150 Layouts.item: "mainMagenta"
151 }
152 Rectangle {
153 objectName: "mainHidden"
154 width: units.gu(15)
155 height: width
156 color: "yellow"
157 visible: false
158 }
159 }
160 }
161 }
162 }
163 }