NAME

Term::Fabulous::Widget::Tabs::Button - The button of one tab in a tab bar

SYNOPSIS

use Term::Fabulous::Widget::Tabs::Bar;
use Term::Fabulous::Widget::Tabs::Button;

my $bar = Term::Fabulous::Widget::Tabs::Bar->new;
$bar->add_child(
	Term::Fabulous::Widget::Tabs::Button->new( title => 'General' ),
	Term::Fabulous::Widget::Tabs::Button->new( title => 'Network', icon => "\x{2601}" ),
	Term::Fabulous::Widget::Tabs::Button->new( title => 'Licenses', disabled => 1 ),
);

DESCRIPTION

A tab button is one tab of a Term::Fabulous::Widget::Tabs::Bar: a Term::Fabulous::Widget::Button with a border on three sides, open toward the page, that shows a title and an optional icon. The bar makes one tab the active one: it is drawn one cell larger toward the page, so that it joins the page's border, and its label is drawn in the bar's active_text_color. The other tabs are closed by the line of the bar and show their labels in text_color.

The look (the side the bar is on, whether the label is written horizontally or downwards, the padding, the line style and the colors) comes from the bar, see "CONSTRUCTOR" in Term::Fabulous::Widget::Tabs::Bar. As a Button, a tab takes the focus (only the active tab does, see "KEYS" in Term::Fabulous::Widget::Tabs::Bar), reacts to clicks and Enter and Space, shows the focus with its border color, the pointer with hover_background_color and can be disabled; a pressed tab shows no pressed look.

A Term::Fabulous::Widget::Tabs makes the tab buttons for its pages itself; you create them only for a bar of your own.

CONSTRUCTOR

new

my $tab = Term::Fabulous::Widget::Tabs::Button->new(%parameters);

Accepts the parameters of "CONSTRUCTOR" in Term::Fabulous::Widget::Button (id, layout, disabled, can_focus, ...), of which the border, the padding, the layout direction, the colors and pressed_background_color are set by the look, and the ones below. Unknown parameters die.

title

A character string. Default: ''. The text of the tab.

icon

A character string, or undef. Default: undef. A short text, for example a symbol, shown before the title with a cell between them; above the title in a tab with a vertical label.

METHODS

The methods of Term::Fabulous::Widget::Button (disabled, is_enabled, is_focused, is_hovered, activate, ...), plus:

title

$tab->title('Advanced');

Accessor for the title; the new text shows in the next frame.

icon

$tab->icon("\x{2699}");
$tab->icon(undef);

Accessor for the icon.

is_active

if ( $tab->is_active ) { ... }

1 while the tab is the active one of its bar. The bar sets it: see "select" in Term::Fabulous::Widget::Tabs::Bar.

focus

$tab->focus;

Gives the keyboard focus to the tab. Dies when the tab is not part of a Term::Fabulous, or cannot take the focus (an inactive or disabled tab).

bar

my $bar = $tab->bar;

The Term::Fabulous::Widget::Tabs::Bar the tab is in, or undef.

refresh_look

$tab->refresh_look;

Updates the borders, the padding, the label and the colors from the tab's state and the bar's settings. The bar calls it when its settings change; call it yourself after changing the tab's look behind its back. Returns the tab.

default_look

my %look = Term::Fabulous::Widget::Tabs::Button->default_look;

Class method: the look a tab shows outside a bar, as a hash of the bar's look parameters (side, orientation, tab_padding, line_style, line_color, text_color, active_text_color, active_bold, hover_background_color, focus_border_color, disabled_color) and their defaults.

EVENTS

A tab fires the events of a Button: Activate for a click or Enter or Space, OnFocus, OnBlur, OnHoverStart, ... The bar fires Term::Fabulous::Event::Select when a tab is chosen.

KDL PROPERTIES

The properties of "KDL PROPERTIES" in Term::Fabulous::Widget::Button, plus title and icon (strings):

use Term::Fabulous::Widget::Tabs::Button as Tab

Tab "network" {
	title "Network"
	icon "#"
	disabled #true
}

SEE ALSO

Term::Fabulous::Widget::Tabs::Bar, Term::Fabulous::Widget::Tabs, Term::Fabulous::Widget::Button, "TABS" in Term::Fabulous::Manual::Layout.