| 1 | package Graphics::Primitive::TextBox; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use MooseX::Storage; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | # enum 'Graphics::Primitive::TextBox::Directions' => [( | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # 'auto', 'ltr', 'rtl' | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # )]; | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # enum 'Graphics::Primitive::TextBox::WrapModes' | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # => [qw(word char word_char)]; | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # enum 'Graphics::Primitive::TextBox::EllipsizeModes' | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # => [qw(none start middle end)]; | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | extends 'Graphics::Primitive::Component'; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | with qw(MooseX::Clone Graphics::Primitive::Aligned); | |||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | with Storage (format => 'JSON', io => 'File'); | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Graphics::Primitive::Font; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | has 'angle' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 22 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | isa => 'Num', | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | trigger => sub { my ($self) = @_; $self->prepared(0); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | has 'direction' => ( | |||||||||||||||||||||||||||||||||||||||||
| 27 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 28 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | has 'ellipsize_mode' => ( | |||||||||||||||||||||||||||||||||||||||||
| 31 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 32 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | has 'font' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 35 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 36 | isa => 'Graphics::Primitive::Font', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | default => sub { Graphics::Primitive::Font->new }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | trigger => sub { my ($self) = @_; $self->prepared(0); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | ▶ | has '+horizontal_alignment' => ( default => sub { 'left'} ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | has 'indent' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 42 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 43 | isa => 'Num', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | default => sub { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 46 | has 'justify' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 47 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | default => sub { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | has 'layout' => ( | |||||||||||||||||||||||||||||||||||||||||
| 52 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 53 | does => 'Graphics::Primitive::Driver::TextLayout', | ||||||||||||||||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | has 'lines' => ( | |||||||||||||||||||||||||||||||||||||||||
| 56 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 58 | has 'line_height' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 59 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 60 | isa => 'Num', | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | trigger => sub { my ($self) = @_; $self->prepared(0); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 63 | has 'text' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 64 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 65 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | ▶ | trigger => sub { my ($self) = @_; $self->prepared(0); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 68 | has 'text_bounding_box' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 69 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 70 | isa => 'Geometry::Primitive::Rectangle', | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | trigger => sub { my ($self) = @_; $self->prepared(0); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | has '+vertical_alignment' => ( default => sub { 'top'} ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | has 'wrap_mode' => ( | |||||||||||||||||||||||||||||||||||||||||
| 75 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 76 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | override('prepare', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my ($self, $driver) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | super; | |||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | return unless defined($self->text) || defined($self->lines) || defined($self->layout); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $self->text or defined $self->lines or defined $self->layout
defined $self->text or defined $self->lines
MC/DC0%0/3
defined $self->text or defined $self->lines or defined $self->layout
defined $self->text
defined $self->lines
defined $self->layout
Truth table0%0/4
A or B or C
A= defined $self->textB= defined $self->linesC= defined $self->layout
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | unless($self->lines) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my $layout = $driver->get_textbox_layout($self); | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $self->layout($layout); | |||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my $mw = $layout->width + $self->outside_width; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if($mw > $self->minimum_width) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $self->minimum_width($mw); | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $mh = $layout->height + $self->outside_height; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if($mh > $self->minimum_height) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $self->minimum_height($mh); | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | }); | |||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 105 | __END__ | ||||||||||||||||||||||||||||||||||||||||||