--- deliantra/Deliantra-Client/DC/UI.pm 2006/08/13 14:38:35 1.342 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/08/13 21:46:10 1.345 @@ -911,8 +911,6 @@ sub _draw { my ($self) = @_; - my ($w, $h) = @$self{qw(w h)}; - my $tex = $self->{texture} or return; @@ -920,7 +918,7 @@ glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; glColor 0, 0, 0, 1; - $tex->draw_quad_alpha_premultiplied (0, 0, $w, $h); + $tex->draw_quad_alpha_premultiplied (0, 0); glDisable GL_TEXTURE_2D; } @@ -1620,6 +1618,7 @@ #text => initial text #markup => initial narkup #max_w => maximum pixel width + #style => 0, # render flags ellipsise => 3, # end layout => (new CFPlus::Layout), fontsize => 1, @@ -1780,7 +1779,7 @@ my $w = List::Util::min $self->{w} + 4, $size->[0]; my $h = List::Util::min $self->{h} + 2, $size->[1]; - $self->{layout}->render ($self->{ox}, $self->{oy}); + $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); } ############################################################################# @@ -1951,10 +1950,9 @@ @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text) } - glColor @{$self->{fg}}; glBegin GL_LINES; - glVertex $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy}; - glVertex $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy} + $self->{cur_h}; + glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy}; + glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy} + $self->{cur_h}; glEnd; } } @@ -2754,6 +2752,23 @@ $self->{children}[1]->set_value ($offset); } +sub current_paragraph { + my ($self) = @_; + + $self->force_uptodate; + $self->{top_paragraph} - 1 +} + +sub scroll_to { + my ($self, $para) = @_; + + $self->force_uptodate; + + $para = List::Util::max 0, List::Util::min $#{$self->{par}}, $para; + + $self->{children}[1]->set_value ($self->{par}[$para]{y}); +} + sub clear { my ($self) = @_; @@ -2794,44 +2809,61 @@ $self->update; } -sub update { +sub force_uptodate { my ($self) = @_; - $self->SUPER::update; + if (delete $self->{need_reflow}) { + my ($W, $H) = @{$self->{children}[0]}{qw(w h)}; - return unless $self->{h} > 0; + my $height = 0; + my $paridx; + my $top_paragraph; + my $top = int $self->{children}[1]{range}[0]; + + for my $para (@{$self->{par}}) { + if ($para->{w} != $W && ($para->{wrapped} || $para->{w} > $W)) { + my $layout = $self->get_layout ($para); + my ($w, $h) = $layout->size; + + $para->{w} = $w + $para->{indent}; + $para->{h} = $h; + $para->{wrapped} = $layout->has_wrapped; + } - delete $self->{texture}; + $para->{y} = $height; - $ROOT->on_post_alloc ($self => sub { - my ($W, $H) = @{$self->{children}[0]}{qw(w h)}; + $paridx++; + $top_paragraph ||= $paridx if $height >= $top; - if (delete $self->{need_reflow}) { - my $height = 0; + $height += $para->{h}; + } - for my $para (@{$self->{par}}) { - if ($para->{w} != $W && ($para->{wrapped} || $para->{w} > $W)) { - my $layout = $self->get_layout ($para); - my ($w, $h) = $layout->size; + $self->{top_paragraph} = $top_paragraph; + $self->{height} = $height; - $para->{w} = $w + $para->{indent}; - $para->{h} = $h; - $para->{wrapped} = $layout->has_wrapped; - } + $self->{children}[1]->set_range ([$self->{children}[1]{range}[0], 0, $height, $H, 1]); - $height += $para->{h}; - } + delete $self->{texture}; + } - $self->{height} = $height; + if (delete $self->{scroll_to_bottom}) { + $self->{children}[1]->set_value (1e10); + } +} - $self->{children}[1]->set_range ([$self->{children}[1]{range}[0], 0, $height, $H, 1]); +sub update { + my ($self) = @_; - delete $self->{texture}; - } + $self->SUPER::update; - if (delete $self->{scroll_to_bottom}) { - $self->{children}[1]->set_value (1e10); - } + return unless $self->{h} > 0; + + delete $self->{texture}; + + $ROOT->on_post_alloc ($self => sub { + $self->force_uptodate; + + my ($W, $H) = @{$self->{children}[0]}{qw(w h)}; $self->{texture} ||= new_from_opengl CFPlus::Texture $W, $H, sub { glClearColor 0, 0, 0, 0; @@ -2842,13 +2874,11 @@ my $y0 = $top; my $y1 = $top + $H; - my $y = 0; - for my $para (@{$self->{par}}) { my $h = $para->{h}; + my $y = $para->{y}; if ($y0 < $y + $h && $y < $y1) { - my $layout = $self->get_layout ($para); $layout->render ($para->{indent}, $y - $y0); @@ -2866,8 +2896,6 @@ } } } - - $y += $h; } }; }); @@ -2999,7 +3027,7 @@ markup => $tooltip, max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, fontsize => 0.8, - fg => [0, 0, 0, 1], + style => 1, # FLAG_INVERSE ellipsise => 0, font => ($widget->{tooltip_font} || $::FONT_PROP), );