logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Layout::Manager::Grid - Simple grid-based layout manager.

Attributes

columns
       The number of columns in this Grid.

   rows
       The number of rows in this Grid.

Author

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

Description

       Layout::Manager::Grid is a layout manager places components into evenly divided cells.

       When you instantiate a Grid manager, you must supply it with a count of how many rows and columns it will
       have.  For example, a Grid with 1 column and 2 rows would look like:

         +--------------------------------+
         |                                |
         |           component 1          |
         |                                |
         +--------------------------------+
         |                                |
         |           component 2          |
         |                                |
         +--------------------------------+

       The container is divided into as many <rows> * <columns> cells, with each taking up an equal amount of
       space.  A grid with 3 columns and 2 rows would create 6 cells that consume 33% of the width and 50% of
       the height.

       Components are placed by specifying the cell they reside in via the row and column number.

         $container->add_component($comp, { row => 0, column => 3 });

         $container->add_component($comp, { row => 0, column => 2, height => 2 });

       Optionally, you may choose to override the default "width" or "height" of 1.  Setting it to a something
       else will cause the component to consume that many rows or columns worth of space.

       Grid is similar to Java's GridLayout <http://java.sun.com/docs/books/tutorial/uiswing/layout/grid.html>.

Methods

do_layout
       Size and position the components in this layout.

Name

       Layout::Manager::Grid - Simple grid-based layout manager.

Synopsis

         $cont->add_component($comp1, { row => 0, column => 1 });
         $cont->add_component($comp2, { row => 0, column => 2 });

         my $lm = Layout::Manager::Grid->new(rows => 1, columns => 2);
         $lm->do_layout($con);

   DYNAMICSIZING
       If the container that the Grid is manging does not have one or both of it's dimensions set, Grid will
       compute the appropriate sizes.  The simple way for me to avoid writing a long explanation is to say it
       works similar to HTML tables.  Rows will become as big as their biggest consituent, as will columns.  It
       is common to add a Grid-managed component to a scene with only one of it's dimensions set.

See Also