aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/MTools/Comp/MAntiRecouvrementItem.pm12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/MTools/Comp/MAntiRecouvrementItem.pm b/src/MTools/Comp/MAntiRecouvrementItem.pm
index 625cefc..fa1509a 100644
--- a/src/MTools/Comp/MAntiRecouvrementItem.pm
+++ b/src/MTools/Comp/MAntiRecouvrementItem.pm
@@ -85,7 +85,7 @@ sub translate {
my ($self, $delta_x, $delta_y) = @_;
if ($self -> {__added})
{
- if ((abs ($delta_x) >= $self -> mget ('width') / 2) or (abs ($delta_y) >= $self -> mget ('height') / 2))
+ if ((abs ($delta_x) >= __max_of(2, $self -> mget ('width') / 2)) or (abs ($delta_y) >= __max_of(2, $self -> mget ('height') / 2)))
{
my ($mini_dx, $mini_dy) = (int ($delta_x / 2), int ($delta_y / 2));
$self -> translate ($mini_dx, $mini_dy);
@@ -164,6 +164,16 @@ sub __update_xy {
$self -> notify ('TRANSLATED', $delta_x, $delta_y);
}
+sub __max_of {
+ my (@values) = @_;
+ my $res = $values [0];
+ foreach (@values)
+ {
+ $res = $_ if ($_ >= $res);
+ }
+ return $res;
+}
+
sub scale {
my ($self, @params) = @_;
MTools::scale ($self, @params);