… | |
… | |
666 | } |
666 | } |
667 | |
667 | |
668 | sub _draw { |
668 | sub _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 | |
2597 | package DC::UI::Image; |
2597 | package DC::UI::Image; |
2598 | |
2598 | |
2599 | our @ISA = DC::UI::Base::; |
2599 | our @ISA = DC::UI::DrawBG::; |
2600 | |
2600 | |
2601 | use DC::OpenGL; |
2601 | use DC::OpenGL; |
2602 | |
2602 | |
2603 | our %texture_cache; |
2603 | our %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 | |
|
|
2642 | sub set_texture { |
|
|
2643 | my ($self, $tex) = @_; |
|
|
2644 | |
|
|
2645 | $self->{tex} = $tex; |
|
|
2646 | $self->update; |
|
|
2647 | } |
|
|
2648 | |
2642 | sub size_request { |
2649 | sub 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 | |
2648 | sub _draw { |
2655 | sub _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 | |
… | |
… | |
2672 | package DC::UI::ImageButton; |
2681 | package DC::UI::ImageButton; |
2673 | |
2682 | |
2674 | our @ISA = DC::UI::Image::; |
2683 | our @ISA = DC::UI::Image::; |
2675 | |
2684 | |
2676 | use DC::OpenGL; |
2685 | use DC::OpenGL; |
2677 | |
|
|
2678 | my %textures; |
|
|
2679 | |
2686 | |
2680 | sub new { |
2687 | sub new { |
2681 | my $class = shift; |
2688 | my $class = shift; |
2682 | |
2689 | |
2683 | my $self = $class->SUPER::new ( |
2690 | my $self = $class->SUPER::new ( |