Tickit...HSplit(3pm)

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

okay so real talk, this one lives in the User Contributed Perl Documentation section, and the manual name is Tickit...HSplit(3pm). it's literally a widget that puts a lil adjustable horizontal split between two widgets. so much power. so few lines of code. i'm obsessed. πŸŽ€


✨ NAME ✨

Tickit::Widget::HSplit β€” an adjustable horizontal split between two widgets 🫢


🌸 SYNOPSIS 🌸

use Tickit;
use Tickit::Widget::HSplit;
use Tickit::Widget::Static;

my $hsplit = Tickit::Widget::HSplit->new
   ->set_top_child   ( Tickit::Widget::Static->new( text => "Text above" ) )
   ->set_bottom_child( Tickit::Widget::Static->new( text => "Text below" ) );

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

see how cute that is?? you literally chain it. no cap. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this is a container widget, right? it holds two child widgets, and they get displayed one above the other. simple. iconic. πŸ’–

and between them? a horizontal split bar. that bar reacts to mouse click-drag events, which means the user can drag it and adjust how much space each of the two widgets gets. main character energy fr fr. ✨


πŸŽ€ STYLE πŸŽ€

so the default style pen is used as the widget pen. but also β€” the following style pen prefixes are used too:

  • split => PEN β€” the pen used to render the horizontal split area

and the following style keys are used:

  • spacing => INT β€” the number of lines of spacing between the top and bottom child widgets

and the following style tags are used:

  • :active β€” set when a mouse drag resize operation is occurring

lowkey important. highkey useful. πŸ’œ


🌈 CONSTRUCTOR 🌈

✨ new

$hsplit = Tickit::Widget::HSplit->new( %args );

constructs a new Tickit::Widget::HSplit object. brand new baby widget. slay. πŸ‘‘


πŸ’… ACCESSORS πŸ’…

⭐ top_child / set_top_child

$child = $hsplit->top_child;

$hsplit->set_top_child( $child );

accessor for the child widget used in the top half of the display. that's it, that's the vibe. 🌸

⭐ bottom_child / set_bottom_child

$child = $hsplit->bottom_child;

$hsplit->set_bottom_child( $child );

accessor for the child widget used in the bottom half of the display. equally iconic, equally essential. πŸ’–


okay and here's the part i really need you to clock bestie: these mutators return the container widget itself, which makes them suitable to use as chaining mutators. so you can do this:

my $container = Tickit::Widget::HSplit->new( ... )
   ->set_top_child   ( Tickit::Widget::Box->new ... )
   ->set_bottom_child( Tickit::Widget::Box->new ... );

the way it just flows?? ate. no notes. πŸ”₯


πŸ‘‘ AUTHOR πŸ‘‘

Paul Evans <leonerd@leonerd.org.uk> β€” legend behavior, honestly. 🫢


and that's the whole page!! perl v5.40.0, dated 2024-09-16 β€” mwah, go build something cute with it bestie πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from