Layout::Manager - 2D Layout Management
Layout::Manager provides a simple interface for creating layout managers, or classes that size and position components withing a container.
A few managers are provided for reference, but this module is primarily meant to serve as a base for outside implementations.
use Layout::Manager; my $foo = Layout::Manager->new(); ...
Various implementations of Layout::Manager will require you do add components with slightly different second arguments, but the general case will be:
$lm->add_component($comp, $constraints);
The contents of $constraints must be discerned by reading the documentation for the layout manager you are using.
The $comp argument must be a class that implements the Layout::Manager::Component role. For more information on Roles please read the Moose::Role documentation on the CPAN.
When you are ready to lay out your container, you'll need to call the do_layout method with a single argument: the component in which you are laying things out. This object is also expected to implement aforementioned Layout::Manager::Component role. When do_layout returns all of the components should be resized and repositioned according to the rules of the Layout::Manager implementation.
Layout::Manager provides all the methods necessary for your implementation, save the do_layout method. This method will be called when it is time to layout the components.
The add_component method takes two arguments: the component and a second, abritrary piece of data. If your layout manager is simple, like Compass, you may only require a simple variable like "NORTH". If you create something more complex the second argument may be a hashref or an object.
The value of the components method is an arrayref of hashrefs. The hashrefs have two keys:
The component to be laid out.
The argument provided to add_component.
Add a component to the layout manager. Returns a true value if the component was added successfully. A second argument may be required, please consult the POD for your specific layout manager implementation.
Before the component is added, it is passed to the validate_component method. If validate_component does not return a true value, then the component is not added.
Remove all components from the layout manager.
Returns the number of components in this layout manager.
Lays out this managers components in the specified container.
Calls prepare on all this layout manager's child components.
Get the component at the specified index.
Removes a component. Components must have names to be removed.
Optionally overriden by an implementation, allows it to deem
Cory Watson, <gphat@cpan.org>
<gphat@cpan.org>
Infinity Interactive, http://www.iinteractive.com
perl(1)
Copyright 2008 by Infinity Interactive, Inc.
http://www.iinteractive.com
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Layout::Manager, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Layout::Manager
CPAN shell
perl -MCPAN -e shell install Layout::Manager
For more information on module installation, please visit the detailed CPAN module installation guide.