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.388 by root, Fri Jul 20 18:30:03 2007 UTC vs.
Revision 1.389 by root, Sat Jul 21 13:02:05 2007 UTC

958sub size_request { 958sub size_request {
959 my ($self) = @_; 959 my ($self) = @_;
960 960
961 my ($w, $h) = @{$self->child}{qw(req_w req_h)}; 961 my ($w, $h) = @{$self->child}{qw(req_w req_h)};
962 962
963 $w = 10 if $self->{scroll_x}; 963 $w = 1 if $self->{scroll_x};
964 $h = 10 if $self->{scroll_y}; 964 $h = 1 if $self->{scroll_y};
965 965
966 ($w, $h) 966 ($w, $h)
967} 967}
968 968
969sub invoke_size_allocate { 969sub invoke_size_allocate {
1616 my $self = shift; 1616 my $self = shift;
1617 1617
1618 while (@_) { 1618 while (@_) {
1619 my ($col, $row, $child) = splice @_, 0, 3, (); 1619 my ($col, $row, $child) = splice @_, 0, 3, ();
1620 1620
1621 $child->{row} = $row;
1622 $child->{col} = $col;
1623
1624 $child->{rowspan} ||= 1;
1625 $child->{colspan} ||= 1;
1626
1621 $child->set_parent ($self); 1627 $child->set_parent ($self);
1622 $self->{children}[$row][$col] = $child; 1628 $self->{children}[$row][$col] = $child;
1623 } 1629 }
1624 1630
1625 $self->{force_realloc} = 1; 1631 $self->{force_realloc} = 1;
1655sub get_wh { 1661sub get_wh {
1656 my ($self) = @_; 1662 my ($self) = @_;
1657 1663
1658 my (@w, @h); 1664 my (@w, @h);
1659 1665
1660 for my $y (0 .. $#{$self->{children}}) { 1666 my @children = $self->children;
1661 my $row = $self->{children}[$y]
1662 or next;
1663 1667
1664 for my $x (0 .. $#$row) { 1668 for my $widget (sort { $b->{rowspan} * $b->{colspan} <=> $a->{rowspan} * $a->{colspan} } @children) {
1665 my $widget = $row->[$x] 1669 my ($r, $c, $w, $h, $rs, $cs) = @$widget{qw(row col req_w req_h rowspan colspan)};
1666 or next;
1667 my ($w, $h) = @$widget{qw(req_w req_h)};
1668 1670
1669 $w[$x] = max $w[$x], $w; 1671 my $sw = sum @w[$c .. $c + $cs - 1];
1670 $h[$y] = max $h[$y], $h; 1672 my $sh = sum @h[$r .. $r + $rs - 1];
1673
1674 if ($w > $sw) {
1675 $_ += ($w - $sw) / $cs for @w[$c .. $c + $cs - 1];
1676 }
1677
1678 if ($h > $sh) {
1679 $_ += ($h - $sh) / $rs for @h[$r .. $r + $rs - 1];
1671 } 1680 }
1672 } 1681 }
1673 1682
1674 (\@w, \@h) 1683 (\@w, \@h)
1675} 1684}
1691 my ($ws, $hs) = $self->get_wh; 1700 my ($ws, $hs) = $self->get_wh;
1692 1701
1693 my $req_w = (sum @$ws) || 1; 1702 my $req_w = (sum @$ws) || 1;
1694 my $req_h = (sum @$hs) || 1; 1703 my $req_h = (sum @$hs) || 1;
1695 1704
1696 # TODO: nicer code 1705 # now linearly scale the rows/columns to the allocated size
1697 my @col_expand = @{$self->{col_expand}}; 1706 my @col_expand = @{$self->{col_expand}};
1698 @col_expand = (1) x @$ws unless @col_expand; 1707 @col_expand = (1) x @$ws unless @col_expand;
1699 my $col_expand = (sum @col_expand) || 1; 1708 my $col_expand = (sum @col_expand) || 1;
1700 1709
1701 $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws; 1710 $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws;
1708 1717
1709 $hs->[$_] += $row_expand[$_] / $row_expand * ($h - $req_h) for 0 .. $#$hs; 1718 $hs->[$_] += $row_expand[$_] / $row_expand * ($h - $req_h) for 0 .. $#$hs;
1710 1719
1711 CFPlus::UI::harmonize $hs; 1720 CFPlus::UI::harmonize $hs;
1712 1721
1713 my $y; 1722 my (@x, @y);
1714 1723
1724 for (0 .. $#$ws) { $x[$_ + 1] = $x[$_] + $ws->[$_] }
1725 for (0 .. $#$hs) { $y[$_ + 1] = $y[$_] + $hs->[$_] }
1726
1715 for my $r (0 .. $#{$self->{children}}) { 1727 for my $widget ($self->children) {
1716 my $row = $self->{children}[$r] 1728 my ($r, $c, $w, $h, $rs, $cs) = @$widget{qw(row col req_w req_h rowspan colspan)};
1717 or next;
1718 1729
1719 my $x = 0; 1730 $widget->configure (
1720 my $row_h = $hs->[$r]; 1731 $x[$c], $y[$r],
1732 $x[$c + $cs] - $x[$c], $y[$r + $rs] - $y[$r],
1721 1733 );
1722 for my $c (0 .. $#$row) {
1723 my $col_w = $ws->[$c];
1724
1725 if (my $widget = $row->[$c]) {
1726 $widget->configure ($x, $y, $col_w, $row_h);
1727 }
1728
1729 $x += $col_w;
1730 }
1731
1732 $y += $row_h;
1733 } 1734 }
1734 1735
1735 1 1736 1
1736} 1737}
1737 1738

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines