| 1 | # You may distribute under the terms of the GNU General Public License | ||
| 2 | # | ||
| 3 | # (C) Paul Evans, 2010-2023 -- leonerd@leonerd.org.uk | ||
| 4 | |||
| 5 | package Circle::FE::Term::Widget::Box 0.240250; | ||
| 6 | |||
| 7 | 1 | ▶ | use v5.26; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use constant type => "Box"; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 0 | ▶ | use Tickit::Widget::HBox; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 12 | use Tickit::Widget::VBox; | ||
| 13 | |||
| 14 | sub build | ||
| 15 | { | ||
| 16 | my $class = shift; | ||
| 17 | my ( $obj, $tab ) = @_; | ||
| 18 | |||
| 19 | my $orientation = $obj->prop("orientation"); | ||
| 20 | my $widget; | ||
| 21 | if( $orientation eq "vertical" ) { | ||
| 22 | $widget = Tickit::Widget::VBox->new( | ||
| 23 | classes => $obj->prop( "classes" ), | ||
| 24 | ); | ||
| 25 | } | ||
| 26 | elsif( $orientation eq "horizontal" ) { | ||
| 27 | $widget = Tickit::Widget::HBox->new( | ||
| 28 | classes => $obj->prop( "classes" ), | ||
| 29 | ); | ||
| 30 | } | ||
| 31 | else { | ||
| 32 | die "Unrecognised orientation '$orientation'"; | ||
| 33 | } | ||
| 34 | |||
| 35 | foreach my $c ( @{ $obj->prop("children") } ) { | ||
| 36 | if( $c->{child} ) { | ||
| 37 | my $childwidget = $tab->build_widget( $c->{child} ); | ||
| 38 | $widget->add( $childwidget, expand => $c->{expand} ); | ||
| 39 | } | ||
| 40 | else { | ||
| 41 | # Just add spacing | ||
| 42 | $widget->add( Tickit::Widget::Static->new( text => " " ), expand => 1 ); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | return $widget; | ||
| 47 | } | ||
| 48 | |||
| 49 | Tickit::Style->load_style( <<'EOF' ); | ||
| 50 | HBox.status { | ||
| 51 | spacing: 1; | ||
| 52 | bg: "blue"; | ||
| 53 | } | ||
| 54 | |||
| 55 | EOF | ||
| 56 | |||
| 57 | 0x55AA; | ||