lib/TUI/Gadgets/ClickTester.pm

filter: Statementstmt 65.6% 42 / 64 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 12 / 16 Podpod 100% 4 / 4 totaltotal 64.4% 58 / 90 CC 4 SCAR 10.0
CC
4
Cov
60%
handleEvent
7.8
draw
6.0
new_TClickTester
2.0
CRAP 2.7
« lib/TUI/Drivers/ScreenCharacter.pm ↑ Summary lib/TUI/Objects/Point.pm »
1 package TUI::Gadgets::ClickTester;
2 # ABSTRACT: A mouse clickable tester gadget for the framework
3
4 5 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 5 our $VERSION = '2.000002';
9 5 $VERSION =~ tr/_//d;
10 5 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 5 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 our @EXPORT = qw(
14 TClickTester
15 new_TClickTester
16 );
17
18 5 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use TUI::toolkit::Types qw( :types );
Subroutine BEGIN: called CC=1 SCAR=0.0
20
21 5 ▶use TUI::Drivers::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
22 evMouseDown
23 meDoubleClick
24 5 );
25 5 ▶use TUI::Dialogs::StaticText;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 5 ▶use TUI::Gadgets::Const qw( cpMousePalette );
Subroutine BEGIN: called CC=1 SCAR=0.0
27 5 ▶use TUI::Views::DrawBuffer;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 5 ▶use TUI::Views::Palette;
Subroutine BEGIN: called CC=1 SCAR=0.0
29
30 sub TClickTester() { __PACKAGE__ }
31 0 ▶sub new_TClickTester { __PACKAGE__->from(@_) }
Subroutine new_TClickTester: not called CC=1 SCAR=6.9
Pod documented
32
33 5 extends TStaticText;
34
35 # private attributes
36 5 has clicked => ( is => 'bare', default => false );
37
38 0 ▶sub getPalette { # $palette ()
Subroutine getPalette: not called CC=1 SCAR=6.9
Pod documented
39 0 state $sig = signature(
40 method => Object,
41 pos => [],
42 );
43 0 my ( $self ) = $sig->( @_ );
44 0 state $palette = TPalette->new(
45 data => cpMousePalette,
46 size => length( cpMousePalette ),
47 );
48 0 return $palette->clone();
49 }
50
51 0 ▶sub handleEvent { # void ($event)
Subroutine handleEvent: not called CC=3 SCAR=20.6
Pod documented
52 5 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
53 0 state $sig = signature(
54 method => Object,
55 pos => [Object],
56 );
57 0 my ( $self, $event ) = $sig->( @_ );
58 0 $self->SUPER::handleEvent( $event );
59
60 0 ▶ if ( $event->{what} == evMouseDown ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($event->{"what"} == 1) 0 0 0
61 0 ▶ if ( $event->{mouse}{eventFlags} & meDoubleClick ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($event->{"mouse"}{"eventFlags"} & 2) 0 0 0
62 0 $self->{clicked} = !$self->{clicked};
63 0 $self->drawView();
64 }
65 0 $self->clearEvent( $event );
66 }
67 0 return;
68 }
69
70 0 ▶sub draw { # void ()
Subroutine draw: not called CC=2 SCAR=17.9
Pod documented
71 0 state $sig = signature(
72 method => Object,
73 pos => [],
74 );
75 0 my ( $self ) = $sig->( @_ );
76
77 0 my $buf = TDrawBuffer->new();
78 my $c = $self->{clicked}
79 0 ▶ ? $self->getColor( 2 )
Branch: 1 branch
BranchTrueFalseTotal
$self->{'clicked'} ? : 0 0 0
80 : $self->getColor( 1 );
81
82 0 $buf->moveChar( 0, ' ', $c, $self->{size}{x} );
83 0 $buf->moveStr( 0, $self->{text}, $c );
84 0 $self->writeLine( 0, 0, $self->{size}{x}, 1, $buf );
85 0 return;
86 }
87
88 5 1
89
90 __END__
« lib/TUI/Drivers/ScreenCharacter.pm ↑ Summary lib/TUI/Objects/Point.pm »