… | |
… | |
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 | |
… | |
… | |
2027 | $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y} |
2011 | $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y} |
2028 | : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y} |
2012 | : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y} |
2029 | : ($self->{h} - $size->[1]) * 0.5); |
2013 | : ($self->{h} - $size->[1]) * 0.5); |
2030 | }; |
2014 | }; |
2031 | |
2015 | |
|
|
2016 | # unless ($self->{list}) { |
|
|
2017 | # $self->{list} = CFPlus::OpenGL::glGenList; |
|
|
2018 | # CFPlus::OpenGL::glNewList $self->{list}; |
|
|
2019 | # $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
|
|
2020 | # CFPlus::OpenGL::glEndList; |
|
|
2021 | # } |
|
|
2022 | # |
|
|
2023 | # CFPlus::OpenGL::glCallList $self->{list}; |
|
|
2024 | |
2032 | $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
2025 | $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
2033 | } |
2026 | } |
|
|
2027 | |
|
|
2028 | #sub destroy { |
|
|
2029 | # my ($self) = @_; |
|
|
2030 | # |
|
|
2031 | # CFPlus::OpenGL::glDeleteList delete $self->{list} if $self->{list}; |
|
|
2032 | # |
|
|
2033 | # $self->SUPER::destroy; |
|
|
2034 | #} |
2034 | |
2035 | |
2035 | ############################################################################# |
2036 | ############################################################################# |
2036 | |
2037 | |
2037 | package CFPlus::UI::EntryBase; |
2038 | package CFPlus::UI::EntryBase; |
2038 | |
2039 | |
… | |
… | |
2823 | |
2824 | |
2824 | $self->SUPER::invoke_button_down ($ev, $x, $y); |
2825 | $self->SUPER::invoke_button_down ($ev, $x, $y); |
2825 | |
2826 | |
2826 | $self->{click} = [$self->{range}[0], $self->{vertical} ? $y : $x]; |
2827 | $self->{click} = [$self->{range}[0], $self->{vertical} ? $y : $x]; |
2827 | |
2828 | |
2828 | $self->invoke_mouse_motion ($ev, $x, $y) |
2829 | $self->invoke_mouse_motion ($ev, $x, $y); |
|
|
2830 | |
|
|
2831 | 1 |
2829 | } |
2832 | } |
2830 | |
2833 | |
2831 | sub invoke_mouse_motion { |
2834 | sub invoke_mouse_motion { |
2832 | my ($self, $ev, $x, $y) = @_; |
2835 | my ($self, $ev, $x, $y) = @_; |
2833 | |
2836 | |
… | |
… | |
2853 | |
2856 | |
2854 | my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2; |
2857 | my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2; |
2855 | |
2858 | |
2856 | $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart); |
2859 | $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart); |
2857 | |
2860 | |
2858 | ! ! $delta |
2861 | 1 |
2859 | } |
2862 | } |
2860 | |
2863 | |
2861 | sub update { |
2864 | sub update { |
2862 | my ($self) = @_; |
2865 | my ($self) = @_; |
2863 | |
2866 | |
… | |
… | |
3748 | sub add { |
3751 | sub add { |
3749 | my ($self, $title, $widget, $tooltip) = @_; |
3752 | my ($self, $title, $widget, $tooltip) = @_; |
3750 | |
3753 | |
3751 | CFPlus::weaken $self; |
3754 | CFPlus::weaken $self; |
3752 | |
3755 | |
3753 | $self->{buttonbar}->add (new CFPlus::UI::Button |
3756 | unless (ref $title) { |
|
|
3757 | $title = new CFPlus::UI::Button |
3754 | markup => $title, |
3758 | markup => $title, |
3755 | tooltip => $tooltip, |
3759 | tooltip => $tooltip, |
|
|
3760 | ; |
|
|
3761 | } |
|
|
3762 | |
3756 | on_activate => sub { $self->set_current_page ($widget) }, |
3763 | $title->connect (activate => sub { $self->set_current_page ($widget) }); |
3757 | ); |
3764 | $self->{buttonbar}->add ($title); |
3758 | |
3765 | |
3759 | $self->{multiplexer}->add ($widget); |
3766 | $self->{multiplexer}->add ($widget); |
3760 | } |
3767 | } |
3761 | |
3768 | |
3762 | sub get_current_page { |
3769 | sub get_current_page { |