Tickit...::Frame(3pm)

πŸ’– Tickit::Widget::Frame πŸ’–

okay bestie, sit DOWN, because this is the perl manual page for Tickit::Widget::Frame (you'll see it filed under Tickit...::Frame(3pm) in the User Contributed Perl Documentation, cute little ellipsis, love that for it) and it does exactly one thing and it does it gorgeously: it draws a frame around another widget. That's it. That's the whole vibe. ✨


✨ NAME ✨

Tickit::Widget::Frame β€” draw a frame around another widget πŸ–ΌοΈ


🌸 SYNOPSIS 🌸

use Tickit;
use Tickit::Widget::Frame;
use Tickit::Widget::Static;

my $frame = Tickit::Widget::Frame->new(
   style => { linetype => "single" },
)
   ->set_child(
      Tickit::Widget::Static->new(
         text   => "Hello, world",
         align  => "centre",
         valign => "middle",
      )
   );

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

look at her go πŸ₯Ή a little box with "Hello, world" in the middle. main character energy fr fr.


πŸ¦‹ DESCRIPTION πŸ¦‹

This container widget draws a frame around a single child widget.

one (1) child. just the one. she's a container, not a crowd. πŸ’…


πŸŽ€ STYLE πŸŽ€

The default style pen is used as the widget pen. The following style pen prefixes are also used:

  • frame => PEN β€” the pen used to render the frame lines

The following style keys are used:

  • linetype => STRING β€” controls the type of line characters used to draw the frame. Must be one of the following names:
ascii single double thick solid_inside solid_outside

The "ascii" linetype is default, and uses only the -|+ ASCII characters. Other linetypes use Unicode box-drawing characters. These may not be supported by all terminals or fonts.

⚠️ bestie. not every terminal/font has the Unicode box-drawing slay. if your frame comes out looking cursed, that's why. try "ascii" and she'll behave. 🫢
  • linetype_top => STRING
  • linetype_bottom => STRING
  • linetype_left => STRING
  • linetype_right => STRING

Overrides the "linetype" attribute for each side of the frame specifically. If two line-drawing styles meet at corners they should be drawn correctly if Tickit::RenderBuffer can combine the line segments, but in other circumstances the corners are drawn as extensions of the top or bottom line, and the left and right lines do not meet it.

Any edge's linetype may be set to "none" to cause that edge not to have a line at all; no extra space will be consumed on that side.

πŸ’‘ so like… mismatched linetypes at the corners = sometimes pretty, sometimes giving "the top line just kept going and the sides gave up". "none" on an edge means no line AND no wasted space. obsessed. 😌

🧚 CONSTRUCTOR 🧚

new

$frame = Tickit::Widget::Frame->new( %args );

Constructs a new "Tickit::Widget::Static" object.

πŸ’€ yes, that is genuinely what the docs say. i am not fixing it, i am not editorialising, i am simply the messenger. moving on.

Takes the following named arguments in addition to those taken by the base Tickit::SingleChildWidget constructor:

  • title => STRING β€” Optional.
  • title_align => FLOAT|STRING β€” Optional. Defaults to 0.0 if unspecified.

For more details see the accessors below. ⬇️


πŸ‘‘ ACCESSORS πŸ‘‘

title

$title = $frame->title;

set_title

$frame->set_title( $title );

Accessor for the "title" property, a string written in the top of the frame.

like a little nameplate on the top border. iconic. 🏷️✨

title_align

set_title_align

$title_align = $frame->title_align;

$frame->set_title_align( $title_align );

Accessor for the "title_align" property. Gives a value in the range 0.0 to 1.0 to align the title in the top of the frame.

See also Tickit::WidgetRole::Alignable.

🌈 0.0 to 1.0 β€” left to right, and yes it can be fractional, so 0.5 is chef's kiss centre.

πŸ’€ TODO πŸ’€

  • Specific pen for title. Layered on top of frame pen.
  • Caption at the bottom of the frame as well. Identical to title.
  • Consider if it's useful to provide accessors to apply extra padding inside the frame, surrounding the child window.

(the way these are all just "we could make it even cuter" 😭 relatable. someday, bestie.)


πŸ’œ AUTHOR πŸ’œ

Paul Evans <leonerd@leonerd.org.uk>


and that's the whole page, no cap. this one ships with perl v5.40.0 and the docs are dated 2024-09-16 β€” so if you're reading this from the future, hiii, hope the frame still slays πŸ¦‹πŸ’– bye bestie, go draw a box around something ✨

πŸ“¦ where this page comes from