ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.346 by root, Mon Aug 14 01:21:02 2006 UTC vs.
Revision 1.347 by root, Mon Aug 14 03:41:28 2006 UTC

1138 my ($class, %arg) = @_; 1138 my ($class, %arg) = @_;
1139 1139
1140 if ((exists $arg{label}) && !ref $arg{label}) { 1140 if ((exists $arg{label}) && !ref $arg{label}) {
1141 $arg{label} = new CFPlus::UI::Label 1141 $arg{label} = new CFPlus::UI::Label
1142 align => 1, 1142 align => 1,
1143 valign => 1, 1143 valign => 0,
1144 text => $arg{label}, 1144 text => $arg{label},
1145 fontsize => ($arg{border} || 0.8) * 0.75; 1145 fontsize => ($arg{border} || 0.8) * 0.75;
1146 } 1146 }
1147 1147
1148 my $self = $class->SUPER::new ( 1148 my $self = $class->SUPER::new (
2853} 2853}
2854 2854
2855sub current_paragraph { 2855sub current_paragraph {
2856 my ($self) = @_; 2856 my ($self) = @_;
2857 2857
2858 $self->force_uptodate;
2859 $self->{top_paragraph} - 1 2858 $self->{top_paragraph} - 1
2860} 2859}
2861 2860
2862sub scroll_to { 2861sub scroll_to {
2863 my ($self, $para) = @_; 2862 my ($self, $para) = @_;
2864 2863
2865 $self->force_uptodate;
2866
2867 $para = List::Util::max 0, List::Util::min $#{$self->{par}}, $para; 2864 $para = List::Util::max 0, List::Util::min $#{$self->{par}}, $para;
2868 2865
2869 $self->{children}[1]->set_value ($self->{par}[$para]{y}); 2866 $self->{scroll_to} = $para;
2867 $self->update;
2870} 2868}
2871 2869
2872sub clear { 2870sub clear {
2873 my ($self) = @_; 2871 my ($self) = @_;
2874 2872
2903} 2901}
2904 2902
2905sub scroll_to_bottom { 2903sub scroll_to_bottom {
2906 my ($self) = @_; 2904 my ($self) = @_;
2907 2905
2908 $self->{scroll_to_bottom} = 1; 2906 $self->{scroll_to} = $#{$self->{par}};
2909 $self->update; 2907 $self->update;
2910} 2908}
2911 2909
2912sub force_uptodate { 2910sub force_uptodate {
2913 my ($self) = @_; 2911 my ($self) = @_;
2914 2912
2915 if (delete $self->{need_reflow}) { 2913 if (delete $self->{need_reflow}) {
2916 my ($W, $H) = @{$self->{children}[0]}{qw(w h)}; 2914 my ($W, $H) = @{$self->{children}[0]}{qw(w h)};
2917 2915
2918 my $height = 0; 2916 my $height = 0;
2919 my $paridx;
2920 my $top_paragraph;
2921 my $top = int $self->{children}[1]{range}[0];
2922 2917
2923 for my $para (@{$self->{par}}) { 2918 for my $para (@{$self->{par}}) {
2924 if ($para->{w} != $W && ($para->{wrapped} || $para->{w} > $W)) { 2919 if ($para->{w} != $W && ($para->{wrapped} || $para->{w} > $W)) {
2925 my $layout = $self->get_layout ($para); 2920 my $layout = $self->get_layout ($para);
2926 my ($w, $h) = $layout->size; 2921 my ($w, $h) = $layout->size;
2929 $para->{h} = $h; 2924 $para->{h} = $h;
2930 $para->{wrapped} = $layout->has_wrapped; 2925 $para->{wrapped} = $layout->has_wrapped;
2931 } 2926 }
2932 2927
2933 $para->{y} = $height; 2928 $para->{y} = $height;
2934
2935 $paridx++;
2936 $top_paragraph ||= $paridx if $height >= $top;
2937
2938 $height += $para->{h}; 2929 $height += $para->{h};
2939 } 2930 }
2940 2931
2941 $self->{top_paragraph} = $top_paragraph;
2942 $self->{height} = $height; 2932 $self->{height} = $height;
2943
2944 $self->{children}[1]->set_range ([$self->{children}[1]{range}[0], 0, $height, $H, 1]); 2933 $self->{children}[1]->set_range ([$self->{children}[1]{range}[0], 0, $height, $H, 1]);
2945 2934
2946 delete $self->{texture}; 2935 delete $self->{texture};
2947 } 2936 }
2948 2937
2949 if (delete $self->{scroll_to_bottom}) { 2938 if (my $paridx = delete $self->{scroll_to}) {
2950 $self->{children}[1]->set_value (1e10); 2939 $self->{children}[1]->set_value ($self->{par}[$paridx]{y});
2951 } 2940 }
2952} 2941}
2953 2942
2954sub update { 2943sub update {
2955 my ($self) = @_; 2944 my ($self) = @_;
2967 2956
2968 $self->{texture} ||= new_from_opengl CFPlus::Texture $W, $H, sub { 2957 $self->{texture} ||= new_from_opengl CFPlus::Texture $W, $H, sub {
2969 glClearColor 0, 0, 0, 0; 2958 glClearColor 0, 0, 0, 0;
2970 glClear GL_COLOR_BUFFER_BIT; 2959 glClear GL_COLOR_BUFFER_BIT;
2971 2960
2961 my $top = int $self->{children}[1]{range}[0];
2962
2963 my $paridx = 0;
2964 my $top_paragraph;
2972 my $top = int $self->{children}[1]{range}[0]; 2965 my $top = int $self->{children}[1]{range}[0];
2973 2966
2974 my $y0 = $top; 2967 my $y0 = $top;
2975 my $y1 = $top + $H; 2968 my $y1 = $top + $H;
2976 2969
2994 2987
2995 $_->draw; 2988 $_->draw;
2996 } 2989 }
2997 } 2990 }
2998 } 2991 }
2992
2993 $paridx++;
2994 $top_paragraph ||= $paridx if $y >= $top;
2999 } 2995 }
2996
2997 $self->{top_paragraph} = $top_paragraph;
3000 }; 2998 };
3001 }); 2999 });
3002} 3000}
3003 3001
3004sub reconfigure { 3002sub reconfigure {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines