File: Box.pm

package info (click to toggle)
libcircle-fe-term-perl 0.240250-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 164 kB
  • sloc: perl: 1,003; makefile: 10
file content (57 lines) | stat: -rw-r--r-- 1,230 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#  You may distribute under the terms of the GNU General Public License
#
#  (C) Paul Evans, 2010-2023 -- leonerd@leonerd.org.uk

package Circle::FE::Term::Widget::Box 0.240250;

use v5.26;
use warnings;
use constant type => "Box";

use Tickit::Widget::HBox;
use Tickit::Widget::VBox;

sub build
{
   my $class = shift;
   my ( $obj, $tab ) = @_;

   my $orientation = $obj->prop("orientation");
   my $widget;
   if( $orientation eq "vertical" ) {
      $widget = Tickit::Widget::VBox->new(
         classes => $obj->prop( "classes" ),
      );
   }
   elsif( $orientation eq "horizontal" ) {
      $widget = Tickit::Widget::HBox->new(
         classes => $obj->prop( "classes" ),
      );
   }
   else {
      die "Unrecognised orientation '$orientation'";
   }

   foreach my $c ( @{ $obj->prop("children") } ) {
      if( $c->{child} ) {
         my $childwidget = $tab->build_widget( $c->{child} );
         $widget->add( $childwidget, expand => $c->{expand} );
      }
      else {
         # Just add spacing
         $widget->add( Tickit::Widget::Static->new( text => " " ), expand => 1 );
      }
   }

   return $widget;
}

Tickit::Style->load_style( <<'EOF' );
HBox.status {
  spacing: 1;
  bg: "blue";
}

EOF

0x55AA;