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