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.302 by root, Mon Jun 12 13:26:14 2006 UTC vs.
Revision 1.303 by elmex, Tue Jun 13 10:28:38 2006 UTC

1090 valign => 1, 1090 valign => 1,
1091 text => $self->{title}, 1091 text => $self->{title},
1092 fontsize => $self->{border}, 1092 fontsize => $self->{border},
1093 if exists $self->{title}; 1093 if exists $self->{title};
1094 1094
1095 unless ($self->{no_close_button}) {
1096 $self->{close_btn} =
1097 new CFClient::UI::ImageButton
1098 image => 'x1_close.png',
1099 on_activate => sub { $self->hide };
1100
1101 $self->CFClient::UI::Container::add ($self->{close_btn});
1102 }
1103
1095 $self 1104 $self
1096} 1105}
1097 1106
1098sub add { 1107sub add {
1099 my ($self, @widgets) = @_; 1108 my ($self, @widgets) = @_;
1100 1109
1101 $self->SUPER::add (@widgets); 1110 $self->SUPER::add (@widgets);
1111 $self->CFClient::UI::Container::add ($self->{close_btn}) if $self->{close_btn};
1102 $self->CFClient::UI::Container::add ($self->{title_widget}) if $self->{title_widget}; 1112 $self->CFClient::UI::Container::add ($self->{title_widget}) if $self->{title_widget};
1103} 1113}
1104 1114
1105sub border { 1115sub border {
1106 int $_[0]{border} * $::FONTSIZE 1116 int $_[0]{border} * $::FONTSIZE
1109sub size_request { 1119sub size_request {
1110 my ($self) = @_; 1120 my ($self) = @_;
1111 1121
1112 $self->{title_widget}->size_request 1122 $self->{title_widget}->size_request
1113 if $self->{title_widget}; 1123 if $self->{title_widget};
1124
1125 $self->{close_btn}->size_request
1126 if $self->{close_btn};
1114 1127
1115 my ($w, $h) = $self->SUPER::size_request; 1128 my ($w, $h) = $self->SUPER::size_request;
1116 1129
1117 ( 1130 (
1118 $w + $self->border * 2, 1131 $w + $self->border * 2,
1131 1144
1132 my $border = $self->border; 1145 my $border = $self->border;
1133 1146
1134 $h -= List::Util::max 0, $border * 2; 1147 $h -= List::Util::max 0, $border * 2;
1135 $w -= List::Util::max 0, $border * 2; 1148 $w -= List::Util::max 0, $border * 2;
1136 1149
1137 $self->child->configure ($border, $border, $w, $h); 1150 $self->child->configure ($border, $border, $w, $h);
1151
1152 $self->{close_btn}->configure ($self->{w} - (2 * $border), 0, $border, $border)
1153 if $self->{close_btn};
1138} 1154}
1139 1155
1140sub button_down { 1156sub button_down {
1141 my ($self, $ev, $x, $y) = @_; 1157 my ($self, $ev, $x, $y) = @_;
1142 1158
1188} 1204}
1189 1205
1190sub button_up { 1206sub button_up {
1191 my ($self, $ev, $x, $y) = @_; 1207 my ($self, $ev, $x, $y) = @_;
1192 1208
1209 $self->{close_btn}->button_up ($ev, $x, $y)
1210 if $self->{close_btn};
1211
1193 !!delete $self->{motion} 1212 !!delete $self->{motion}
1194} 1213}
1195 1214
1196sub mouse_motion { 1215sub mouse_motion {
1197 my ($self, $ev, $x, $y) = @_; 1216 my ($self, $ev, $x, $y) = @_;
1235 $child->draw; 1254 $child->draw;
1236 1255
1237 if ($self->{title_widget}) { 1256 if ($self->{title_widget}) {
1238 glTranslate 0, $border - $self->{h}; 1257 glTranslate 0, $border - $self->{h};
1239 $self->{title_widget}->_draw; 1258 $self->{title_widget}->_draw;
1259
1260 glTranslate 0, - ($border - $self->{h});
1240 } 1261 }
1262
1263 $self->{close_btn}->draw
1264 if $self->{close_btn};
1241} 1265}
1242 1266
1243############################################################################# 1267#############################################################################
1244 1268
1245package CFClient::UI::Table; 1269package CFClient::UI::Table;
1956 $tex[0]->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); 1980 $tex[0]->draw_quad_alpha (0, 0, $self->{w}, $self->{h});
1957 1981
1958 glDisable GL_TEXTURE_2D; 1982 glDisable GL_TEXTURE_2D;
1959 1983
1960 $self->SUPER::_draw; 1984 $self->SUPER::_draw;
1985}
1986
1987#############################################################################
1988
1989package CFClient::UI::ImageButton;
1990
1991our @ISA = CFClient::UI::Image::;
1992
1993use CFClient::OpenGL;
1994
1995my %textures;
1996
1997sub new {
1998 my $class = shift;
1999
2000 my $self = $class->SUPER::new (
2001 padding_x => 4,
2002 padding_y => 4,
2003 fg => [1, 1, 1],
2004 active_fg => [0, 0, 1],
2005 can_hover => 1,
2006 align => 0,
2007 valign => 0,
2008 can_events => 1,
2009 @_
2010 );
2011}
2012
2013sub activate { }
2014
2015sub button_up {
2016 my ($self, $ev, $x, $y) = @_;
2017
2018 $self->emit ("activate")
2019 if $x >= 0 && $x < $self->{w}
2020 && $y >= 0 && $y < $self->{h};
2021
2022 1
1961} 2023}
1962 2024
1963############################################################################# 2025#############################################################################
1964 2026
1965package CFClient::UI::CheckBox; 2027package CFClient::UI::CheckBox;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines