20 |
foreach my $object (@alignees) |
foreach my $object (@alignees) |
21 |
{ |
{ |
22 |
# If object's width not set, make it as wide as the box |
# If object's width not set, make it as wide as the box |
23 |
my $width = $object->width || $object->width($self->width); |
my $width = $object->width || $object->width($self->contents_width); |
24 |
|
|
25 |
# Place object in the vertical according to alignment |
# Place object in the vertical according to alignment |
26 |
$object->x($self->x + $self->width - $object->width), next if $alignment =~ /^right$/i; |
$object->x($self->contents_origin_x + $self->contents_width - $object->width), next if $alignment =~ /^right$/i; |
27 |
$object->x(int(($self->x + $self->width - $object->width)/2)), next if $alignment =~ /^center$/i; |
$object->x(int(($self->contents_origin_x + $self->contents_width - $object->width)/2)), next if $alignment =~ /^center$/i; |
28 |
$object->x($self->x); # Default case: left alignment |
$object->x($self->contents_origin_x); # Default case: left alignment |
29 |
} |
} |
30 |
} |
} |
31 |
|
|
33 |
{ |
{ |
34 |
my $self = shift; |
my $self = shift; |
35 |
my @alignees = @_; |
my @alignees = @_; |
36 |
my $free_space = $self->height; |
my $free_space = $self->contents_height; |
37 |
my @stretchable = (); |
my @stretchable = (); |
38 |
|
|
39 |
foreach my $object (@alignees) |
foreach my $object (@alignees) |
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 top |
my $cursor = $self->contents_origin_y; # Default alignment is top |
58 |
$cursor += int($free_space/2) if $alignment =~ /^center$/; |
$cursor += int($free_space/2) if $alignment =~ /^center$/; |
59 |
$cursor += $free_space if $alignment =~ /^bottom$/; |
$cursor += $free_space if $alignment =~ /^bottom$/; |
60 |
map {$_->y($cursor); $cursor += $_->height} @alignees; |
map {$_->y($cursor); $cursor += $_->height} @alignees; |