--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/23 02:50:42 1.156 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/23 21:47:32 1.157 @@ -213,6 +213,13 @@ # nothing to be done } +sub set_max_size { + my ($self, $w, $h) = @_; + + delete $self->{max_w}; $self->{max_w} = $w if $w; + delete $self->{max_h}; $self->{max_h} = $h if $h; +} + # return top left coordinates sub _topleft { my ($self, $x, $y) = @_; @@ -1101,6 +1108,7 @@ my $self = $class->SUPER::new ( fg => [1, 1, 1], + #font => default_font fontsize => 1, text => "", align => -1, @@ -1156,12 +1164,14 @@ sub size_request { my ($self) = @_; - $self->{layout}->set_width; + $self->{layout}->set_font ($self->{font}) if $self->{font}; + $self->{layout}->set_width ($self->{max_w} || -1); $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); my ($w, $h) = $self->{layout}->size; if (exists $self->{template}) { + $self->{template}->set_font ($self->{font}) if $self->{font}; $self->{template}->set_height ($self->{fontsize} * $::FONTSIZE); my ($w2, $h2) = $self->{template}->size; @@ -1195,6 +1205,7 @@ my ($self) = @_; my $tex = $self->{texture} ||= do { + $self->{layout}->set_font ($self->{font}) if $self->{font}; $self->{layout}->set_width ($self->{w}); $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize} * $::FONTSIZE); new_from_layout CFClient::Texture $self->{layout} @@ -1909,6 +1920,7 @@ my $self = $class->SUPER::new ( fontsize => 1, + #font => default_font @_, layout => (new CFClient::Layout), @@ -1958,6 +1970,7 @@ $self->SUPER::size_allocate ($w, $h); + $self->{layout}->set_font ($self->{font}) if $self->{font}; $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); $self->{layout}->set_width ($self->{children}[0]{w}); @@ -2020,6 +2033,8 @@ my $layout = $self->{layout}; + $layout->set_font ($self->{font}) if $self->{font}; + for my $par (@{$self->{par}}) { my $h = $par->[0]; @@ -2164,10 +2179,9 @@ sub size_request { my ($self) = @_; - my ($w, $h) = @{$self->child}{qw(req_w req_h)}; + $self->child->set_max_size ($::WIDTH * 0.2); - $w = List::Util::min $::WIDTH * 0.2, $w; - $h = List::Util::max $::HEIGHT * 0.2, $h; + my ($w, $h) = @{$self->child}{qw(req_w req_h)}; ($w + 4, $h + 4) }