… | |
… | |
1686 | |
1686 | |
1687 | use List::Util qw(min max); |
1687 | use List::Util qw(min max); |
1688 | |
1688 | |
1689 | our @ISA = CFPlus::UI::Container::; |
1689 | our @ISA = CFPlus::UI::Container::; |
1690 | |
1690 | |
1691 | sub add_fixed { |
|
|
1692 | my ($self, $child, $posmode, $x, $y, $sizemode, $w, $h) = @_; |
|
|
1693 | |
|
|
1694 | $child->{_fixed} = [$posmode, $x, $y, $sizemode, $w, $h]; |
|
|
1695 | $self->SUPER::add ($child); |
|
|
1696 | } |
|
|
1697 | |
|
|
1698 | sub _scale($$$) { |
1691 | sub _scale($$$) { |
1699 | my ($mode, $val, $max) = @_; |
1692 | my ($rel, $val, $max) = @_; |
1700 | |
1693 | |
1701 | $mode eq "abs" ? $val |
1694 | $rel ? $val * $max : $val |
1702 | : $mode eq "rel" ? $val * $max |
|
|
1703 | : 0 |
|
|
1704 | } |
1695 | } |
1705 | |
1696 | |
1706 | sub size_request { |
1697 | sub size_request { |
1707 | my ($self) = @_; |
1698 | my ($self) = @_; |
1708 | |
1699 | |
1709 | my ($x1, $y1, $x2, $y2) = (0, 0, 0, 0); |
1700 | my ($x1, $y1, $x2, $y2) = (0, 0, 0, 0); |
1710 | |
1701 | |
1711 | # determine overall size by querying abs widgets |
1702 | # determine overall size by querying abs widgets |
1712 | for my $child ($self->visible_children) { |
1703 | for my $child ($self->visible_children) { |
1713 | my ($pos, $x, $y, $size, $w, $h) = @{ $child->{_fixed} }; |
1704 | unless ($child->{c_rel}) { |
|
|
1705 | my $x = $child->{c_x}; |
|
|
1706 | my $y = $child->{c_y}; |
1714 | |
1707 | |
1715 | if ($pos eq "abs") { |
|
|
1716 | $w = _scale $size, $w, $child->{req_w}; |
|
|
1717 | $h = _scale $size, $h, $child->{req_h}; |
|
|
1718 | |
|
|
1719 | $x1 = min $x1, $x; $x2 = max $x2, $x + $w; |
1708 | $x1 = min $x1, $x; $x2 = max $x2, $x + $child->{req_w}; |
1720 | $y1 = min $y1, $y; $y2 = max $y2, $y + $h; |
1709 | $y1 = min $y1, $y; $y2 = max $y2, $y + $child->{req_h}; |
1721 | } |
1710 | } |
1722 | } |
1711 | } |
1723 | |
1712 | |
1724 | my $W = $x2 - $x1; |
1713 | my $W = $x2 - $x1; |
1725 | my $H = $y2 - $y1; |
1714 | my $H = $y2 - $y1; |
1726 | |
1715 | |
1727 | # now layout remaining widgets |
1716 | # now layout remaining widgets |
1728 | for my $child ($self->visible_children) { |
1717 | for my $child ($self->visible_children) { |
1729 | my ($pos, $x, $y, $size, $w, $h) = @{ $child->{_fixed} }; |
1718 | if ($child->{c_rel}) { |
|
|
1719 | my $x = _scale $child->{c_rel}, $child->{c_x}, $W; |
|
|
1720 | my $y = _scale $child->{c_rel}, $child->{c_y}, $H; |
1730 | |
1721 | |
1731 | if ($pos ne "abs") { |
|
|
1732 | $x = _scale $pos, $x, $W; |
|
|
1733 | $y = _scale $pos, $x, $H; |
|
|
1734 | $w = _scale $size, $w, $child->{req_w}; |
|
|
1735 | $h = _scale $size, $h, $child->{req_h}; |
|
|
1736 | |
|
|
1737 | $x1 = min $x1, $x; $x2 = max $x2, $x + $w; |
1722 | $x1 = min $x1, $x; $x2 = max $x2, $x + $child->{req_w}; |
1738 | $y1 = min $y1, $y; $y2 = max $y2, $y + $h; |
1723 | $y1 = min $y1, $y; $y2 = max $y2, $y + $child->{req_h}; |
1739 | } |
1724 | } |
1740 | } |
1725 | } |
1741 | |
1726 | |
1742 | my $W = $x2 - $x1; |
1727 | my $W = $x2 - $x1; |
1743 | my $H = $y2 - $y1; |
1728 | my $H = $y2 - $y1; |
… | |
… | |
1747 | |
1732 | |
1748 | sub invoke_size_allocate { |
1733 | sub invoke_size_allocate { |
1749 | my ($self, $W, $H) = @_; |
1734 | my ($self, $W, $H) = @_; |
1750 | |
1735 | |
1751 | for my $child ($self->visible_children) { |
1736 | for my $child ($self->visible_children) { |
1752 | my ($pos, $x, $y, $size, $w, $h) = @{ $child->{_fixed} }; |
1737 | my $x = _scale $child->{c_rel}, $child->{c_x}, $W; |
|
|
1738 | my $y = _scale $child->{c_rel}, $child->{c_y}, $H; |
1753 | |
1739 | |
1754 | $x = _scale $pos, $x, $W; |
1740 | $x += $child->{c_halign} * $child->{req_w}; |
1755 | $y = _scale $pos, $x, $H; |
1741 | $y += $child->{c_valign} * $child->{req_h}; |
1756 | $w = _scale $size, $w, $W; |
|
|
1757 | $h = _scale $size, $h, $H; |
|
|
1758 | |
1742 | |
1759 | $child->configure ($x, $y, $w, $h); |
1743 | $child->configure (int $x, int $y, $child->{req_w}, $child->{req_h}); |
1760 | } |
1744 | } |
1761 | |
1745 | |
1762 | 1 |
1746 | 1 |
1763 | } |
1747 | } |
1764 | |
1748 | |
… | |
… | |
2840 | |
2824 | |
2841 | $self->SUPER::invoke_button_down ($ev, $x, $y); |
2825 | $self->SUPER::invoke_button_down ($ev, $x, $y); |
2842 | |
2826 | |
2843 | $self->{click} = [$self->{range}[0], $self->{vertical} ? $y : $x]; |
2827 | $self->{click} = [$self->{range}[0], $self->{vertical} ? $y : $x]; |
2844 | |
2828 | |
2845 | $self->invoke_mouse_motion ($ev, $x, $y) |
2829 | $self->invoke_mouse_motion ($ev, $x, $y); |
|
|
2830 | |
|
|
2831 | 1 |
2846 | } |
2832 | } |
2847 | |
2833 | |
2848 | sub invoke_mouse_motion { |
2834 | sub invoke_mouse_motion { |
2849 | my ($self, $ev, $x, $y) = @_; |
2835 | my ($self, $ev, $x, $y) = @_; |
2850 | |
2836 | |
… | |
… | |
2870 | |
2856 | |
2871 | my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2; |
2857 | my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2; |
2872 | |
2858 | |
2873 | $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart); |
2859 | $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart); |
2874 | |
2860 | |
2875 | ! ! $delta |
2861 | 1 |
2876 | } |
2862 | } |
2877 | |
2863 | |
2878 | sub update { |
2864 | sub update { |
2879 | my ($self) = @_; |
2865 | my ($self) = @_; |
2880 | |
2866 | |