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.169 by elmex, Mon Apr 24 10:43:39 2006 UTC vs.
Revision 1.173 by root, Tue Apr 25 10:30:48 2006 UTC

236 236
237sub size_allocate { 237sub size_allocate {
238 # nothing to be done 238 # nothing to be done
239} 239}
240 240
241sub children {
242}
243
244# call when resoltuion changes etc.
245sub reconfigure {
246 my ($self) = @_;
247
248 $_->reconfigure
249 for $self->children;
250
251 $_->check_size;
252}
253
241sub set_max_size { 254sub set_max_size {
242 my ($self, $w, $h) = @_; 255 my ($self, $w, $h) = @_;
243 256
244 delete $self->{max_w}; $self->{max_w} = $w if $w; 257 delete $self->{max_w}; $self->{max_w} = $w if $w;
245 delete $self->{max_h}; $self->{max_h} = $h if $h; 258 delete $self->{max_h}; $self->{max_h} = $h if $h;
246} 259}
247 260
248# return top left coordinates 261# return top left coordinates
249sub _topleft { 262sub _topleft {
250 my ($self, $x, $y) = @_; 263 my ($self, $x, $y) = @_;
264
265 $self->{parent}
266 or Carp::confess "no parent widget in _topleft\n";#d#
251 267
252 $self->{parent}->_topleft ($x + $self->{x}, $y + $self->{y}); 268 $self->{parent}->_topleft ($x + $self->{x}, $y + $self->{y});
253} 269}
254 270
255# translate global coordinates to local coordinate system 271# translate global coordinates to local coordinate system
517 ]; 533 ];
518 534
519 $child->check_size; 535 $child->check_size;
520} 536}
521 537
538sub children {
539 @{ $_[0]{children} }
540}
541
522sub remove { 542sub remove {
523 my ($self, $child) = @_; 543 my ($self, $child) = @_;
524 544
525 delete $child->{parent}; 545 delete $child->{parent};
526 $child->hide; 546 $child->hide;
912 $self->{children}[$y][$x] = $child; 932 $self->{children}[$y][$x] = $child;
913 933
914 $child->check_size; 934 $child->check_size;
915} 935}
916 936
937sub children {
938 grep $_, map @$_, grep $_, @{ $_[0]{children} }
939}
940
917# TODO: move to container class maybe? send childs a signal on removal? 941# TODO: move to container class maybe? send childs a signal on removal?
918sub clear { 942sub clear {
919 my ($self) = @_; 943 my ($self) = @_;
920 944
921 my $children = delete $self->{children}; 945 my @children = $self->children;
946 delete $self->{children};
922 947
923 for (grep $_, map @$_, grep $_, @$children) { 948 for (@children) {
924 delete $_->{parent}; 949 delete $_->{parent};
925 $_->hide; 950 $_->hide;
926 } 951 }
927 952
928 $self->update; 953 $self->update;
1189 s/</&lt;/g; 1214 s/</&lt;/g;
1190 1215
1191 $_[1] 1216 $_[1]
1192} 1217}
1193 1218
1219sub update {
1220 my ($self) = @_;
1221
1222 delete $self->{texture};
1223 $self->SUPER::update;
1224}
1225
1226sub reconfigure {
1227 my ($self) = @_;
1228
1229 delete $self->{texture};
1230}
1231
1194sub set_text { 1232sub set_text {
1195 my ($self, $text) = @_; 1233 my ($self, $text) = @_;
1196 1234
1235 return if $self->{text} eq "T$text";
1236 $self->{text} = "T$text";
1237
1197 $self->{layout}->set_text ($text); 1238 $self->{layout}->set_text ($text);
1198 1239
1199 delete $self->{texture}; 1240 delete $self->{texture};
1241 $self->update;
1200 $self->check_size; 1242 $self->check_size;
1201 $self->update;
1202} 1243}
1203 1244
1204sub set_markup { 1245sub set_markup {
1205 my ($self, $markup) = @_; 1246 my ($self, $markup) = @_;
1206 1247
1248 return if $self->{text} eq "M$markup";
1249 $self->{text} = "M$markup";
1250
1207 $self->{layout}->set_markup ($markup); 1251 $self->{layout}->set_markup ($markup);
1208 1252
1209 delete $self->{texture}; 1253 delete $self->{texture};
1254 $self->update;
1210 $self->check_size; 1255 $self->check_size;
1211 $self->update;
1212} 1256}
1213 1257
1214sub size_request { 1258sub size_request {
1215 my ($self) = @_; 1259 my ($self) = @_;
1216 1260
1740} 1784}
1741 1785
1742sub set_max { 1786sub set_max {
1743 my ($self, $max) = @_; 1787 my ($self, $max) = @_;
1744 1788
1789 return if $self->{max_val} == $max;
1790
1745 $self->{max_val} = $max; 1791 $self->{max_val} = $max;
1792 $self->update;
1746} 1793}
1747 1794
1748sub set_value { 1795sub set_value {
1749 my ($self, $val, $max) = @_; 1796 my ($self, $val, $max) = @_;
1750 1797
1751 $self->set_max ($max) 1798 $self->set_max ($max)
1752 if defined $max; 1799 if defined $max;
1753 1800
1754 $max = $self->{max_val}; 1801 return if $self->{val} == $val;
1802
1755 $self->{val} = $val; 1803 $self->{val} = $val;
1756
1757 $self->update; 1804 $self->update;
1758} 1805}
1759 1806
1760sub _draw { 1807sub _draw {
1761 my ($self) = @_; 1808 my ($self) = @_;
1824 1871
1825sub new { 1872sub new {
1826 my ($class, %arg) = @_; 1873 my ($class, %arg) = @_;
1827 1874
1828 my $self = $class->SUPER::new ( 1875 my $self = $class->SUPER::new (
1829 tooltip => $arg{type}, 1876 tooltip => $arg{type},
1830 can_hover => 1, 1877 can_hover => 1,
1878 can_events => 1,
1831 %arg, 1879 %arg,
1832 ); 1880 );
1833 1881
1834 $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999"); 1882 $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999");
1835 $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1); 1883 $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1);
1843 1891
1844 $self->{value}->set_fontsize ($fsize); 1892 $self->{value}->set_fontsize ($fsize);
1845 $self->{max} ->set_fontsize ($fsize); 1893 $self->{max} ->set_fontsize ($fsize);
1846} 1894}
1847 1895
1896sub set_max {
1897 my ($self, $max) = @_;
1898
1899 $self->{gauge}->set_max ($max);
1900 $self->{max}->set_text ($max);
1901}
1902
1848sub set_value { 1903sub set_value {
1849 my ($self, $val, $max) = @_; 1904 my ($self, $val, $max) = @_;
1850 1905
1851 $self->set_max ($max) 1906 $self->set_max ($max)
1852 if defined $max; 1907 if defined $max;
1853 1908
1854 $self->{gauge}->set_value ($val, $max); 1909 $self->{gauge}->set_value ($val, $max);
1855 $self->{value}->set_text ($val); 1910 $self->{value}->set_text ($val);
1856}
1857
1858sub set_max {
1859 my ($self, $max) = @_;
1860
1861 $self->{gauge}->set_max ($max);
1862 $self->{max}->set_text ($max);
1863} 1911}
1864 1912
1865############################################################################# 1913#############################################################################
1866 1914
1867package CFClient::UI::Slider; 1915package CFClient::UI::Slider;
2150 my ($self) = @_; 2198 my ($self) = @_;
2151 2199
2152 if ($self->{texture}) { 2200 if ($self->{texture}) {
2153 glEnable GL_TEXTURE_2D; 2201 glEnable GL_TEXTURE_2D;
2154 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 2202 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2203 glColor 1, 1, 1, 1;
2155 $self->{texture}->draw_quad (0, 0, $self->{w}, $self->{h}); 2204 $self->{texture}->draw_quad (0, 0, $self->{w}, $self->{h});
2156 glDisable GL_TEXTURE_2D; 2205 glDisable GL_TEXTURE_2D;
2157 } 2206 }
2158 2207
2159 $self->{children}[1]->draw; 2208 $self->{children}[1]->draw;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines