--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/11 12:21:29 1.58 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/11 13:05:12 1.59 @@ -640,7 +640,13 @@ $height ||= $::FONTSIZE; # TODO: color, and make height, xyz etc. optional - my $self = $class->SUPER::new (x => $x, y => $y, z => $z, height => $height); + my $self = $class->SUPER::new ( + x => $x, + y => $y, + z => $z, + height => $height, + layout => new Crossfire::Client::Layout, + ); $self->set_text ($text); @@ -651,9 +657,9 @@ my ($self, $text) = @_; $self->{text} = $text; - $self->{texture} = new_from_text Crossfire::Client::Texture $text, $self->{height}; + $self->{layout}->set_markup ($text); - $self->update; + delete $self->{texture}; } sub get_text { @@ -665,23 +671,34 @@ sub size_request { my ($self) = @_; - if ($self->{texture}{width} > 1 && $self->{texture}{height} > 1) { #TODO: hack - ( - $self->{texture}{width}, - $self->{texture}{height}, - ) - } else { - my ($w, $h, $data) = Crossfire::Client::font_render "Yy", $self->{height}; + $self->{layout}->set_width; + $self->{layout}->size +# if ($self->{texture}{width} > 1 && $self->{texture}{height} > 1) { #TODO: hack +# ( +# $self->{texture}{width}, +# $self->{texture}{height}, +# ) +# } else { +# my ($w, $h, $data) = Crossfire::Client::font_render "Yy", $self->{height}; +# +# ($w, $h) +# } +} - ($w, $h) - } +sub size_allocate { + my ($self, $w, $h) = @_; + $self->SUPER::size_allocate ($w, $h); + delete $self->{texture}; } sub _draw { my ($self) = @_; - my $tex = $self->{texture}; + my $tex = $self->{texture} ||= do { + $self->{layout}->set_width ($self->{w}); + new_from_layout Crossfire::Client::Texture $self->{layout}; + }; glEnable GL_BLEND; glEnable GL_TEXTURE_2D;