blib/lib/Gtk2/Ex/MindMapView/HotSpot/Grip/Round.pm untested

filter: Statementstmt 0.0% 0 / 48 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 66 CC 2 SCAR 9.6
CC
2
Cov
0%
hotspot_adjust_event_handler
6.0
new
2.0
hotspot_get_image
2.0
CRAP 2.6
1 package Gtk2::Ex::MindMapView::HotSpot::Grip::Round;
2  
3 our $VERSION = '0.000001';
4  
5 use warnings;
6 use strict;
7 use Carp;
8  
9 use Gtk2::Ex::MindMapView::ArgUtils;
10  
11 use constant IMAGE_RADIUS=>3;
12  
13 use Glib ':constants';
14  
15 use Gnome2::Canvas;
16  
17 use base 'Gtk2::Ex::MindMapView::HotSpot::Grip';
18  
19 sub new
20 {
21 my ($class, @attributes) = @_;
22  
23 my $self = $class->SUPER::new(@attributes);
24  
25 my %attributes = @attributes;
26  
27 args_valid(\%attributes, qw(item side enabled radius
28 fill_color_gdk outline_color_gdk hotspot_color_gdk));
29  
30 arg_default($self, 'enabled', FALSE);
31  
32 arg_default($self, 'radius', 10);
33  
34 arg_default($self, 'fill_color_gdk', Gtk2::Gdk::Color->parse('white'));
35  
36 arg_default($self, 'outline_color_gdk', Gtk2::Gdk::Color->parse('gray'));
37  
38 arg_default($self, 'hotspot_color_gdk', Gtk2::Gdk::Color->parse('orange'));
39  
40 $self->{image} = $self->hotspot_get_image();
41  
42 return $self;
43 }
44  
45  
46 # $self->hotspot_adjust_event_handler($item);
47  
48 sub hotspot_adjust_event_handler
49 {
50 my ($self, $item) = @_;
51  
52 my $offset = 1;
53  
54 my $r = $self->{radius};
55  
56 my ($x, $y, $width, $height) = $self->{item}->get(qw(x y width height));
57  
58 if ($self->{side} eq 'left')
59 {
60 _set_point($self, $x + ($r / 2) + $offset, $y + $height - ($r / 2) - $offset);
61 }
62 else # $self->{side} eq 'right'
63 {
64 _set_point($self, $x + $width - ($r / 2) - $offset, $y + $height - ($r / 2) - $offset);
65 }
66 }
67  
68  
69 # my $image = $self->hotspot_get_image();
70  
71 sub hotspot_get_image
72 {
73 my $self = shift(@_);
74  
75 return Gnome2::Canvas::Item->new($self->{item}, 'Gnome2::Canvas::Ellipse',
76 fill_color_gdk=>$self->{fill_color_gdk},
77 outline_color_gdk=>$self->{outline_color_gdk});
78 }
79  
80  
81 sub _set_point
82 {
83 my ($self, $x, $y) = @_;
84  
85 $self->{image}->set(x1=>$x - IMAGE_RADIUS, y1=>$y - IMAGE_RADIUS,
86 x2=>$x + IMAGE_RADIUS, y2=>$y + IMAGE_RADIUS);
87 }
88  
89  
90  
91 1; # Magic true value required at end of module
92 __END__