Grid::Layout - Create grid based layouts.
use Grid::Layout; my $gl = Grid::Layout->new();
$self->_init_V_or_H('V'); $self->_init_V_or_H('H');
This method is called by "new" twice to initialize the vertical and the horizontal components of the layout.
The parameter 'V' or 'H' indiciates which componenents to initialize.
'V'
'H'
my $track_v = $gl->add_vertical_track(…); my ($track_v, $line_v) = $gl->add_vertical_track(…);
Adds a vertical track on the right side of the grid and returns it.
If called in list context, it returns the newly created Grid::Layout::Track and Grid::Layout::Line. Otherwise, it returns the newly created Grid::Layout::Track.
my $track_h = $gl->add_horizontal_track(…); my ($track_h, $line_h) = $gl->add_horizontal_track(…);
Adds a horizontal track at the bottom of the grid and returns it.
my $logical_width = 5; my $fourth_horizontal_line = $gl->get_horizontal_line($logical_width);
Returns the horizontal line that is $logical_width units from the zero-line apart.
$logical_width
my $logical_width = 4; my $third_horizontal_line = $gl->get_horizontal_line($logical_width);
Returns the vertical line that is $logical_width units from the zero-line apart.
my $new_line = $gl->add_horizontal_line(…); my ($new_line, $new_track) = $gl->add_horizontal_line(…);
Adds a horizontal line (and by implication also a horizontal track).
If called in list contect, it returns both, if called in scalar contect, it returns the new line only.
my $new_line = $gl->add_vertical_line(…); my ($new_line, $new_track) = $gl->add_vertical_line(…);
Adds a vertical line (and by implication also a vertical track).
my $track = $gl->_add_track($V_or_H);
Internal function. Returns a vertical or horizontal track, depending on the value of $V_or_H (whose should be either 'V' or 'H').
$V_or_H
$self->_add_line($V_or_H);
Internal function, called by "_add_track", to add a vertical or horizontal Grid::Layout::Line.
$gl->area(…)
Create an area
my $vertical_line_from = $gl->add_vertical_line(…); my $horizontal_line_from = $gl->add_vertical_line(…); my $vertical_line_to = $gl->add_vertical_line(…); my $horizontal_line_to = $gl->add_vertical_line(…); my $area = $gl->area ( $vertical_line_from, $horizontal_line_from, $vertical_line_to ,$horizontal_line_to );
my $vertical_track_from = $gl->add_vertical_track(…); my $horizontal_track_from = $gl->add_vertical_track(…); my $vertical_track_to = $gl->add_vertical_track(…); my $horizontal_track_to = $gl->add_vertical_track(…); my $area = $gl->area($vertical_track_from, $horizontal_track_from, $vertical_track_to, $vertical_track_to);
Define an area bound by the four tracks. Both the from and the to tracks are included.
An area that lies on only one track can be created with "area" in Grid::Layout::Track.
my $x = $gl->size_x();
Returns the horizontal size (x axis) in logical cell units.
my $y = $gl->size_y();
Returns the vertical size (y axis) in logical cell units.
Returns size of grid (nof vertical tracks x nof horizontal tracks);
my ($v, $h) = $gl -> size();
Internal use.
my $track_v = $gl->add_vertical_track(…); my $track_h = $gl->add_horizontal_track(…); my $cell_1 = $gl->cell($x, $y); my $cell_2 = $gl->cell($track_v, $track_h);
Return the Grid::Layout::Cell at horizontal position $x and vertical position $y or where $track_v and $track_h intersects.
$x
$y
$track_v
$track_h
my $line = $gl->line_x($postition);
Returns the $positionth line in horizontal direction.
$position
my $line = $gl->line_y($postition);
Returns the $positionth line in vertical direction.
my $line = $gl->_line($V_or_H, $position)
Returns the $positionth line in vertical or horizontal direction.
my $track = $gl->_track($V_or_H, $position)
Returns the $positionth track in vertical or horizontal direction.
my $o1 = Grid::Layout::VH_opposite('H'); my $02 = Grid::Layout::VH_opposite('V');
Static method. Returns 'V' if passed 'H' and vice versa.
Copyright © 2017 René Nyffenegger, Switzerland. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at: http://www.perlfoundation.org/artistic_license_2_0
The source code is on github. Meaningful pull requests are welcome.
To install Grid::Layout, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Grid::Layout
CPAN shell
perl -MCPAN -e shell install Grid::Layout
For more information on module installation, please visit the detailed CPAN module installation guide.