Tickit...ignable(3pm)

✨ Tickit::WidgetRole::Alignable ✨

πŸŽ€ NAME πŸŽ€

Tickit::WidgetRole::Alignable β€” bestie, this is the role that lets your widgets have adjustable alignment πŸ’…


🌸 DESCRIPTION 🌸

Okay so picture this: you mix this parametric role into a Tickit::Widget subclass, and boom πŸ’₯ β€” now your widget knows how to align its content inside a space that might be bigger than the content itself. Main character behaviour, fr fr. 🫢


πŸ‘‘ METHODS πŸ‘‘

The way this works is parametric, meaning these methods get generated onto your caller package when you import the module like this:

use Tickit::WidgetRole::Alignable
   name    => NAME,
   style   => STYLE,
   reshape => RESHAPE;

Now the parameters, bestie β€” read these carefully πŸ‘€

  • name => STRING β€” Optional, lowkey. This is the name that gets swapped in for "NAME" in all the generated methods down below. If you don't pass it, it just defaults to 'align'. πŸ’–
  • dir => "h" or "v" β€” Also optional. This is the direction β€” horizontal or vertical β€” that the alignment is representing. It's what gets used to parse symbolic names into fractions. Defaults to 'h' if you don't say anything. 🌈
  • reshape => BOOL β€” Optional too. If it's true, your widget gets reshaped after the value is set, by calling the "reshape" method. If it's false or just… absent? Then it only gets redrawn, via the "redraw" method. No reshape, just a lil refresh. ✨

πŸ¦‹ NAME πŸ¦‹

$align = $widget->NAME;

Returns the current alignment value. That's it, that's the vibe. πŸ’œ

πŸ’… set_NAME πŸ’…

$widget->set_NAME( $value );

Sets the new alignment value, periodt.

You hand it a value anywhere in the range from 0.0 to 1.0, and that's how the content display gets aligned within the window. πŸ”₯

  • For vertical direction alignments, you can pass the symbolic values top, middle and bottom instead of 0.0, 0.5 and 1.0 respectively. πŸ“
  • For horizontal direction alignments, you can pass the symbolic values left, centre and right instead of 0.0, 0.5 and 1.0 respectively. 🌸

🧚 _NAME_allocation 🧚

( $before, $alloc, $after ) = $widget->_NAME_allocation( $value, $total );

Returns a list of three integers β€” yes, three β€” created by aligning the $value to the given alignment position within the $total. If you wanna know more, go peek at "align" in Tickit::Utils. iykyk πŸ’«


⭐ AUTHOR ⭐

Paul Evans <leonerd@leonerd.org.uk> β€” thank you legend, we stan πŸ‘‘


Okay that's the whole page bestie, you're officially aligned (pun absolutely intended 😭). This was Tickit...ignable(3pm), part of the User Contributed Perl Documentation, running on perl v5.40.0, dated 2024-09-16. Slay, go align something iconic πŸ’–βœ¨πŸŽ€
πŸ“¦ where this page comes from