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.172 by root, Tue Apr 25 09:52:04 2006 UTC vs.
Revision 1.174 by root, Tue Apr 25 11:18:49 2006 UTC

24 my $tip = $widget->{tooltip}; 24 my $tip = $widget->{tooltip};
25 25
26 $tip = $tip->($widget) if CODE:: eq ref $tip; 26 $tip = $tip->($widget) if CODE:: eq ref $tip;
27 27
28 $TOOLTIP->set_markup ($widget->{tooltip}); 28 $TOOLTIP->set_markup ($widget->{tooltip});
29 $TOOLTIP->move ($widget->coord2global ($widget->{w}, 0)); 29
30 $TOOLTIP->show; 30 $TOOLTIP->show;
31
32 my ($x, $y) = $widget->coord2global ($widget->{w}, 0);
33
34 if ($x + $TOOLTIP->{w} > $::WIDTH) {
35 ($x, $y) = $widget->coord2global (-$TOOLTIP->{w}, 0);
36 }
37
38 $TOOLTIP->move ($x, $y);
31 } 39 }
32 40
33 return; 41 return;
34 } 42 }
35 } 43 }
237sub size_allocate { 245sub size_allocate {
238 # nothing to be done 246 # nothing to be done
239} 247}
240 248
241sub children { 249sub children {
250}
251
252# call when resoltuion changes etc.
253sub reconfigure {
254 my ($self) = @_;
255
256 $_->reconfigure
257 for $self->children;
258
259 $_->check_size;
242} 260}
243 261
244sub set_max_size { 262sub set_max_size {
245 my ($self, $w, $h) = @_; 263 my ($self, $w, $h) = @_;
246 264
633} 651}
634 652
635sub update { 653sub update {
636 my ($self) = @_; 654 my ($self) = @_;
637 655
638 # we want to do this delayed... 656 $ROOT->on_refresh ($self => sub { $self->render_child });
639 $self->render_chld;
640 $self->SUPER::update; 657 $self->SUPER::update;
641} 658}
642 659
660sub size_allocate {
661 my ($self, $w, $h) = @_;
662
663 $self->SUPER::size_allocate ($w, $h);
664 $self->update;
665}
666
643sub render_chld { 667sub render_child {
644 my ($self) = @_; 668 my ($self) = @_;
645 669
646 $self->{texture} = new_from_opengl CFClient::Texture $self->{w}, $self->{h}, sub { 670 $self->{texture} = new_from_opengl CFClient::Texture $self->{w}, $self->{h}, sub {
647 glClearColor 0, 0, 0, 1; 671 glClearColor 0, 0, 0, 0;
648 glClear GL_COLOR_BUFFER_BIT; 672 glClear GL_COLOR_BUFFER_BIT;
649 $self->child->draw; 673 $self->child->draw;
650 }; 674 };
651} 675}
652 676
653sub size_allocate {
654 my ($self, $w, $h) = @_;
655
656 $self->child->configure (0, 0, $w, $h);
657
658 $self->render_chld;
659}
660
661sub _draw { 677sub _draw {
662 my ($self) = @_; 678 my ($self) = @_;
663 679
664 my ($w, $h) = ($self->w, $self->h); 680 my ($w, $h) = ($self->w, $self->h);
665 681
666 my $tex = $self->{texture} 682 my $tex = $self->{texture}
667 or return; 683 or return;
668 684
669 glEnable GL_BLEND; 685 glEnable GL_BLEND;
670 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 686 glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA;
671 glEnable GL_TEXTURE_2D; 687 glEnable GL_TEXTURE_2D;
672 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 688 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
689 glColor 0, 0, 0, 1;
673 690
674 $tex->draw_quad (0, 0, $w, $h); 691 $tex->draw_quad (0, 0, $w, $h);
675 692
676 glDisable GL_BLEND; 693 glDisable GL_BLEND;
677 glDisable GL_TEXTURE_2D; 694 glDisable GL_TEXTURE_2D;
1204 s/</&lt;/g; 1221 s/</&lt;/g;
1205 1222
1206 $_[1] 1223 $_[1]
1207} 1224}
1208 1225
1226sub update {
1227 my ($self) = @_;
1228
1229 delete $self->{texture};
1230 $self->SUPER::update;
1231}
1232
1233sub reconfigure {
1234 my ($self) = @_;
1235
1236 delete $self->{texture};
1237}
1238
1209sub set_text { 1239sub set_text {
1210 my ($self, $text) = @_; 1240 my ($self, $text) = @_;
1211 1241
1242 return if $self->{text} eq "T$text";
1243 $self->{text} = "T$text";
1244
1212 $self->{layout}->set_text ($text); 1245 $self->{layout}->set_text ($text);
1213 1246
1214 delete $self->{texture}; 1247 delete $self->{texture};
1248 $self->update;
1215 $self->check_size; 1249 $self->check_size;
1216 $self->update;
1217} 1250}
1218 1251
1219sub set_markup { 1252sub set_markup {
1220 my ($self, $markup) = @_; 1253 my ($self, $markup) = @_;
1221 1254
1255 return if $self->{text} eq "M$markup";
1256 $self->{text} = "M$markup";
1257
1222 $self->{layout}->set_markup ($markup); 1258 $self->{layout}->set_markup ($markup);
1223 1259
1224 delete $self->{texture}; 1260 delete $self->{texture};
1261 $self->update;
1225 $self->check_size; 1262 $self->check_size;
1226 $self->update;
1227} 1263}
1228 1264
1229sub size_request { 1265sub size_request {
1230 my ($self) = @_; 1266 my ($self) = @_;
1231 1267
1755} 1791}
1756 1792
1757sub set_max { 1793sub set_max {
1758 my ($self, $max) = @_; 1794 my ($self, $max) = @_;
1759 1795
1796 return if $self->{max_val} == $max;
1797
1760 $self->{max_val} = $max; 1798 $self->{max_val} = $max;
1799 $self->update;
1761} 1800}
1762 1801
1763sub set_value { 1802sub set_value {
1764 my ($self, $val, $max) = @_; 1803 my ($self, $val, $max) = @_;
1765 1804
1766 $self->set_max ($max) 1805 $self->set_max ($max)
1767 if defined $max; 1806 if defined $max;
1768 1807
1769 $max = $self->{max_val}; 1808 return if $self->{val} == $val;
1809
1770 $self->{val} = $val; 1810 $self->{val} = $val;
1771
1772 $self->update; 1811 $self->update;
1773} 1812}
1774 1813
1775sub _draw { 1814sub _draw {
1776 my ($self) = @_; 1815 my ($self) = @_;
1859 1898
1860 $self->{value}->set_fontsize ($fsize); 1899 $self->{value}->set_fontsize ($fsize);
1861 $self->{max} ->set_fontsize ($fsize); 1900 $self->{max} ->set_fontsize ($fsize);
1862} 1901}
1863 1902
1903sub set_max {
1904 my ($self, $max) = @_;
1905
1906 $self->{gauge}->set_max ($max);
1907 $self->{max}->set_text ($max);
1908}
1909
1864sub set_value { 1910sub set_value {
1865 my ($self, $val, $max) = @_; 1911 my ($self, $val, $max) = @_;
1866 1912
1867 $self->set_max ($max) 1913 $self->set_max ($max)
1868 if defined $max; 1914 if defined $max;
1869 1915
1870 $self->{gauge}->set_value ($val, $max); 1916 $self->{gauge}->set_value ($val, $max);
1871 $self->{value}->set_text ($val); 1917 $self->{value}->set_text ($val);
1872}
1873
1874sub set_max {
1875 my ($self, $max) = @_;
1876
1877 $self->{gauge}->set_max ($max);
1878 $self->{max}->set_text ($max);
1879} 1918}
1880 1919
1881############################################################################# 1920#############################################################################
1882 1921
1883package CFClient::UI::Slider; 1922package CFClient::UI::Slider;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines