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.120 by elmex, Sun Apr 16 17:43:17 2006 UTC vs.
Revision 1.121 by root, Mon Apr 17 19:21:00 2006 UTC

962 padding => 2, 962 padding => 2,
963 layout => new CFClient::Layout, 963 layout => new CFClient::Layout,
964 %arg 964 %arg
965 ); 965 );
966 966
967 $self->set_text ($self->{text}); 967 $self->{xxx}++ if $self->{text} eq "Client Setup" && $self->{align};#d#
968
969 $self->set_text (delete $self->{text}) if exists $self->{text};
970 $self->set_markup (delete $self->{markup}) if exists $self->{markup};
968 971
969 $self 972 $self
970} 973}
971 974
972sub escape_text { 975sub escape_text {
980} 983}
981 984
982sub set_text { 985sub set_text {
983 my ($self, $text) = @_; 986 my ($self, $text) = @_;
984 987
985 $self->{text} = $text;
986 $self->{layout}->set_markup ($text); 988 $self->{layout}->set_text ($text);
987 989
988 delete $self->{texture}; 990 delete $self->{texture};
989# $self->{w} = $self->{h} = -1;
990 $self->update; 991 $self->update;
991} 992}
992 993
993sub get_text { 994sub set_markup {
994 my ($self, $text) = @_; 995 my ($self, $markup) = @_;
995 996
996 $self->{text} 997 $self->{layout}->set_markup ($markup);
998
999 delete $self->{texture};
1000 $self->update;
997} 1001}
998 1002
999sub size_request { 1003sub size_request {
1000 my ($self) = @_; 1004 my ($self) = @_;
1001 1005
1002 $self->{layout}->set_width; 1006 $self->{layout}->set_width;
1003 $self->{layout}->set_height ($self->{fontsize}); 1007 $self->{layout}->set_height ($self->{fontsize});
1008
1004 my ($w, $h) = $self->{layout}->size; 1009 my ($w, $h) = $self->{layout}->size;
1005 1010
1006 ( 1011 (
1007 $w + $self->{padding} * 2, 1012 $w + $self->{padding} * 2,
1008 $h + $self->{padding} * 2, 1013 $h + $self->{padding} * 2,
1027sub _draw { 1032sub _draw {
1028 my ($self) = @_; 1033 my ($self) = @_;
1029 1034
1030 my $tex = $self->{texture} ||= do { 1035 my $tex = $self->{texture} ||= do {
1031 $self->{layout}->set_width ($self->{w}); 1036 $self->{layout}->set_width ($self->{w});
1032 $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{fontsize}); 1037 $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize});
1033 new_from_layout CFClient::Texture $self->{layout} 1038 new_from_layout CFClient::Texture $self->{layout}
1034 }; 1039 };
1035 1040
1036 glEnable GL_BLEND; 1041 glEnable GL_BLEND;
1037 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 1042 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1056 glDisable GL_BLEND; 1061 glDisable GL_BLEND;
1057} 1062}
1058 1063
1059############################################################################# 1064#############################################################################
1060 1065
1061package CFClient::UI::Entry; 1066package CFClient::UI::EntryBase;
1062 1067
1063our @ISA = CFClient::UI::Label::; 1068our @ISA = CFClient::UI::Label::;
1064 1069
1065use SDL; 1070use SDL;
1066use SDL::OpenGL; 1071use SDL::OpenGL;
1081} 1086}
1082 1087
1083sub _set_text { 1088sub _set_text {
1084 my ($self, $text) = @_; 1089 my ($self, $text) = @_;
1085 1090
1086 my $old_text = $self->{text}; 1091 delete $self->{cur_h};
1092
1093 return if $self->{text} eq $text;
1087 1094
1088 $self->{last_activity} = $::NOW; 1095 $self->{last_activity} = $::NOW;
1089
1090 $self->{text} = $text; 1096 $self->{text} = $text;
1091 $self->{layout}->set_width ($self->{w});
1092 $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{fontsize});
1093 1097
1094 $text =~ s/./*/g if $self->{hidden}; 1098 $text =~ s/./*/g if $self->{hidden};
1099 $self->{layout}->set_text ("$text ");
1095 1100
1096 $self->{layout}->set_markup ($self->escape_text ($text) . " "); 1101 $self->emit (changed => $self->{text});
1102}
1097 1103
1098 $text = substr $text, 0, $self->{cursor}; 1104sub get_text {
1099 utf8::encode $text; 1105 $_[0]{text}
1100
1101 @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text);
1102
1103 $self->emit (changed => $self->{text}) # XXX: is this the right place to do this?
1104 if $old_text ne $self->{text};
1105} 1106}
1106 1107
1107sub size_request { 1108sub size_request {
1108 my ($self) = @_; 1109 my ($self) = @_;
1109 1110
1213 1214
1214 $self->SUPER::_draw; 1215 $self->SUPER::_draw;
1215 1216
1216 #TODO: force update every cursor change :( 1217 #TODO: force update every cursor change :(
1217 if ($FOCUS == $self && (($::NOW - $self->{last_activity}) & 1023) < 600) { 1218 if ($FOCUS == $self && (($::NOW - $self->{last_activity}) & 1023) < 600) {
1219
1220 unless (exists $self->{cur_h}) {
1221 my $text = substr $self->{text}, 0, $self->{cursor};
1222 utf8::encode $text;
1223
1224 @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text)
1225 }
1226
1218 glColor @{$self->{fg}}; 1227 glColor @{$self->{fg}};
1219 glBegin GL_LINES; 1228 glBegin GL_LINES;
1220 glVertex $self->{cur_x}, $self->{cur_y}; 1229 glVertex $self->{cur_x}, $self->{cur_y};
1221 glVertex $self->{cur_x}, $self->{cur_y} + $self->{cur_h}; 1230 glVertex $self->{cur_x}, $self->{cur_y} + $self->{cur_h};
1222 glEnd; 1231 glEnd;
1223 } 1232 }
1224} 1233}
1225 1234
1226package CFClient::UI::LineEntry; 1235package CFClient::UI::Entry;
1227 1236
1228our @ISA = CFClient::UI::Entry::; 1237our @ISA = CFClient::UI::EntryBase::;
1229 1238
1230use SDL; 1239use SDL;
1231use SDL::OpenGL; 1240use SDL::OpenGL;
1232 1241
1233sub key_down { 1242sub key_down {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines