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.482 by root, Sat Aug 13 23:18:19 2011 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
7use AnyEvent ();
8use Guard (); 8use Guard ();
9 9
10use DC; 10use DC;
11use DC::Pod; 11use DC::Pod;
12use DC::Texture; 12use DC::Texture;
223 223
224############################################################################# 224#############################################################################
225 225
226package DC::UI::Base; 226package DC::UI::Base;
227 227
228use strict; 228use common::sense;
229 229
230use DC::OpenGL; 230use DC::OpenGL;
231 231
232sub new { 232sub new {
233 my $class = shift; 233 my $class = shift;
643 643
644package DC::UI::DrawBG; 644package DC::UI::DrawBG;
645 645
646our @ISA = DC::UI::Base::; 646our @ISA = DC::UI::Base::;
647 647
648use strict; 648use common::sense;
649
649use DC::OpenGL; 650use DC::OpenGL;
650 651
651sub new { 652sub new {
652 my $class = shift; 653 my $class = shift;
653 654
666} 667}
667 668
668sub _draw { 669sub _draw {
669 my ($self) = @_; 670 my ($self) = @_;
670 671
671 my $color = $FOCUS == $self && $self->{active_bg} 672 my $color = $FOCUS == $self
672 ? $self->{active_bg} 673 ? $self->{active_bg} || $self->{bg}
673 : $self->{bg}; 674 : $self->{bg};
674 675
675 if ($color && (@$color < 4 || $color->[3])) { 676 if ($color && (@$color < 4 || $color->[3])) {
676 my ($w, $h) = @$self{qw(w h)}; 677 my ($w, $h) = @$self{qw(w h)};
677 678
2594 2595
2595############################################################################# 2596#############################################################################
2596 2597
2597package DC::UI::Image; 2598package DC::UI::Image;
2598 2599
2599our @ISA = DC::UI::Base::; 2600our @ISA = DC::UI::DrawBG::;
2600 2601
2601use DC::OpenGL; 2602use DC::OpenGL;
2602 2603
2603our %texture_cache; 2604our %texture_cache;
2604 2605
2637 my ($self, $cloning, $path) = @_; 2638 my ($self, $cloning, $path) = @_;
2638 2639
2639 $self->new (path => $path) 2640 $self->new (path => $path)
2640} 2641}
2641 2642
2643sub set_texture {
2644 my ($self, $tex) = @_;
2645
2646 $self->{tex} = $tex;
2647 $self->update;
2648}
2649
2642sub size_request { 2650sub size_request {
2643 my ($self) = @_; 2651 my ($self) = @_;
2644 2652
2645 (int $self->{tex}{w} * $self->{scale}, int $self->{tex}{h} * $self->{scale}) 2653 (int $self->{tex}{w} * $self->{scale}, int $self->{tex}{h} * $self->{scale})
2646} 2654}
2647 2655
2648sub _draw { 2656sub _draw {
2649 my ($self) = @_; 2657 my ($self) = @_;
2658
2659 $self->SUPER::_draw;
2650 2660
2651 my $tex = $self->{tex}; 2661 my $tex = $self->{tex};
2652 2662
2653 my ($w, $h) = ($self->{w}, $self->{h}); 2663 my ($w, $h) = ($self->{w}, $self->{h});
2654 2664
2672package DC::UI::ImageButton; 2682package DC::UI::ImageButton;
2673 2683
2674our @ISA = DC::UI::Image::; 2684our @ISA = DC::UI::Image::;
2675 2685
2676use DC::OpenGL; 2686use DC::OpenGL;
2677
2678my %textures;
2679 2687
2680sub new { 2688sub new {
2681 my $class = shift; 2689 my $class = shift;
2682 2690
2683 my $self = $class->SUPER::new ( 2691 my $self = $class->SUPER::new (
3047 3055
3048############################################################################# 3056#############################################################################
3049 3057
3050package DC::UI::Slider; 3058package DC::UI::Slider;
3051 3059
3052use strict; 3060use common::sense;
3053 3061
3054use DC::OpenGL; 3062use DC::OpenGL;
3055 3063
3056our @ISA = DC::UI::DrawBG::; 3064our @ISA = DC::UI::DrawBG::;
3057 3065
3143 if ($GRAB == $self) { 3151 if ($GRAB == $self) {
3144 my ($x, $w) = $self->{vertical} ? ($y, $self->{h}) : ($x, $self->{w}); 3152 my ($x, $w) = $self->{vertical} ? ($y, $self->{h}) : ($x, $self->{w});
3145 3153
3146 my (undef, $lo, $hi, $page) = @{$self->{range}}; 3154 my (undef, $lo, $hi, $page) = @{$self->{range}};
3147 3155
3148 $x = ($x - $self->{click}[1]) / ($w * $self->{scale}); 3156 $x = ($x - $self->{click}[1]) / ($w * $self->{scale} || 1e999);
3149 3157
3150 $self->set_value ($self->{click}[0] + $x * ($hi - $page - $lo)); 3158 $self->set_value ($self->{click}[0] + $x * ($hi - $page - $lo));
3151 } else { 3159 } else {
3152 return 0; 3160 return 0;
3153 } 3161 }
4285 $self 4293 $self
4286} 4294}
4287 4295
4288sub reorder { 4296sub reorder {
4289 my ($self) = @_; 4297 my ($self) = @_;
4290 my $NOW = EV::time; 4298 my $NOW = AE::time;
4291 4299
4292 # freeze display when hovering over any label 4300 # freeze display when hovering over any label
4293 return if $DC::UI::TOOLTIP->{owner} 4301 return if $DC::UI::TOOLTIP->{owner}
4294 && grep $DC::UI::TOOLTIP->{owner} == $_->{label}, 4302 && grep $DC::UI::TOOLTIP->{owner} == $_->{label},
4295 values %{ $self->{item} }; 4303 values %{ $self->{item} };

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines