… | |
… | |
66 | $hover->update if $hover && $hover->{can_hover}; |
66 | $hover->update if $hover && $hover->{can_hover}; |
67 | $HOVER->update if $HOVER && $HOVER->{can_hover}; |
67 | $HOVER->update if $HOVER && $HOVER->{can_hover}; |
68 | } |
68 | } |
69 | |
69 | |
70 | $HOVER->mouse_motion ($ev, $HOVER->translate ($x, $y)) if $HOVER; |
70 | $HOVER->mouse_motion ($ev, $HOVER->translate ($x, $y)) if $HOVER; |
|
|
71 | } |
|
|
72 | |
|
|
73 | # convert position array to integers |
|
|
74 | sub harmonize { |
|
|
75 | my ($vals) = @_; |
|
|
76 | |
|
|
77 | my $rem = 0; |
|
|
78 | |
|
|
79 | for ($vals) { |
|
|
80 | my $i = int $_ + $rem; |
|
|
81 | $rem += $_ - $i; |
|
|
82 | $_ = $i; |
|
|
83 | } |
71 | } |
84 | } |
72 | |
85 | |
73 | ############################################################################# |
86 | ############################################################################# |
74 | |
87 | |
75 | package CFClient::UI::Base; |
88 | package CFClient::UI::Base; |
… | |
… | |
733 | |
746 | |
734 | # linearly scale sizes |
747 | # linearly scale sizes |
735 | $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws; |
748 | $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws; |
736 | $hs->[$_] *= 1 * $h / $req_h for 0 .. $#$hs; |
749 | $hs->[$_] *= 1 * $h / $req_h for 0 .. $#$hs; |
737 | |
750 | |
738 | $_ = int $_ for @$ws; #TODO: avoid rounding problems |
751 | CFClient::UI::harmonize $ws; |
739 | $_ = int $_ for @$hs; #TODO: avoid rounding problems |
752 | CFClient::UI::harmonize $hs; |
740 | |
753 | |
741 | my $y; |
754 | my $y; |
742 | |
755 | |
743 | for my $r (0 .. $#{$self->{children}}) { |
756 | for my $r (0 .. $#{$self->{children}}) { |
744 | my $row = $self->{children}[$r] |
757 | my $row = $self->{children}[$r] |
… | |
… | |
832 | $alloc_h += ($h - $req_h) * $child->{expand} / $exp; |
845 | $alloc_h += ($h - $req_h) * $child->{expand} / $exp; |
833 | $h[$_] = $alloc_h; |
846 | $h[$_] = $alloc_h; |
834 | } |
847 | } |
835 | } |
848 | } |
836 | |
849 | |
|
|
850 | CFClient::UI::harmonize \@h; |
|
|
851 | |
837 | my $y = 0; |
852 | my $y = 0; |
838 | for (0 .. $#$children) { |
853 | for (0 .. $#$children) { |
839 | my $child = $children->[$_]; |
854 | my $child = $children->[$_]; |
840 | my $h = int $h[$_]; |
855 | my $h = $h[$_]; |
841 | $child->size_allocate ($y, 0, $h, $w); |
856 | $child->size_allocate ($y, 0, $h, $w); |
842 | |
857 | |
843 | $y += $h; |
858 | $y += $h; |
844 | } |
859 | } |
845 | } |
860 | } |
… | |
… | |
886 | |
901 | |
887 | $h[$_] += ($h - $req_h) * $child->{expand} / $exp; |
902 | $h[$_] += ($h - $req_h) * $child->{expand} / $exp; |
888 | } |
903 | } |
889 | } |
904 | } |
890 | |
905 | |
|
|
906 | CFClient::UI::harmonize \@h; |
|
|
907 | |
891 | my $y = 0; |
908 | my $y = 0; |
892 | for (0 .. $#$children) { |
909 | for (0 .. $#$children) { |
893 | my $child = $children->[$_]; |
910 | my $child = $children->[$_]; |
894 | my $h = int $h[$_]; |
911 | my $h = $h[$_]; |
895 | $child->size_allocate (0, $y, $w, $h); |
912 | $child->size_allocate (0, $y, $w, $h); |
896 | |
913 | |
897 | $y += $h; |
914 | $y += $h; |
898 | } |
915 | } |
899 | } |
916 | } |