… | |
… | |
140 | 0 |
140 | 0 |
141 | } |
141 | } |
142 | |
142 | |
143 | sub size_request { |
143 | sub size_request { |
144 | require Carp; |
144 | require Carp; |
145 | Carp::confess "size_request is abtract"; |
145 | Carp::confess "size_request is abstract"; |
146 | } |
146 | } |
147 | |
147 | |
148 | sub configure { |
148 | sub configure { |
149 | my ($self, $x, $y, $w, $h) = @_; |
149 | my ($self, $x, $y, $w, $h) = @_; |
150 | |
150 | |
… | |
… | |
152 | my $w2 = List::Util::min $w, int $h * $self->{aspect}; |
152 | my $w2 = List::Util::min $w, int $h * $self->{aspect}; |
153 | my $h2 = List::Util::min $h, int $w / $self->{aspect}; |
153 | my $h2 = List::Util::min $h, int $w / $self->{aspect}; |
154 | |
154 | |
155 | # use alignment to adjust x, y |
155 | # use alignment to adjust x, y |
156 | |
156 | |
157 | $x += ($w - $w2) * 0.5; |
157 | $x += int +($w - $w2) * 0.5; |
158 | $y += ($h - $h2) * 0.5; |
158 | $y += int +($h - $h2) * 0.5; |
159 | |
159 | |
160 | ($w, $h) = ($w2, $h2); |
160 | ($w, $h) = ($w2, $h2); |
161 | } |
161 | } |
162 | |
162 | |
163 | if ($self->{x} != $x || $self->{y} != $y) { |
163 | if ($self->{x} != $x || $self->{y} != $y) { |
… | |
… | |
1115 | |
1115 | |
1116 | sub set_fontsize { |
1116 | sub set_fontsize { |
1117 | my ($self, $fontsize) = @_; |
1117 | my ($self, $fontsize) = @_; |
1118 | |
1118 | |
1119 | $self->{fontsize} = $fontsize; |
1119 | $self->{fontsize} = $fontsize; |
1120 | $self->update; |
1120 | $self->check_size; |
1121 | } |
1121 | } |
1122 | |
1122 | |
1123 | sub _draw { |
1123 | sub _draw { |
1124 | my ($self) = @_; |
1124 | my ($self) = @_; |
1125 | |
1125 | |
… | |
… | |
1487 | |
1487 | |
1488 | $loaded_images{$self->{image}} ||= |
1488 | $loaded_images{$self->{image}} ||= |
1489 | new_from_file CFClient::Texture CFClient::find_rcfile $self->{image}, mipmap => 1; |
1489 | new_from_file CFClient::Texture CFClient::find_rcfile $self->{image}, mipmap => 1; |
1490 | |
1490 | |
1491 | my $tex = $self->{tex} = $loaded_images{$self->{image}}; |
1491 | my $tex = $self->{tex} = $loaded_images{$self->{image}}; |
|
|
1492 | |
|
|
1493 | Scalar::Util::weaken $loaded_images{$self->{image}}; |
1492 | |
1494 | |
1493 | $self->{aspect} = $tex->{w} / $tex->{h}; |
1495 | $self->{aspect} = $tex->{w} / $tex->{h}; |
1494 | |
1496 | |
1495 | $self |
1497 | $self |
1496 | } |
1498 | } |
… | |
… | |
1664 | sub set_fontsize { |
1666 | sub set_fontsize { |
1665 | my ($self, $fsize) = @_; |
1667 | my ($self, $fsize) = @_; |
1666 | |
1668 | |
1667 | $self->{value}->set_fontsize ($fsize); |
1669 | $self->{value}->set_fontsize ($fsize); |
1668 | $self->{max} ->set_fontsize ($fsize); |
1670 | $self->{max} ->set_fontsize ($fsize); |
1669 | $self->update; |
|
|
1670 | } |
1671 | } |
1671 | |
1672 | |
1672 | sub set_value { |
1673 | sub set_value { |
1673 | my ($self, $val, $max) = @_; |
1674 | my ($self, $val, $max) = @_; |
1674 | |
1675 | |