Layout...r::Grid(3pm)

πŸ“¦
version 0.35 Β· 2 versions
  • 0.35 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.35 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Layout::Manager::Grid β€” the vibe ✨

ok so bestie, this is Layout::Manager::Grid, and it lives in the User Contributed Perl Documentation corner of the perl universe 🫢


🌸 NAME 🌸

Layout::Manager::Grid β€” a simple grid-based layout manager. that's it, that's the whole name, she's lowkey humble πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so Layout::Manager::Grid is a layout manager that places components into evenly divided cells. it's giving spreadsheet, it's giving tic-tac-toe board, it's giving structure ✨

the way it works: when you instantiate a Grid manager, you must supply it with a count of how many rows and columns it's gonna have. no rows-and-columns, no grid, periodt. for example, a Grid with 1 column and 2 rows would look like this:

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

so the container gets divided into <rows> * <columns> cells, and every single one takes up an equal amount of space. no favourites here, everyone gets the same slice 🍰 a grid with 3 columns and 2 rows would create 6 cells that consume 33% of the width and 50% of the height. math ate, honestly.

components get 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 something else will cause the component to consume that many rows or columns worth of space. so yeah, your component can absolutely claim extra real estate if it wants to be the main character πŸ‘‘

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


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

πŸŽ€ DYNAMIC SIZING πŸŽ€

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. and honestly? the simple way for me to avoid writing a long explanation is to just say it works similar to HTML tables. Rows will become as big as their biggest consituent, as will columns. it's the same energy as a table cell stretching to fit the tallest thing in its row 🫢

it is common to add a Grid-managed component to a scene with only one of it's dimensions set. no cap.


πŸ’… ATTRIBUTES πŸ’…

🌈 columns

The number of columns in this Grid.

🌈 rows

The number of rows in this Grid.


πŸ”₯ METHODS πŸ”₯

✨ do_layout

Size and position the components in this layout. that's the whole job description bestie, and she does it flawlessly πŸ’–


πŸ‘‘ AUTHOR πŸ‘‘

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


Copyright 2008 - 2010 Cory G Watson

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


ok so that's the whole page! every flag, every default, every path, every permission clause β€” nothing skipped, nothing invented, all facts intact πŸ’―

and that's a wrap on Layout...r::Grid(3pm) from perl v5.34.0, dated 2022-06-15, brought to you by User Contributed Perl Documentation. go forth and lay out ur components, bestie, u got this πŸ¦‹βœ¨πŸ’œ

πŸ“¦ where this page comes from