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.113 by root, Sat Apr 15 12:46:48 2006 UTC vs.
Revision 1.116 by root, Sat Apr 15 21:16:50 2006 UTC

74sub harmonize { 74sub harmonize {
75 my ($vals) = @_; 75 my ($vals) = @_;
76 76
77 my $rem = 0; 77 my $rem = 0;
78 78
79 for ($vals) { 79 for (@$vals) {
80 my $i = int $_ + $rem; 80 my $i = int $_ + $rem;
81 $rem += $_ - $i; 81 $rem += $_ - $i;
82 $_ = $i; 82 $_ = $i;
83 } 83 }
84} 84}
707 707
708 $self->{w} = $self->{h} = -1; 708 $self->{w} = $self->{h} = -1;
709 $self->update; 709 $self->update;
710} 710}
711 711
712# TODO: move to container class maybe? send childs a signal on removal?
713sub clear {
714 my ($self) = @_;
715
716 delete $self->{children};
717 $self->update;
718}
719
712sub get_wh { 720sub get_wh {
713 my ($self) = @_; 721 my ($self) = @_;
714 722
715 my (@w, @h); 723 my (@w, @h);
716 724
942 my $self = $class->SUPER::new ( 950 my $self = $class->SUPER::new (
943 fg => [1, 1, 1], 951 fg => [1, 1, 1],
944 fontsize => $::FONTSIZE, 952 fontsize => $::FONTSIZE,
945 text => "", 953 text => "",
946 align => -1, 954 align => -1,
955 valign => -1,
947 padding => 2, 956 padding => 2,
948 layout => new CFClient::Layout, 957 layout => new CFClient::Layout,
949 %arg 958 %arg
950 ); 959 );
951 960
1028 my $x = 1037 my $x =
1029 $self->{align} < 0 ? $self->{padding} 1038 $self->{align} < 0 ? $self->{padding}
1030 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} 1039 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding}
1031 : ($self->{w} - $tex->{w}) * 0.5; 1040 : ($self->{w} - $tex->{w}) * 0.5;
1032 1041
1033 $tex->draw_quad (int $x, int +($self->{h} - $tex->{h}) * 0.5); 1042 my $y =
1043 $self->{valign} < 0 ? $self->{padding}
1044 : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding}
1045 : ($self->{h} - $tex->{h}) * 0.5;
1046
1047 $tex->draw_quad (int $x, int $y);
1034 1048
1035 glDisable GL_TEXTURE_2D; 1049 glDisable GL_TEXTURE_2D;
1036 glDisable GL_BLEND; 1050 glDisable GL_BLEND;
1037} 1051}
1038 1052
1053 bg => [0, 0, 0, 0.2], 1067 bg => [0, 0, 0, 0.2],
1054 active_bg => [1, 1, 1, 0.5], 1068 active_bg => [1, 1, 1, 0.5],
1055 active_fg => [0, 0, 0], 1069 active_fg => [0, 0, 0],
1056 can_hover => 1, 1070 can_hover => 1,
1057 can_focus => 1, 1071 can_focus => 1,
1072 valign => 0,
1058 @_ 1073 @_
1059 ) 1074 )
1060} 1075}
1061 1076
1062sub _set_text { 1077sub _set_text {
1960 1975
1961 # TODO: use animation 1976 # TODO: use animation
1962 if ($self->{state} = !$self->{state}) { 1977 if ($self->{state} = !$self->{state}) {
1963 $CFClient::UI::ROOT->add ($self->{other}); 1978 $CFClient::UI::ROOT->add ($self->{other});
1964 $self->{other}->move ($self->coord2global (0, $self->{h})); 1979 $self->{other}->move ($self->coord2global (0, $self->{h}));
1980 $self->emit ("open");
1965 } else { 1981 } else {
1966 $CFClient::UI::ROOT->remove ($self->{other}); 1982 $CFClient::UI::ROOT->remove ($self->{other});
1983 $self->emit ("close");
1967 } 1984 }
1985
1986 $self->emit (changed => $self->{state});
1968} 1987}
1969 1988
1970############################################################################# 1989#############################################################################
1971 1990
1972package CFClient::UI::Root; 1991package CFClient::UI::Root;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines