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.477 by root, Sun Jan 11 23:50:27 2009 UTC vs.
Revision 1.481 by root, Tue Oct 12 05:11:38 2010 UTC

1package DC::UI; 1package DC::UI;
2 2
3use utf8; 3use common::sense;
4use strict;
5 4
6use List::Util (); 5use List::Util ();
7 6
8use Guard (); 7use Guard ();
9 8
223 222
224############################################################################# 223#############################################################################
225 224
226package DC::UI::Base; 225package DC::UI::Base;
227 226
228use strict; 227use common::sense;
229 228
230use DC::OpenGL; 229use DC::OpenGL;
231 230
232sub new { 231sub new {
233 my $class = shift; 232 my $class = shift;
643 642
644package DC::UI::DrawBG; 643package DC::UI::DrawBG;
645 644
646our @ISA = DC::UI::Base::; 645our @ISA = DC::UI::Base::;
647 646
648use strict; 647use common::sense;
648
649use DC::OpenGL; 649use DC::OpenGL;
650 650
651sub new { 651sub new {
652 my $class = shift; 652 my $class = shift;
653 653
666} 666}
667 667
668sub _draw { 668sub _draw {
669 my ($self) = @_; 669 my ($self) = @_;
670 670
671 my $color = $FOCUS == $self && $self->{active_bg} 671 my $color = $FOCUS == $self
672 ? $self->{active_bg} 672 ? $self->{active_bg} || $self->{bg}
673 : $self->{bg}; 673 : $self->{bg};
674 674
675 if ($color && (@$color < 4 || $color->[3])) { 675 if ($color && (@$color < 4 || $color->[3])) {
676 my ($w, $h) = @$self{qw(w h)}; 676 my ($w, $h) = @$self{qw(w h)};
677 677
2594 2594
2595############################################################################# 2595#############################################################################
2596 2596
2597package DC::UI::Image; 2597package DC::UI::Image;
2598 2598
2599our @ISA = DC::UI::Base::; 2599our @ISA = DC::UI::DrawBG::;
2600 2600
2601use DC::OpenGL; 2601use DC::OpenGL;
2602 2602
2603our %texture_cache; 2603our %texture_cache;
2604 2604
2637 my ($self, $cloning, $path) = @_; 2637 my ($self, $cloning, $path) = @_;
2638 2638
2639 $self->new (path => $path) 2639 $self->new (path => $path)
2640} 2640}
2641 2641
2642sub set_texture {
2643 my ($self, $tex) = @_;
2644
2645 $self->{tex} = $tex;
2646 $self->update;
2647}
2648
2642sub size_request { 2649sub size_request {
2643 my ($self) = @_; 2650 my ($self) = @_;
2644 2651
2645 (int $self->{tex}{w} * $self->{scale}, int $self->{tex}{h} * $self->{scale}) 2652 (int $self->{tex}{w} * $self->{scale}, int $self->{tex}{h} * $self->{scale})
2646} 2653}
2647 2654
2648sub _draw { 2655sub _draw {
2649 my ($self) = @_; 2656 my ($self) = @_;
2657
2658 $self->SUPER::_draw;
2650 2659
2651 my $tex = $self->{tex}; 2660 my $tex = $self->{tex};
2652 2661
2653 my ($w, $h) = ($self->{w}, $self->{h}); 2662 my ($w, $h) = ($self->{w}, $self->{h});
2654 2663
2672package DC::UI::ImageButton; 2681package DC::UI::ImageButton;
2673 2682
2674our @ISA = DC::UI::Image::; 2683our @ISA = DC::UI::Image::;
2675 2684
2676use DC::OpenGL; 2685use DC::OpenGL;
2677
2678my %textures;
2679 2686
2680sub new { 2687sub new {
2681 my $class = shift; 2688 my $class = shift;
2682 2689
2683 my $self = $class->SUPER::new ( 2690 my $self = $class->SUPER::new (
3047 3054
3048############################################################################# 3055#############################################################################
3049 3056
3050package DC::UI::Slider; 3057package DC::UI::Slider;
3051 3058
3052use strict; 3059use common::sense;
3053 3060
3054use DC::OpenGL; 3061use DC::OpenGL;
3055 3062
3056our @ISA = DC::UI::DrawBG::; 3063our @ISA = DC::UI::DrawBG::;
3057 3064
3143 if ($GRAB == $self) { 3150 if ($GRAB == $self) {
3144 my ($x, $w) = $self->{vertical} ? ($y, $self->{h}) : ($x, $self->{w}); 3151 my ($x, $w) = $self->{vertical} ? ($y, $self->{h}) : ($x, $self->{w});
3145 3152
3146 my (undef, $lo, $hi, $page) = @{$self->{range}}; 3153 my (undef, $lo, $hi, $page) = @{$self->{range}};
3147 3154
3148 $x = ($x - $self->{click}[1]) / ($w * $self->{scale}); 3155 $x = ($x - $self->{click}[1]) / ($w * $self->{scale} || 1e999);
3149 3156
3150 $self->set_value ($self->{click}[0] + $x * ($hi - $page - $lo)); 3157 $self->set_value ($self->{click}[0] + $x * ($hi - $page - $lo));
3151 } else { 3158 } else {
3152 return 0; 3159 return 0;
3153 } 3160 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines