File: Single.pm

package info (click to toggle)
liblayout-manager-perl 0.31-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 336 kB
  • ctags: 133
  • sloc: perl: 1,782; makefile: 2
file content (78 lines) | stat: -rw-r--r-- 1,635 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package Layout::Manager::Single;
use Moose;

extends 'Layout::Manager';

override('do_layout', sub {
    my ($self, $container) = @_;

    return 0 if $container->prepared && $self->_check_container($container);

    my $bbox = $container->inside_bounding_box;
    my $cwidth = $bbox->width;
    my $cheight = $bbox->height;
    my $x = $bbox->origin->x;
    my $y = $bbox->origin->y;

    my $count = 0;
    foreach my $comp (@{ $container->components }) {

        next unless defined($comp) && $comp->visible;

        $comp->width($cwidth);
        $comp->height($cheight);
        $comp->origin->x($x);
        $comp->origin->y($y);

        if($comp->can('do_layout')) {
            $comp->do_layout($comp);
        } else {
            #$comp->prepared(1);
        }
    }

    $container->prepared(1);
    return 1;
});

__PACKAGE__->meta->make_immutable;

no Moose;

1;
__END__
=head1 NAME

Layout::Manager::Single - One-size vertical layout manager

=head1 DESCRIPTION

Lays out all components in a single position.  All components are set to the
height and width of the container and positioned at the offsets.  This
basically stacks them all vertically.

=head1 SYNOPSIS

  my $lm = Layout::Manager::Single->new();
  
  $lm->add_component($comp1);
  $lm->add_component($comp2);

  $lm->do_layout($container);

=head1 METHODS

=head2 do_layout

Size and position the components in this layout.

=head1 AUTHOR

Cory Watson, C<< <gphat@cpan.org> >>

=head1 COPYRIGHT & LICENSE

Copyright 2008 - 2009 by Cory G Watson

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.