~glitter-team/glitter/trunk

« back to all changes in this revision

Viewing changes to glitter/box.py

(Merge) From layout engine improvements branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
140
140
            reserved_width = 0.0
141
141
        
142
142
        # Discover fixed width children and update the reserved height
143
 
        print self.packed_children, reserved_width
144
143
        for child in self.packed_children:         
145
144
            if child.size_ratio > 0 or \
146
145
              (child.minimum_width > 0 and child.natural_width == 0):
164
163
        current_x = 0.0
165
164
        for child in self.packed_children:
166
165
            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
 
166
            if self.get_widthu() > 0:
 
167
                child.natural_x = current_x / self.get_widthu()
 
168
                if child not in fixed_width_children:
 
169
                    child.natural_width = var_child_width / self.get_widthu()
171
170
            child._update_layout()
 
171
            current_x += child.get_widthu()
172
172
            current_x += child.get_widthu() * child.h_offset
173
173
            current_x += self.get_widthu() * self.spacing
174
 
        
175
 
        """fixed_width_children = []
176
 
        
177
 
        reserved_width = 0 # For fixed width children
178
 
        for child in self.packed_children:
179
 
            if child.size_ratio > 0 or \
180
 
               (child.minimum_width > 0 and child.natural_width == 0):
181
 
                fixed_width_children.append(child)
182
 
                child._update_layout()
183
 
                reserved_width += child.get_widthu()
184
 
     
185
 
        if self.get_widthu() > 0: # Account for zero width
186
 
            reserved_width = reserved_width * 1.0 / self.get_widthu()
187
 
        available_width = 1.0 - reserved_width
188
 
        current_x = 0.0
189
 
        max_height = self.minimum_height
190
 
        for child in self.packed_children:
191
 
            child.set_natural_x(current_x)
192
 
            if child not in fixed_width_children:
193
 
                child_width = available_width / (len(self.packed_children) - \
194
 
                  len(fixed_width_children))
195
 
                child.set_natural_width(child_width)
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)
199
 
            if self.get_widthu() > 0:
200
 
                current_x += child.get_widthu() * 1.0 / self.get_widthu()
201
 
            current_x += self.spacing  
202
 
            
203
 
        self.minimum_height = max_height     
204
 
        
205
 
        super(HBox, self)._update_layout()      """   
206
 
                           
207
174
          
208
175
class VBox(Box):
209
176
    """ A VBox layouts children in a vertical fashion """