17 |
my @alignees = @_; |
my @alignees = @_; |
18 |
my $alignment = $self->halign; |
my $alignment = $self->halign; |
19 |
|
|
20 |
foreach my $object in (@alignees) |
foreach my $object (@alignees) |
21 |
{ |
{ |
22 |
# If object's width not set, make it as high as the box |
# If object's width not set, make it as high as the box |
23 |
my $width = $object->width || $object->width($self->width); |
my $width = $object->width || $object->width($self->width); |
29 |
} |
} |
30 |
} |
} |
31 |
|
|
32 |
sub layout {} |
sub layout |
33 |
{ |
{ |
34 |
my $self = shift; |
my $self = shift; |
35 |
my @alignees = @_; |
my @alignees = @_; |
36 |
my $free_space = $self->height; |
my $free_space = $self->height; |
37 |
my @stretchable = (); |
my @stretchable = (); |
38 |
|
|
39 |
foreach my $object in (@alignees) |
foreach my $object (@alignees) |
40 |
{ |
{ |
41 |
my $height = $object->height; |
my $height = $object->height; |
42 |
# If height is defined, then that space is taken. |
# If height is defined, then that space is taken. |
43 |
# If height undefined, record object to be stretched |
# If height undefined, record object to be stretched |
44 |
defined($height) ? $free_space -= $height : push(@stretchable, $object); |
defined($height) ? $free_space -= $height : push(@stretchable, $object); |
45 |
} |
} |
46 |
$free_space < 0 && $free_space = 0; # make sure free space not negative |
$free_space < 0 and $free_space = 0; # make sure free space not negative |
47 |
|
|
48 |
# Distribute free space among stretchable items, if any |
# Distribute free space among stretchable items, if any |
49 |
if (0 < @stretchable) |
if (0 < @stretchable) |
53 |
} |
} |
54 |
|
|
55 |
# Now lay out the elements |
# Now lay out the elements |
56 |
my $alignment = = $self->valign; |
my $alignment = $self->valign; |
57 |
my $cursor = $self->y; # Default alignment is left |
my $cursor = $self->y; # Default alignment is left |
58 |
$cursor += int($free_space/2) if $alignment =~ /^center$/; |
$cursor += int($free_space/2) if $alignment =~ /^center$/; |
59 |
$cursor += $free_space if $alignment =~ /^right$/; |
$cursor += $free_space if $alignment =~ /^right$/; |