--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/14 12:17:06 1.102 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/14 13:51:36 1.103 @@ -1352,6 +1352,7 @@ req_h => 13, vertical => 0, can_hover => 1, + inner_pad => 5, @_ ); @@ -1382,7 +1383,11 @@ my ($x, $w) = $self->{vertical} ? ($y, $self->{h}) : ($x, $self->{w}); - $x = $x * ($hi - $lo) / $w + $lo; + my $inner_pad_px = $self->_calc_inner_pad_px ($w); + my $inner_w = $w - $inner_pad_px * 2; # * 2 for left & right + + $x -= $inner_pad_px; # substract the padding + $x = $x * ($hi - $lo) / $inner_w + $lo; $x = $lo if $x < $lo; $x = $hi - $page if $x > $hi - $page; $self->{range}[0] = $x; @@ -1392,6 +1397,14 @@ } } +# the inner_* stuff is for generating a padding for the slider handle, +# so that the handle doesn't leave the texture. This calculation isn't 100% +# correct propably, but it does the job for now +sub _calc_inner_pad_px { + my ($self, $w) = @_; + ($w / 100) * $self->{inner_pad} # % to pixels +} + sub _draw { my ($self) = @_; @@ -1413,12 +1426,8 @@ my ($value, $lo, $hi, $page) = @{$self->{range}}; - # the inner_* stuff is for generating a padding for the slider handle, - # so that the handle doesn't leave the texture. This calculation isn't 100% - # correct propably, but it does the job for now - my $inner_pad = 5; # 5% of width for slider bg texture border - my $inner_pad_px = ($w / 100) * $inner_pad; # % to pixels - my $inner_w = $w - $inner_pad_px * 2; # * 2 for left & right + my $inner_pad_px = $self->_calc_inner_pad_px ($w); + my $inner_w = $w - $inner_pad_px * 2; # * 2 for left & right $page = int $page * $inner_w / ($hi - $lo); $value = int +($value - $lo) * $inner_w / ($hi - $lo);