Tickit...::VBox(3pm)

πŸ’– Tickit::Widget::VBox β€” bestie edition πŸ’–

okay so. Tickit::Widget::VBox is a Perl module (a 3pm manual page, if we're being official about it) and it does exactly one thing but it does it so well: it stacks your child widgets in a vertical column. top to bottom. that's the whole vibe. πŸ‘‘


✨ SYNOPSIS ✨

no thoughts, just code. here's the whole lewk:

use Tickit;
use Tickit::Widget::VBox;
use Tickit::Widget::Static;

my $vbox = Tickit::Widget::VBox->new;

foreach my $position (qw( top middle bottom )) {
   $vbox->add(
      Tickit::Widget::Static->new(
         text   => $position,
         align  => "centre",
         valign => $position,
      ),
      expand => 1
   );
}

Tickit->new( root => $vbox )->run;

slay. three widgets, three vertical positions, one box. 🫢


🌸 DESCRIPTION 🌸

so Tickit::Widget::VBox is a subclass of Tickit::Widget::LinearBox (iykyk β€” that's where the linear layout energy comes from), and it distributes its children in a vertical column. like, straight down. πŸ“š

the sizing math is lowkey simple and highkey important:

  • its width = the width of the widest child
  • its height = the sum of the heights of all the children, plus the inter-child spacing

and here's a cute bonus: optionally, if you give it a non-zero spacing between child widgets and a style to draw in, it will draw a horizontal dividing line between each child. ✨ little separators. iconic.


πŸ’… STYLE πŸ’…

the default style pen is used as the widget pen. periodt. but also, these style pen prefixes get used:

  • line => PEN β€” since version 0.52. this is the pen used to render a dividing line between child widgets.
⚠️ okay important thing bestie: the widget pen is mutable, and changes to it will result in immediate redrawing. BUT β€” any changes you make will be lost if the widget style is changed. so like, don't get attached. 😭

and the style keys it uses:

  • spacing => INT β€” the number of lines of spacing between children.
  • line_style => INT β€” since version 0.52. if set, this is the style used to draw a dividing line between each child widget. it must be one of the LINE_* constants from Tickit::RenderBuffer. no random numbers, bestie, it will not pass the vibe check. πŸ’€

πŸ‘‘ AUTHOR πŸ‘‘

Paul Evans <leonerd@leonerd.org.uk> β€” the main character who wrote this. give him his flowers. 🌹


that's the whole page, fr fr. this manual page is from perl v5.40.0, dated 2024-09-16, and it lives under the name Tickit...::VBox(3pm) in the User Contributed Perl Documentation section. go stack some widgets, you got this. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from