--- deliantra/Deliantra-Client/DC/UI.pm 2006/05/24 03:29:20 1.227 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/05/24 03:52:54 1.228 @@ -2295,7 +2295,7 @@ $self->reflow; } -sub text_height { +sub text_size { my ($self, $text, $indent) = @_; my $layout = $self->{layout}; @@ -2304,7 +2304,7 @@ $layout->set_width ($self->{children}[0]{w} - $indent); $layout->set_markup ($text); - ($layout->size)[1] + $layout->size } sub reflow { @@ -2333,9 +2333,9 @@ my ($self, $color, $text, $indent) = @_; for my $line (split /\n/, $text) { - my $height = $self->text_height ($line); - $self->{height} += $height; - push @{$self->{par}}, [$height, $color, $indent, $line]; + my ($w, $h) = $self->text_size ($line); + $self->{height} += $h; + push @{$self->{par}}, [$w + $indent, $h, $color, $indent, $line]; } $self->{children}[1]->set_range ([$self->{height}, 0, $self->{height}, $self->{h}, 1]); @@ -2351,27 +2351,42 @@ delete $self->{texture}; $ROOT->on_post_alloc ($self, sub { + my ($W, $H) = @{$self->{children}[0]}{qw(w h)}; + if (delete $self->{need_reflow}) { my $height = 0; - $height += $_->[0] = $self->text_height ($_->[3], $_->[2]) - for @{$self->{par}}; + my $layout = $self->{layout}; + + $layout->set_height ($self->{fontsize} * $::FONTSIZE); + + for (@{$self->{par}}) { + if (1 || $_->[0] >= $W) { # TODO: works,but needs reconfigure etc. support + $layout->set_width ($W - $_->[3]); + $layout->set_markup ($_->[4]); + my ($w, $h) = $layout->size; + $_->[0] = $w + $_->[3]; + $_->[1] = $h; + } + + $height += $_->[1]; + } $self->{height} = $height; - $self->{children}[1]->set_range ([$height, 0, $height, $self->{h}, 1]); + $self->{children}[1]->set_range ([$height, 0, $height, $H, 1]); delete $self->{texture}; } - $self->{texture} ||= new_from_opengl CFClient::Texture $self->{children}[0]{w}, $self->{children}[0]{h}, sub { + $self->{texture} ||= new_from_opengl CFClient::Texture $W, $H, sub { glClearColor 0.5, 0.5, 0.5, 0; glClear GL_COLOR_BUFFER_BIT; my $top = int $self->{children}[1]{range}[0]; my $y0 = $top; - my $y1 = $top + $self->{h}; + my $y1 = $top + $H; my $y = 0; @@ -2380,19 +2395,20 @@ $layout->set_font ($self->{font}) if $self->{font}; glEnable GL_BLEND; + #TODO# not correct in windows where rgba is forced off glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; for my $par (@{$self->{par}}) { - my $h = $par->[0]; + my $h = $par->[1]; if ($y0 < $y + $h && $y < $y1) { - $layout->set_foreground (@{ $par->[1] }); - $layout->set_width ($self->{w} - $par->[2]); - $layout->set_markup ($par->[3]); + $layout->set_foreground (@{ $par->[2] }); + $layout->set_width ($W - $par->[3]); + $layout->set_markup ($par->[4]); my ($w, $h, $data, $format, $internalformat) = $layout->render; - glRasterPos $par->[2], $y - $y0; + glRasterPos $par->[3], $y - $y0; glDrawPixels $w, $h, $format, GL_UNSIGNED_BYTE, $data; }