]> Pileus Git - ~andy/gtk/blob - tests/reftests/align-expand.sh
reftests: Add a test comparing inherit and initial
[~andy/gtk] / tests / reftests / align-expand.sh
1 #!/bin/bash
2 #
3 # align-expand.sh [METHOD]
4 #
5 # This is the script used to create the align-expand tests. These tests
6 # put a 20x20 size-requested GtkTreeView into a 40x40 size-requested
7 # container and try to achieve multiple combinations of expand and align
8 # flags. The resulting GtkBuilder file is written to stdout. All of the
9 # resulting files should render identical.
10 #
11 # METHOD is one of:
12 # * flags (default)
13 #   Uses expand flags to align and expand the treeview inside a GtkGrid.
14 #   You should use this as the reference when adding tests for other
15 #   methods
16 # * alignment
17 #   Aligns and expands the treeview in a GtkAlignment using its scale
18 #   and align properties.
19
20
21 if test $# -lt 1; then
22   method="flags"
23 else
24   method=$1
25 fi
26
27 cat << EOF
28 <?xml version="1.0" encoding="UTF-8"?>
29 <interface>
30   <!-- interface-requires gtk+ 3.0 -->
31   <object class="GtkWindow" id="window">
32     <property name="can_focus">False</property>
33     <property name="type">popup</property>
34     <child>
35       <object class="GtkGrid" id="grid">
36         <property name="visible">True</property>
37         <property name="can_focus">False</property>
38         <property name="row_spacing">2</property>
39         <property name="column_spacing">2</property>
40 EOF
41
42
43 y=2
44 for hexpand in False True; do
45 for halign in "start" center end fill; do
46
47 cat << EOF
48         <child>
49           <object class="GtkLabel" id="hexpand-$halign-$hexpand">
50             <property name="visible">True</property>
51             <property name="can_focus">False</property>
52             <property name="label">$hexpand</property>
53             <property name="angle">90</property>
54           </object>
55           <packing>
56             <property name="left_attach">$y</property>
57             <property name="top_attach">0</property>
58             <property name="width">1</property>
59             <property name="height">1</property>
60           </packing>
61         </child>
62         <child>
63           <object class="GtkLabel" id="halign-$halign-$hexpand">
64             <property name="visible">True</property>
65             <property name="can_focus">False</property>
66             <property name="label">$halign</property>
67             <property name="angle">90</property>
68           </object>
69           <packing>
70             <property name="left_attach">$y</property>
71             <property name="top_attach">1</property>
72             <property name="width">1</property>
73             <property name="height">1</property>
74           </packing>
75         </child>
76 EOF
77 x=2
78 for vexpand in False True; do
79 for valign in "start" center end fill; do
80
81 if test $y = "2"; then
82 cat << EOF
83         <child>
84           <object class="GtkLabel" id="vexpand-$valign-$vexpand">
85             <property name="visible">True</property>
86             <property name="can_focus">False</property>
87             <property name="label">$vexpand</property>
88           </object>
89           <packing>
90             <property name="left_attach">0</property>
91             <property name="top_attach">$x</property>
92             <property name="width">1</property>
93             <property name="height">1</property>
94           </packing>
95         </child>
96         <child>
97           <object class="GtkLabel" id="valign-$valign-$vexpand">
98             <property name="visible">True</property>
99             <property name="can_focus">False</property>
100             <property name="label">$valign</property>
101           </object>
102           <packing>
103             <property name="left_attach">1</property>
104             <property name="top_attach">$x</property>
105             <property name="width">1</property>
106             <property name="height">1</property>
107           </packing>
108         </child>
109 EOF
110 fi
111
112 if test $method = "flags"; then
113
114 cat << EOF
115         <child>
116           <object class="GtkGrid" id="grid-$valign-$halign-$vexpand-$hexpand">
117             <property name="width_request">40</property>
118             <property name="height_request">40</property>
119             <property name="visible">True</property>
120             <property name="can_focus">False</property>
121             <child>
122               <object class="GtkTreeView" id="treeview-$valign-$halign-$vexpand-$hexpand">
123                 <property name="width_request">20</property>
124                 <property name="height_request">20</property>
125                 <property name="visible">True</property>
126                 <property name="can_focus">False</property>
127                 <property name="halign">$halign</property>
128                 <property name="valign">$valign</property>
129                 <property name="hexpand">$hexpand</property>
130                 <property name="vexpand">$vexpand</property>
131               </object>
132               <packing>
133                 <property name="left_attach">0</property>
134                 <property name="top_attach">0</property>
135                 <property name="width">1</property>
136                 <property name="height">1</property>
137               </packing>
138             </child>
139           </object>
140           <packing>
141             <property name="left_attach">$x</property>
142             <property name="top_attach">$y</property>
143             <property name="width">1</property>
144             <property name="height">1</property>
145           </packing>
146         </child>
147 EOF
148   
149 elif test $method = "alignment"; then
150
151 xscale=0.0
152 case "$halign" in
153   "start") xalign=0.0 ;;
154   "center") xalign=0.5 ;;
155   "end") xalign=1.0 ;;
156   "fill") xalign=0.5; xscale=1.0 ;;
157 esac
158 if test $hexpand = "True"; then
159   xscale=1.0
160 fi
161
162 yscale=0.0
163 case "$valign" in
164   "start") yalign=0.0 ;;
165   "center") yalign=0.5 ;;
166   "end") yalign=1.0 ;;
167   "fill") yalign=0.5; yscale=1.0 ;;
168 esac
169 if test $vexpand = "True"; then
170   yscale=1.0
171 fi
172
173 cat << EOF
174         <child>
175           <object class="GtkAlignment" id="align-$valign-$halign-$vexpand-$hexpand">
176             <property name="width_request">40</property>
177             <property name="height_request">40</property>
178             <property name="visible">True</property>
179             <property name="can_focus">False</property>
180             <property name="xalign">$xalign</property>
181             <property name="yalign">$yalign</property>
182             <property name="xscale">$xscale</property>
183             <property name="yscale">$yscale</property>
184             <child>
185               <object class="GtkTreeView" id="treeview-$valign-$halign-$vexpand-$hexpand">
186                 <property name="width_request">20</property>
187                 <property name="height_request">20</property>
188                 <property name="visible">True</property>
189                 <property name="can_focus">False</property>
190               </object>
191             </child>
192           </object>
193           <packing>
194             <property name="left_attach">$x</property>
195             <property name="top_attach">$y</property>
196             <property name="width">1</property>
197             <property name="height">1</property>
198           </packing>
199         </child>
200 EOF
201
202 else
203
204   exit 1
205
206 fi
207
208 x=`expr $x + 1`
209 done
210 done
211
212 y=`expr $y + 1`
213 x=0
214 done
215 done
216
217 cat << EOF
218       </object>
219     </child>
220   </object>
221 </interface>
222 EOF