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.293 by root, Tue Jun 6 03:05:16 2006 UTC vs.
Revision 1.297 by root, Wed Jun 7 06:28:30 2006 UTC

315} 315}
316 316
317sub move_abs { 317sub move_abs {
318 my ($self, $x, $y, $z) = @_; 318 my ($self, $x, $y, $z) = @_;
319 319
320 $self->{x} = List::Util::max 0, int $x; 320 $self->{x} = List::Util::max 0, List::Util::min $self->{root}{w} - $self->{w}, int $x;
321 $self->{y} = List::Util::max 0, int $y; 321 $self->{y} = List::Util::max 0, List::Util::min $self->{root}{h} - $self->{h}, int $y;
322 $self->{z} = $z if defined $z; 322 $self->{z} = $z if defined $z;
323 323
324 $self->update; 324 $self->update;
325} 325}
326 326
1658 : ($self->{h} - $tex->{h}) * 0.5); 1658 : ($self->{h} - $tex->{h}) * 0.5);
1659 }; 1659 };
1660 1660
1661 glEnable GL_TEXTURE_2D; 1661 glEnable GL_TEXTURE_2D;
1662 1662
1663 my $w = List::Util::min $self->{w} + 4, $tex->{w};
1664 my $h = List::Util::min $self->{h} + 2, $tex->{h};
1665
1663 if ($tex->{format} == GL_ALPHA) { 1666 if ($tex->{format} == GL_ALPHA) {
1664 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 1667 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
1665 glColor @{$self->{fg}}; 1668 glColor @{$self->{fg}};
1666 $tex->draw_quad_alpha ($self->{ox}, $self->{oy}); 1669 $tex->draw_quad_alpha ($self->{ox}, $self->{oy}, $w, $h);
1667 } else { 1670 } else {
1668 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 1671 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1669 $tex->draw_quad_alpha_premultiplied ($self->{ox}, $self->{oy}); 1672 $tex->draw_quad_alpha_premultiplied ($self->{ox}, $self->{oy}, $w, $h);
1670 } 1673 }
1671 1674
1672 glDisable GL_TEXTURE_2D; 1675 glDisable GL_TEXTURE_2D;
1673} 1676}
1674 1677
2304sub set_range { 2307sub set_range {
2305 my ($self, $range) = @_; 2308 my ($self, $range) = @_;
2306 2309
2307 ($range, $self->{range}) = ($self->{range}, $range); 2310 ($range, $self->{range}) = ($self->{range}, $range);
2308 2311
2309 $self->update
2310 if "@$range" ne "@{$self->{range}}"; 2312 if ("@$range" ne "@{$self->{range}}") {
2313 $self->update;
2314 $self->set_value ($self->{range}[0]);
2315 }
2311} 2316}
2312 2317
2313sub set_value { 2318sub set_value {
2314 my ($self, $value) = @_; 2319 my ($self, $value) = @_;
2315 2320
2462sub set_range { shift->{slider}->set_range (@_) } 2467sub set_range { shift->{slider}->set_range (@_) }
2463sub set_value { shift->{slider}->set_value (@_) } 2468sub set_value { shift->{slider}->set_value (@_) }
2464 2469
2465############################################################################# 2470#############################################################################
2466 2471
2467package CFClient::UI::TextView; 2472package CFClient::UI::TextScroller;
2468 2473
2469our @ISA = CFClient::UI::HBox::; 2474our @ISA = CFClient::UI::HBox::;
2470 2475
2471use CFClient::OpenGL; 2476use CFClient::OpenGL;
2472 2477
2568 2573
2569 return unless $self->{h} > 0; 2574 return unless $self->{h} > 0;
2570 2575
2571 delete $self->{texture}; 2576 delete $self->{texture};
2572 2577
2573 $ROOT->on_post_alloc ($self, sub { 2578 $ROOT->on_post_alloc ($self => sub {
2574 my ($W, $H) = @{$self->{children}[0]}{qw(w h)}; 2579 my ($W, $H) = @{$self->{children}[0]}{qw(w h)};
2575 2580
2576 if (delete $self->{need_reflow}) { 2581 if (delete $self->{need_reflow}) {
2577 my $height = 0; 2582 my $height = 0;
2578 2583
2594 } 2599 }
2595 2600
2596 $self->{height} = $height; 2601 $self->{height} = $height;
2597 2602
2598 $self->{children}[1]->set_range ([$height, 0, $height, $H, 1]); 2603 $self->{children}[1]->set_range ([$height, 0, $height, $H, 1]);
2599 2604
2600 delete $self->{texture}; 2605 delete $self->{texture};
2601 } 2606 }
2602 2607
2603 $self->{texture} ||= new_from_opengl CFClient::Texture $W, $H, sub { 2608 $self->{texture} ||= new_from_opengl CFClient::Texture $W, $H, sub {
2604 glClearColor 0, 0, 0, 0; 2609 glClearColor 0, 0, 0, 0;
2784 or return; 2789 or return;
2785 2790
2786 my ($x, $y) = $widget->coord2global ($widget->{w}, 0); 2791 my ($x, $y) = $widget->coord2global ($widget->{w}, 0);
2787 2792
2788 ($x, $y) = $widget->coord2global (-$self->{w}, 0) 2793 ($x, $y) = $widget->coord2global (-$self->{w}, 0)
2789 if $x + $self->{w} > $::WIDTH; 2794 if $x + $self->{w} > $self->{root}{w};
2790 2795
2791 $self->move_abs ($x, $y); 2796 $self->move_abs ($x, $y);
2792 }); 2797 });
2793} 2798}
2794 2799
3105 3110
3106sub new { 3111sub new {
3107 my $class = shift; 3112 my $class = shift;
3108 3113
3109 my $self = $class->SUPER::new ( 3114 my $self = $class->SUPER::new (
3110 options => [], # [title, value, tooltip], ... 3115 options => [], # [value, title, longdesc], ...
3111 value => undef, 3116 value => undef,
3112 @_, 3117 @_,
3113 ); 3118 );
3114 3119
3115 $self->_set_value ($self->{value}); 3120 $self->_set_value ($self->{value});
3121 my ($self, $ev) = @_; 3126 my ($self, $ev) = @_;
3122 3127
3123 my @menu_items; 3128 my @menu_items;
3124 3129
3125 for (@{ $self->{options} }) { 3130 for (@{ $self->{options} }) {
3126 my ($title, $value, $tooltip) = @$_; 3131 my ($value, $title, $tooltip) = @$_;
3127 3132
3128 push @menu_items, [$tooltip, sub { $self->set_value ($value) }]; 3133 push @menu_items, [$tooltip || $title, sub { $self->set_value ($value) }];
3129 } 3134 }
3130 3135
3131 CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); 3136 CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev);
3132} 3137}
3133 3138
3134sub _set_value { 3139sub _set_value {
3135 my ($self, $value) = @_; 3140 my ($self, $value) = @_;
3136 3141
3137 my ($item) = grep $_->[1] eq $value, @{ $self->{options} } 3142 my ($item) = grep $_->[0] eq $value, @{ $self->{options} }
3138 or return; 3143 or return;
3139 3144
3140 $self->{value} = $item->[1]; 3145 $self->{value} = $item->[0];
3141 $self->set_markup ("$item->[0] ⇓"); 3146 $self->set_markup ("$item->[1] ⇓");
3142 $self->set_tooltip ($item->[2]); 3147 $self->set_tooltip ($item->[2]);
3143} 3148}
3144 3149
3145sub set_value { 3150sub set_value {
3146 my ($self, $value) = @_; 3151 my ($self, $value) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines