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.170 by root, Mon Apr 24 11:45:17 2006 UTC vs.
Revision 1.173 by root, Tue Apr 25 10:30:48 2006 UTC

234 } 234 }
235} 235}
236 236
237sub size_allocate { 237sub size_allocate {
238 # nothing to be done 238 # nothing to be done
239}
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;
239} 252}
240 253
241sub set_max_size { 254sub set_max_size {
242 my ($self, $w, $h) = @_; 255 my ($self, $w, $h) = @_;
243 256
520 ]; 533 ];
521 534
522 $child->check_size; 535 $child->check_size;
523} 536}
524 537
538sub children {
539 @{ $_[0]{children} }
540}
541
525sub remove { 542sub remove {
526 my ($self, $child) = @_; 543 my ($self, $child) = @_;
527 544
528 delete $child->{parent}; 545 delete $child->{parent};
529 $child->hide; 546 $child->hide;
915 $self->{children}[$y][$x] = $child; 932 $self->{children}[$y][$x] = $child;
916 933
917 $child->check_size; 934 $child->check_size;
918} 935}
919 936
937sub children {
938 grep $_, map @$_, grep $_, @{ $_[0]{children} }
939}
940
920# 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?
921sub clear { 942sub clear {
922 my ($self) = @_; 943 my ($self) = @_;
923 944
924 my $children = delete $self->{children}; 945 my @children = $self->children;
946 delete $self->{children};
925 947
926 for (grep $_, map @$_, grep $_, @$children) { 948 for (@children) {
927 delete $_->{parent}; 949 delete $_->{parent};
928 $_->hide; 950 $_->hide;
929 } 951 }
930 952
931 $self->update; 953 $self->update;
1192 s/</&lt;/g; 1214 s/</&lt;/g;
1193 1215
1194 $_[1] 1216 $_[1]
1195} 1217}
1196 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
1197sub set_text { 1232sub set_text {
1198 my ($self, $text) = @_; 1233 my ($self, $text) = @_;
1199 1234
1235 return if $self->{text} eq "T$text";
1236 $self->{text} = "T$text";
1237
1200 $self->{layout}->set_text ($text); 1238 $self->{layout}->set_text ($text);
1201 1239
1202 delete $self->{texture}; 1240 delete $self->{texture};
1241 $self->update;
1203 $self->check_size; 1242 $self->check_size;
1204 $self->update;
1205} 1243}
1206 1244
1207sub set_markup { 1245sub set_markup {
1208 my ($self, $markup) = @_; 1246 my ($self, $markup) = @_;
1209 1247
1248 return if $self->{text} eq "M$markup";
1249 $self->{text} = "M$markup";
1250
1210 $self->{layout}->set_markup ($markup); 1251 $self->{layout}->set_markup ($markup);
1211 1252
1212 delete $self->{texture}; 1253 delete $self->{texture};
1254 $self->update;
1213 $self->check_size; 1255 $self->check_size;
1214 $self->update;
1215} 1256}
1216 1257
1217sub size_request { 1258sub size_request {
1218 my ($self) = @_; 1259 my ($self) = @_;
1219 1260
1743} 1784}
1744 1785
1745sub set_max { 1786sub set_max {
1746 my ($self, $max) = @_; 1787 my ($self, $max) = @_;
1747 1788
1789 return if $self->{max_val} == $max;
1790
1748 $self->{max_val} = $max; 1791 $self->{max_val} = $max;
1792 $self->update;
1749} 1793}
1750 1794
1751sub set_value { 1795sub set_value {
1752 my ($self, $val, $max) = @_; 1796 my ($self, $val, $max) = @_;
1753 1797
1754 $self->set_max ($max) 1798 $self->set_max ($max)
1755 if defined $max; 1799 if defined $max;
1756 1800
1757 $max = $self->{max_val}; 1801 return if $self->{val} == $val;
1802
1758 $self->{val} = $val; 1803 $self->{val} = $val;
1759
1760 $self->update; 1804 $self->update;
1761} 1805}
1762 1806
1763sub _draw { 1807sub _draw {
1764 my ($self) = @_; 1808 my ($self) = @_;
1827 1871
1828sub new { 1872sub new {
1829 my ($class, %arg) = @_; 1873 my ($class, %arg) = @_;
1830 1874
1831 my $self = $class->SUPER::new ( 1875 my $self = $class->SUPER::new (
1832 tooltip => $arg{type}, 1876 tooltip => $arg{type},
1833 can_hover => 1, 1877 can_hover => 1,
1878 can_events => 1,
1834 %arg, 1879 %arg,
1835 ); 1880 );
1836 1881
1837 $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");
1838 $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);
1846 1891
1847 $self->{value}->set_fontsize ($fsize); 1892 $self->{value}->set_fontsize ($fsize);
1848 $self->{max} ->set_fontsize ($fsize); 1893 $self->{max} ->set_fontsize ($fsize);
1849} 1894}
1850 1895
1896sub set_max {
1897 my ($self, $max) = @_;
1898
1899 $self->{gauge}->set_max ($max);
1900 $self->{max}->set_text ($max);
1901}
1902
1851sub set_value { 1903sub set_value {
1852 my ($self, $val, $max) = @_; 1904 my ($self, $val, $max) = @_;
1853 1905
1854 $self->set_max ($max) 1906 $self->set_max ($max)
1855 if defined $max; 1907 if defined $max;
1856 1908
1857 $self->{gauge}->set_value ($val, $max); 1909 $self->{gauge}->set_value ($val, $max);
1858 $self->{value}->set_text ($val); 1910 $self->{value}->set_text ($val);
1859}
1860
1861sub set_max {
1862 my ($self, $max) = @_;
1863
1864 $self->{gauge}->set_max ($max);
1865 $self->{max}->set_text ($max);
1866} 1911}
1867 1912
1868############################################################################# 1913#############################################################################
1869 1914
1870package CFClient::UI::Slider; 1915package CFClient::UI::Slider;
2153 my ($self) = @_; 2198 my ($self) = @_;
2154 2199
2155 if ($self->{texture}) { 2200 if ($self->{texture}) {
2156 glEnable GL_TEXTURE_2D; 2201 glEnable GL_TEXTURE_2D;
2157 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;
2158 $self->{texture}->draw_quad (0, 0, $self->{w}, $self->{h}); 2204 $self->{texture}->draw_quad (0, 0, $self->{w}, $self->{h});
2159 glDisable GL_TEXTURE_2D; 2205 glDisable GL_TEXTURE_2D;
2160 } 2206 }
2161 2207
2162 $self->{children}[1]->draw; 2208 $self->{children}[1]->draw;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines