Tickit...nearBox(3pm)

✨ Tickit::Widget::LinearBox ✨

okay so bestie, welcome to the manual page for Tickit::Widget::LinearBox πŸ’– (the header up there calls it Tickit...nearBox(3pm) bc terminals truncate stuff, but you and me know the real name, and so does the perl v5.40.0 docs set from 2024-09-16 🫢)


🌸 NAME 🌸

Tickit::Widget::LinearBox β€” abstract base class for HBox and VBox πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So. This class is the base class for both Tickit::Widget::HBox and Tickit::Widget::VBox. She's the momager. The blueprint. The blueprint that is not meant to be used directly, okay?? Like, do not instantiate her for your own widget, she's doing her job behind the scenes and that's that 😌

What she does: she keeps an ordered list of child widgets πŸ“‹ β€” yes, order matters, this is not a vibe-optional situation β€” and she implements the following child widget options:

  • expand => NUM β€” a number that controls how extra space gets divvied up among the child widgets, but only if the window containing this widget has more space than the children actually need. The actual value is unimportant (fr fr, the number itself means nothing), but extra space will be distributed among the children in proportion with their expand value. So like, if all the children have an expand value of 1, the extra space gets distributed evenly β€” equal shares, we love a fair split ✨. If one child has a value of 2, it will gain twice as much extra space as its siblings. And any child with a value of 0 will obtain no extra space. Zero. Nothing. Not a crumb πŸ“
  • force_size => NUM β€” if provided, this forces the size of this child widget, overriding the value returned by get_child_base. That's it, that's the whole option, she said "I don't care what get_child_base thinks, I'm the one in charge now" πŸ‘‘

πŸŽ€ CONSTRUCTOR πŸŽ€

new

$widget = Tickit::Widget::LinearBox->new( %args );

Returns a new Tickit::Widget::LinearBox πŸ’«


πŸ’œ METHODS πŸ’œ

children

@children = $widget->children;

In scalar context, returns the number of contained children. In list context, returns a list of all the child widgets. Same method, different moods depending on the context you ask her in β€” she contains multitudes 🌈

child_opts

%opts = $widget->child_opts( $child_or_index );

Returns the options currently set for the given child, specified either by reference or by index. Your call, bestie β€” object or number, she'll find them πŸ’…

set_child

$widget->set_child( $index, $child );

Replaces the child widget at the given index with the given new one β€” while preserving any options that are set on it. She's swapping the kid but keeping the whole wardrobe, iconic behavior honestly πŸ‘‘

set_child_opts

$widget->set_child_opts( $child_or_index, %newopts );

Sets new options on the given child, specified either by reference or by index. And listen β€” any options whose value is given as undef are deleted. Gone. Not set to undef, deleted πŸ’€ so don't be handing her undef unless you actually want that option yeeted.

add

$widget->add( $child, %opts );

Adds the widget as a new child of this one, with the given options.

And here's the cute part: this method returns the container widget instance itself, making it suitable to use as a chaining mutator 😭✨ e.g.

my $container = Tickit::Widget::LinearBox->new( ... )
   ->add( Tickit::Widget::Static->new( ... ) )
   ->add( Tickit::Widget::Static->new( ... ) );

Look at that chain. Look at her go. Main character energy fr fr πŸ”₯

add_children

$widget->add_children( @children );

Adds each of the given widgets as a new child of this one. Each element of the list should either be a widget object reference directly, or an unblessed hash reference containing additional options. (See split_widget_opts in Tickit::Widget.) iykyk πŸ‘€

This method also returns the container widget instance itself, making it suitable to use as a chaining mutator. Chain queen stays chain queen πŸ’…

remove

$widget->remove( $child_or_index );

Removes the given child widget if present, by reference or index. If she's not there, no drama, nothing happens πŸ¦‹


🌟 AUTHOR 🌟

Paul Evans <leonerd@leonerd.org.uk> πŸ’–


πŸ’Œ and that's the whole page bestie!! she was written for perl v5.40.0 and this doc is dated 2024-09-16, so go forth, build your boxes, chain your mutators, and remember: do not use the base class directly πŸ™ˆ πŸ’…βœ¨πŸŒΈπŸ«Ά
πŸ“¦ where this page comes from