Tickit...Ribbon(3pm)

πŸ“¦
version 0.028 Β· 4 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Tickit::Widget::Tabbed::Ribbon πŸ’–

okay bestie, so this one's a Perl manual page β€” User Contributed Perl Documentation, no big deal, just the docs for a lil' Perl module. and the module is...

✨ NAME ✨

Tickit::Widget::Tabbed::Ribbon β€” the base class for the Tickit::Widget::Tabbed control ribbon πŸŽ€


🌸 DESCRIPTION 🌸

so like. this class is where the default implementation of the control ribbon for Tickit::Widget::Tabbed lives, AND it doubles as the base class you'd build a custom ribbon on top of. two jobs, main character energy fr fr πŸ’…

the deets about this class and how it works? genuinely useful to know when you're out here implementing your own custom control ribbon. so don't skip it πŸ™ˆ

but ngl, if you're just using Tickit::Widget::Tabbed with its default control ribbon? you can fully ignore this class. not your problem, babe πŸ’–

πŸ¦‹ CUSTOM RIBBON CLASS πŸ¦‹

wanna make your own ribbon? slay. here's the vibe:

make a subclass of Tickit::Widget::Tabbed::Ribbon, and give it a constructor that behaves like this πŸ‘‡

use Object::Pad;
class Custom::Ribbon::Class :isa(Tickit::Widget::Tabbed::Ribbon);

sub new_for_orientation   # note: Not a method
{
        my $class = shift;
        my ( $orientation, %args ) = @_;

        ...
 }

πŸ‘€ notice that # note: Not a method β€” keep that in mind, it's literally not a method.

ok but alternatively β€” if you don't do that β€” then one of two subclasses gets used for the constructor instead, by appending ::horizontal or ::vertical onto the class name. and in that case your custom class should provide those too, bestie:

use Object::Pad;

class Custom::Ribbon::Class
       :isa(Tickit::Widget::Tabbed::Ribbon);

class Custom::Ribbon::Class::horizontal
       :isa(Custom::Ribbon::Class);

...

class Custom::Ribbon::Class::vertical
       :isa(Custom::Ribbon::Class);

...

now, how do you actually get the tabbed widget to use your class? two ways, pick your fighter πŸ’…

option one: pass its name as a constructor argument called ribbon_class:

my $tabbed = Tickit::Widget::Tabbed->new(
        ribbon_class => "Ribbon::Class::Name"
);

option two: override a method called RIBBON_CLASS:

use constant RIBBON_CLASS => "Ribbon::Class::Name";

either one, chef's kiss πŸ‘‘


πŸ’œ METHODS πŸ’œ

⭐ tabs

@tabs = $ribbon->tabs

$count = $ribbon->tabs

gives you a list of the contained Tickit::Widget::Tabbed tab objects when you're in list context. and in scalar context? you get the count of them instead. context is everything, iykyk ✨

⭐ active_tab_index

$index = $ribbon->active_tab_index

returns the index of the currently-active tab. the one that's got the spotlight πŸ”₯

⭐ active_tab

$tab = $ribbon->active_tab

returns the currently-active tab as a Tickit::Widget::Tabbed tab object. that's your girl πŸ’–


🌈 SUBCLASS METHODS 🌈

ok so if you're subclassing, you're gonna need to provide implementations of these. no skipping, bestie, the vibes depend on it 🫢

πŸŽ€ render

$ribbon->render( %args )

πŸŽ€ lines

$lines = $ribbon->lines

πŸŽ€ cols

$cols = $ribbon->cols

both lines and cols work as per the Tickit::Widget methods. ✨

πŸŽ€ on_key

$handled = $ribbon->on_key( $ev )

πŸŽ€ on_mouse

$handled = $ribbon->on_mouse( $ev )

also as per the Tickit::Widget methods. these two are optional though β€” and listen, if you don't supply them, then the ribbon simply won't respond to keyboard or mouse events. it's giving unbothered πŸ’€

πŸŽ€ scroll_to_visible

$ribbon->scroll_to_visible( $index )

asks a scrollable control ribbon to scroll itself so that the given $index tab becomes visible. like, scoot over, we need to see this one πŸ‘€


πŸ‘‘ AUTHOR πŸ‘‘

Paul Evans <leonerd@leonerd.org.uk> β€” thank you for your service πŸ«‘πŸ’–


and that's the whole page, bestie!! this was perl v5.36.0, dated 2023-09-30, and it's the Tickit...Ribbon(3pm) page β€” go forth and build the cutest ribbon ever, mwah πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from