René Nyffenegger

Grid::Layout - Create grid based layouts.

SYNOPSIS

DESCRIPTION

METHODS

new

    use Grid::Layout;

    my $gl = Grid::Layout->new();

_init_V_or_H

    $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.

add_vertical_track

    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.

add_horizontal_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.

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.

new

    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.

new

    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.

add_horizontal_line

    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.

add_vertical_line

    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).

If called in list contect, it returns both, if called in scalar contect, it returns the new line only.

_add_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').

_add_line

    $self->_add_line($V_or_H);

Internal function, called by "_add_track", to add a vertical or horizontal Grid::Layout::Line.

area

    $gl->area(…)

Create an area

creating an area from lines

    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
    );

creating an area from tracks

    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.

size_x

    my $x = $gl->size_x();

Returns the horizontal size (x axis) in logical cell units.

size_y

    my $y = $gl->size_y();

Returns the vertical size (y axis) in logical cell units.

size

Returns size of grid (nof vertical tracks x nof horizontal tracks);

    my ($v, $h) = $gl -> size();

_size

Internal use.

cell

    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.

_add_cell

Internal use.

line_x

    my $line = $gl->line_x($postition);

Returns the $positionth line in horizontal direction.

line_y

    my $line = $gl->line_y($postition);

Returns the $positionth line in vertical direction.

_line

    my $line = $gl->_line($V_or_H, $position)

Returns the $positionth line in vertical or horizontal direction.

_track

    my $track = $gl->_track($V_or_H, $position)

Returns the $positionth track in vertical or horizontal direction.

VH_opposite

    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

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

Source Code

The source code is on github. Meaningful pull requests are welcome.