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.268 by root, Thu Jun 1 05:04:41 2006 UTC vs.
Revision 1.269 by root, Fri Jun 2 06:22:55 2006 UTC

1050my @border = 1050my @border =
1051 map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } 1051 map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 }
1052 qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); 1052 qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png);
1053 1053
1054sub new { 1054sub new {
1055 my $class = shift; 1055 my ($class, %arg) = @_;
1056
1057 my $title = delete $arg{title};
1056 1058
1057 my $self = $class->SUPER::new ( 1059 my $self = $class->SUPER::new (
1058 bg => [1, 1, 1, 1], 1060 bg => [1, 1, 1, 1],
1059 border_bg => [1, 1, 1, 1], 1061 border_bg => [1, 1, 1, 1],
1060 border => 0.6, 1062 border => 0.6,
1061 can_events => 1, 1063 can_events => 1,
1062 min_w => 16, 1064 min_w => 16,
1063 min_h => 16, 1065 min_h => 16,
1064 @_ 1066 %arg,
1065 ); 1067 );
1066 1068
1067 $self->{title} &&= new CFClient::UI::Label 1069 $self->{title} = new CFClient::UI::Label
1068 align => 0, 1070 align => 0,
1069 valign => 1, 1071 valign => 1,
1070 text => $self->{title}, 1072 text => $title,
1071 fontsize => $self->{border}; 1073 fontsize => $self->{border}
1074 if defined $title;
1072 1075
1073 $self 1076 $self
1077}
1078
1079sub add {
1080 my ($self, @widgets) = @_;
1081
1082 $self->SUPER::add (@widgets);
1083 $self->CFClient::UI::Container::add ($self->{title}) if $self->{title};
1074} 1084}
1075 1085
1076sub border { 1086sub border {
1077 int $_[0]{border} * $::FONTSIZE 1087 int $_[0]{border} * $::FONTSIZE
1078} 1088}
1079 1089
1080sub size_request { 1090sub size_request {
1081 my ($self) = @_; 1091 my ($self) = @_;
1092
1093 $self->{title}->size_request
1094 if $self->{title};
1082 1095
1083 my ($w, $h) = $self->SUPER::size_request; 1096 my ($w, $h) = $self->SUPER::size_request;
1084 1097
1085 ( 1098 (
1086 $w + $self->border * 2, 1099 $w + $self->border * 2,
1089} 1102}
1090 1103
1091sub size_allocate { 1104sub size_allocate {
1092 my ($self, $w, $h) = @_; 1105 my ($self, $w, $h) = @_;
1093 1106
1107 if ($self->{title}) {
1108 $self->{title}{w} = $w;
1109 $self->{title}{h} = $h;
1110 $self->{title}->size_allocate ($w, $h);
1111 }
1112
1113 my $border = $self->border;
1114
1094 $h -= List::Util::max 0, $self->border * 2; 1115 $h -= List::Util::max 0, $border * 2;
1095 $w -= List::Util::max 0, $self->border * 2; 1116 $w -= List::Util::max 0, $border * 2;
1096 1117
1097 $self->{title}->configure ($self->border, int $self->border - $::FONTSIZE * 2, $w, int $::FONTSIZE * 2)
1098 if $self->{title};
1099
1100 $self->child->configure ($self->border, $self->border, $w, $h); 1118 $self->child->configure ($border, $border, $w, $h);
1101} 1119}
1102 1120
1103sub button_down { 1121sub button_down {
1104 my ($self, $ev, $x, $y) = @_; 1122 my ($self, $ev, $x, $y) = @_;
1105 1123
1157} 1175}
1158 1176
1159sub _draw { 1177sub _draw {
1160 my ($self) = @_; 1178 my ($self) = @_;
1161 1179
1180 my $child = $self->{children}[0];
1181
1162 my ($w, $h ) = ($self->{w}, $self->{h}); 1182 my ($w, $h ) = ($self->{w}, $self->{h});
1163 my ($cw, $ch) = ($self->child->{w}, $self->child->{h}); 1183 my ($cw, $ch) = ($child->{w}, $child->{h});
1164 1184
1165 glEnable GL_TEXTURE_2D; 1185 glEnable GL_TEXTURE_2D;
1166 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 1186 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
1167 1187
1168 my $border = $self->border; 1188 my $border = $self->border;
1183 $bg->draw_quad_alpha ($border, $border, $cw, $ch); 1203 $bg->draw_quad_alpha ($border, $border, $cw, $ch);
1184 } 1204 }
1185 1205
1186 glDisable GL_TEXTURE_2D; 1206 glDisable GL_TEXTURE_2D;
1187 1207
1188 $self->{title}->draw if $self->{title};
1189
1190 $self->child->draw; 1208 $child->draw;
1209
1210 if ($self->{title}) {
1211 glTranslate 0, $border - $self->{h};
1212 $self->{title}->_draw;
1213 }
1191} 1214}
1192 1215
1193############################################################################# 1216#############################################################################
1194 1217
1195package CFClient::UI::Table; 1218package CFClient::UI::Table;
1543} 1566}
1544 1567
1545sub size_allocate { 1568sub size_allocate {
1546 my ($self, $w, $h) = @_; 1569 my ($self, $w, $h) = @_;
1547 1570
1571 delete $self->{ox};
1572
1548 delete $self->{texture} 1573 delete $self->{texture}
1549 unless $w >= $self->{req_w} && $self->{old_w} >= $self->{req_w}; 1574 unless $w >= $self->{req_w} && $self->{old_w} >= $self->{req_w};
1550} 1575}
1551 1576
1552sub set_fontsize { 1577sub set_fontsize {
1569 $self->{layout}->set_width ($self->{w}); 1594 $self->{layout}->set_width ($self->{w});
1570 $self->{layout}->set_ellipsise ($self->{ellipsise}); 1595 $self->{layout}->set_ellipsise ($self->{ellipsise});
1571 $self->{layout}->set_single_paragraph_mode ($self->{ellipsise}); 1596 $self->{layout}->set_single_paragraph_mode ($self->{ellipsise});
1572 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); 1597 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE);
1573 1598
1574 my $tex = new_from_layout CFClient::Texture $self->{layout}; 1599 new_from_layout CFClient::Texture $self->{layout}
1600 };
1575 1601
1602 unless (exists $self->{ox}) {
1576 $self->{ox} = int ($self->{align} < 0 ? $self->{padding_x} 1603 $self->{ox} = int ($self->{align} < 0 ? $self->{padding_x}
1577 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding_x} 1604 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding_x}
1578 : ($self->{w} - $tex->{w}) * 0.5); 1605 : ($self->{w} - $tex->{w}) * 0.5);
1579 1606
1580 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y} 1607 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y}
1581 : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding_y} 1608 : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding_y}
1582 : ($self->{h} - $tex->{h}) * 0.5); 1609 : ($self->{h} - $tex->{h}) * 0.5);
1583
1584 $tex
1585 }; 1610 };
1586 1611
1587 glEnable GL_TEXTURE_2D; 1612 glEnable GL_TEXTURE_2D;
1588 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 1613 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1589 1614

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines