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.124 by elmex, Mon Apr 17 20:29:37 2006 UTC vs.
Revision 1.125 by root, Mon Apr 17 20:52:15 2006 UTC

260 my ($self, $parent) = @_; 260 my ($self, $parent) = @_;
261 261
262 Scalar::Util::weaken ($self->{parent} = $parent); 262 Scalar::Util::weaken ($self->{parent} = $parent);
263} 263}
264 264
265sub check_size {
266 my ($self) = @_;
267
268 my ($w, $h) = $self->size_request;
269
270 if ($w != $self->{req_w} || $h != $self->{req_h}) {
271 $self->{req_w} = $w;
272 $self->{req_h} = $h;
273
274 $self->{parent}->check_size
275 if $self->{parent};
276 }
277}
278
265sub update { 279sub update {
266 my ($self) = @_; 280 my ($self) = @_;
267 281
268 $self->{parent}->update 282 $self->{parent}->update
269 if $self->{parent}; 283 if $self->{parent};
376sub remove { 390sub remove {
377 my ($self, $widget) = @_; 391 my ($self, $widget) = @_;
378 392
379 $self->{children} = [ grep $_ != $widget, @{ $self->{children} } ]; 393 $self->{children} = [ grep $_ != $widget, @{ $self->{children} } ];
380 394
381 $self->size_allocate (0, 0, $self->{w}, $self->{h}); 395 $self->check_size;
382} 396}
383 397
384sub find_widget { 398sub find_widget {
385 my ($self, $x, $y) = @_; 399 my ($self, $x, $y) = @_;
386 400
506 $tex->draw_quad (0, 0, $w, $h); 520 $tex->draw_quad (0, 0, $w, $h);
507 521
508 glDisable GL_BLEND; 522 glDisable GL_BLEND;
509 glDisable GL_TEXTURE_2D; 523 glDisable GL_TEXTURE_2D;
510} 524}
525
526#############################################################################
527
528package CFClient::UI::ViewPort;
529
530our @ISA = CFClient::UI::Window::;
531
532sub new { die }
533
534sub size_request {
535 my ($self) = @_;
536
537 @$self{qw(child_w child_h)} = $self->child->size_request;
538 $self->child->size_allocate (0, 0, @$self{qw(child_w child_h)});
539
540 @$self{qw(child_w child_h)}
541}
542
543sub size_allocate {
544 my ($self, $x, $y, $w, $h) = @_;
545
546 $self->_size_allocate ($x, $y, $w, $h) or return;
547}
548
549sub _draw {
550 my ($self) = @_;
551
552 $self->{children}[1]->draw;
553}
554
511 555
512############################################################################# 556#############################################################################
513 557
514package CFClient::UI::Frame; 558package CFClient::UI::Frame;
515 559
846} 890}
847 891
848sub size_allocate { 892sub size_allocate {
849 my ($self, $x, $y, $w, $h) = @_; 893 my ($self, $x, $y, $w, $h) = @_;
850 894
851 $self->_size_allocate ($x, $y, $w, $h); 895 $self->_size_allocate ($x, $y, $w, $h) or return;
852 896
853 ($h, $w) = ($w, $h); 897 ($h, $w) = ($w, $h);
854 898
855 my $children = $self->{children}; 899 my $children = $self->{children};
856 900
882 my $h = $h[$_]; 926 my $h = $h[$_];
883 $child->size_allocate ($y, 0, $h, $w); 927 $child->size_allocate ($y, 0, $h, $w);
884 928
885 $y += $h; 929 $y += $h;
886 } 930 }
931
932 1
887} 933}
888 934
889############################################################################# 935#############################################################################
890 936
891package CFClient::UI::VBox; 937package CFClient::UI::VBox;
906} 952}
907 953
908sub size_allocate { 954sub size_allocate {
909 my ($self, $x, $y, $w, $h) = @_; 955 my ($self, $x, $y, $w, $h) = @_;
910 956
911 $self->_size_allocate ($x, $y, $w, $h); 957 $self->_size_allocate ($x, $y, $w, $h) or return;
912 958
913 my $children = $self->{children}; 959 my $children = $self->{children};
914 960
915 my @h = map +($_->size_request)[1], @$children; 961 my @h = map +($_->size_request)[1], @$children;
916 962
938 my $h = $h[$_]; 984 my $h = $h[$_];
939 $child->size_allocate (0, $y, $w, $h); 985 $child->size_allocate (0, $y, $w, $h);
940 986
941 $y += $h; 987 $y += $h;
942 } 988 }
989
990 1
943} 991}
944 992
945############################################################################# 993#############################################################################
946 994
947package CFClient::UI::Label; 995package CFClient::UI::Label;
1116} 1164}
1117 1165
1118sub size_allocate { 1166sub size_allocate {
1119 my ($self, $x, $y, $w, $h) = @_; 1167 my ($self, $x, $y, $w, $h) = @_;
1120 1168
1121 $self->SUPER::size_allocate ($x, $y, $w, $h); 1169 $self->SUPER::size_allocate ($x, $y, $w, $h) or return;
1122 1170
1123 $self->_set_text ($self->{text}); 1171 $self->_set_text ($self->{text});
1124} 1172}
1125 1173
1126sub set_text { 1174sub set_text {
1347} 1395}
1348 1396
1349sub size_allocate { 1397sub size_allocate {
1350 my ($self, $x, $y, $w, $h) = @_; 1398 my ($self, $x, $y, $w, $h) = @_;
1351 1399
1352 $self->_size_allocate ($x, $y, $w, $h); 1400 $self->_size_allocate ($x, $y, $w, $h) or return;
1353} 1401}
1354 1402
1355sub button_down { 1403sub button_down {
1356 my ($self, $ev, $x, $y) = @_; 1404 my ($self, $ev, $x, $y) = @_;
1357 1405
1690} 1738}
1691 1739
1692sub size_allocate { 1740sub size_allocate {
1693 my ($self, $x, $y, $w, $h) = @_; 1741 my ($self, $x, $y, $w, $h) = @_;
1694 1742
1695 $self->SUPER::size_allocate ($x, $y, $w, $h); 1743 $self->SUPER::size_allocate ($x, $y, $w, $h) or return;
1696 1744
1697 $self->{layout}->set_height ($self->{fontsize}); 1745 $self->{layout}->set_height ($self->{fontsize});
1698 $self->{layout}->set_width ($self->{w}); 1746 $self->{layout}->set_width ($self->{w});
1699 1747
1700 $self->reflow; 1748 $self->reflow;
1749 $self->update;
1701} 1750}
1702 1751
1703sub add_paragraph { 1752sub add_paragraph {
1704 my ($self, $color, $text) = @_; 1753 my ($self, $color, $text) = @_;
1705 1754
2113 2162
2114our @ISA = CFClient::UI::Container::; 2163our @ISA = CFClient::UI::Container::;
2115 2164
2116use SDL::OpenGL; 2165use SDL::OpenGL;
2117 2166
2167sub check_size {
2168 my ($self) = @_;
2169
2170 $self->size_allocate (0, 0, $::WITH, $::HEIGHT);
2171}
2172
2118sub size_request { 2173sub size_request {
2119 ($::WIDTH, $::HEIGHT) 2174 ($::WIDTH, $::HEIGHT)
2120} 2175}
2121 2176
2122sub size_allocate { 2177sub size_allocate {
2135} 2190}
2136 2191
2137sub update { 2192sub update {
2138 my ($self) = @_; 2193 my ($self) = @_;
2139 2194
2140 $self->size_allocate (0, 0, $::WIDTH, $::HEIGHT); 2195 $self->check_size;
2141 ::refresh (); 2196 ::refresh ();
2142} 2197}
2143 2198
2144sub add { 2199sub add {
2145 my ($self, $widget) = @_; 2200 my ($self, $widget) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines