132
132
super(HBox, self)._update_layout()
134
134
fixed_width_children = []
135
# For fixed width children and layouting
136
if len(self.packed_children) > 0:
137
reserved_width = self.spacing * (len(self.packed_children) - 1) * \
142
# Discover fixed width children and update the reserved height
143
print self.packed_children, reserved_width
144
for child in self.packed_children:
145
if child.size_ratio > 0 or \
146
(child.minimum_width > 0 and child.natural_width == 0):
147
fixed_width_children.append(child)
148
child._update_layout()
149
# Increment reserved width by child height and horizontal
151
reserved_width += child.get_widthu() + \
152
child.h_offset * child.get_widthu() * 2.0
154
# Total width excluding reserved width
155
free_width = self.get_widthu() - reserved_width
156
# Width for variable width children
157
var_width_child_count = len(self.packed_children) - \
158
len(fixed_width_children)
159
var_child_width = free_width
160
if var_width_child_count > 0:
161
var_child_width /= var_width_child_count
163
# Position all children
165
for child in self.packed_children:
166
current_x += child.get_widthu() * child.h_offset
167
child.natural_x = current_x
168
if child not in fixed_width_children:
169
print var_child_width
170
child.natural_width = var_child_width
171
child._update_layout()
172
current_x += child.get_widthu() * child.h_offset
173
current_x += self.get_widthu() * self.spacing
175
"""fixed_width_children = []
136
177
reserved_width = 0 # For fixed width children
137
178
for child in self.packed_children:
138
if child.size_ratio > 0:
179
if child.size_ratio > 0 or \
180
(child.minimum_width > 0 and child.natural_width == 0):
139
181
fixed_width_children.append(child)
140
182
child._update_layout()
141
183
reserved_width += child.get_widthu()
143
185
if self.get_widthu() > 0: # Account for zero width
144
186
reserved_width = reserved_width * 1.0 / self.get_widthu()
145
187
available_width = 1.0 - reserved_width
189
max_height = self.minimum_height
147
190
for child in self.packed_children:
148
191
child.set_natural_x(current_x)
149
192
if child not in fixed_width_children:
151
194
len(fixed_width_children))
152
195
child.set_natural_width(child_width)
153
196
child._update_layout()
197
if child.get_height() + (child.v_offset * self.get_height() * 2) > max_height:
198
max_height = child.get_height() + (child.v_offset * self.get_height() * 2)
154
199
if self.get_widthu() > 0:
155
200
current_x += child.get_widthu() * 1.0 / self.get_widthu()
156
current_x += self.spacing
201
current_x += self.spacing
203
self.minimum_height = max_height
205
super(HBox, self)._update_layout() """
172
221
super(VBox, self)._update_style(props)
174
223
def _update_layout(self):
175
""" Updates layout """
226
Fixed height children are flagged and will be offered the space they
227
need. Other children will share the remaining space.
229
Children with minimum height and width->height size ratios qualify as
177
233
super(VBox, self)._update_layout()
179
235
fixed_height_children = []
181
reserved_height = 0 # For fixed width children
182
for child in self.packed_children:
183
if child.size_ratio < 0:
184
fixed_height_children.append(child)
185
child._update_layout()
186
reserved_height += child.get_heightu()
188
if self.get_heightu() > 0:
189
reserved_height = (reserved_height * 1.0 / self.get_heightu())
236
# For fixed height children and layouting
237
reserved_height = self.spacing * (len(self.packed_children) - 1) * \
240
# Discover fixed height children and update the reserved height
241
for child in self.packed_children:
242
if child.size_ratio < 0 or \
243
(child.minimum_height > 0 and child.natural_height == 0):
244
fixed_height_children.append(child)
245
child._update_layout()
246
# Increment reserved height by child height and vertical
248
reserved_height += child.get_heightu() + \
249
child.v_offset * child.get_heightu() * 2.0
251
# Total height excluding reserved height
252
free_height = self.get_heightu() - reserved_height
253
# Height for variable height children
254
var_height_child_count = len(self.packed_children) - \
255
len(fixed_height_children)
256
var_child_height = free_height
257
if var_height_child_count > 0:
258
var_child_height /= var_height_child_count
260
# Position all children
262
for child in self.packed_children:
263
current_y += child.get_heightu() * child.v_offset
264
child.natural_y = current_y
265
if child not in fixed_height_children:
266
child.natural_height = var_child_height
267
child._update_layout()
268
current_y += child.get_heightu() * child.v_offset
269
current_y += self.get_heightu() * self.spacing
271
"""fixed_height_children = []
273
reserved_height = 0.0 # For fixed height children
274
for child in self.packed_children:
275
if child.size_ratio < 0 or \
276
(child.minimum_height > 0 and child.natural_height == 0):
277
fixed_height_children.append(child)
278
child._update_layout()
279
reserved_height += child.get_heightu() + (child.v_offset * self.get_heightu() * 2.0)
281
if self.get_heightu() > 0: # Account for zero width
282
reserved_height = reserved_height * 1.0 / self.get_heightu()
190
283
available_height = 1.0 - reserved_height
285
max_width = self.minimum_width
192
286
for child in self.packed_children:
193
287
child.set_natural_y(current_y)
194
288
if child not in fixed_height_children:
196
290
len(fixed_height_children))
197
291
child.set_natural_height(child_height)
198
292
child._update_layout()
293
if child.get_width() + (child.h_offset * self.get_width() * 2) > max_width:
294
max_width = child.get_width() + (child.h_offset * self.get_width() * 2)
199
295
if self.get_heightu() > 0:
200
296
current_y += child.get_heightu() * 1.0 / self.get_heightu()
201
current_y += self.spacing
297
current_y += self.spacing
299
self.minimum_width = max_width
301
super(VBox, self)._update_layout()"""
203
303
def get_item(self, i):
204
304
""" Retrieve natural y for packed item i """