… | |
… | |
593 | |
593 | |
594 | # using global variables seems a bit hacky, but passing through all drawing |
594 | # using global variables seems a bit hacky, but passing through all drawing |
595 | # functions seems pointless. |
595 | # functions seems pointless. |
596 | our ($draw_x, $draw_y, $draw_w, $draw_h); # screen rectangle being drawn |
596 | our ($draw_x, $draw_y, $draw_w, $draw_h); # screen rectangle being drawn |
597 | |
597 | |
598 | sub draw { |
598 | #sub draw { |
599 | my ($self) = @_; |
599 | #CFPlus.xs |
600 | |
|
|
601 | return unless $self->{h} && $self->{w}; |
|
|
602 | |
|
|
603 | # update screen rectangle |
|
|
604 | local $draw_x = $draw_x + $self->{x}; |
|
|
605 | local $draw_y = $draw_y + $self->{y}; |
|
|
606 | |
|
|
607 | # skip widgets that are entirely outside the drawing area |
|
|
608 | return if ($draw_x + $self->{w} < 0) || ($draw_x >= $draw_w) |
|
|
609 | || ($draw_y + $self->{h} < 0) || ($draw_y >= $draw_h); |
|
|
610 | |
|
|
611 | glPushMatrix; |
|
|
612 | glTranslate $self->{x}, $self->{y}, 0; |
|
|
613 | |
|
|
614 | if ($self == $HOVER && $self->{can_hover}) { |
|
|
615 | glColor 1*0.2, 0.8*0.2, 0.5*0.2, 0.2; |
|
|
616 | glEnable GL_BLEND; |
|
|
617 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
|
|
618 | glBegin GL_QUADS; |
|
|
619 | glVertex 0 , 0; |
|
|
620 | glVertex $self->{w}, 0; |
|
|
621 | glVertex $self->{w}, $self->{h}; |
|
|
622 | glVertex 0 , $self->{h}; |
|
|
623 | glEnd; |
|
|
624 | glDisable GL_BLEND; |
|
|
625 | } |
|
|
626 | |
|
|
627 | if ($ENV{CFPLUS_DEBUG} & 1) { |
|
|
628 | glPushMatrix; |
|
|
629 | glColor 1, 1, 0, 1; |
|
|
630 | glTranslate 0.375, 0.375; |
|
|
631 | glBegin GL_LINE_LOOP; |
|
|
632 | glVertex 0 , 0; |
|
|
633 | glVertex $self->{w} - 1, 0; |
|
|
634 | glVertex $self->{w} - 1, $self->{h} - 1; |
|
|
635 | glVertex 0 , $self->{h} - 1; |
|
|
636 | glEnd; |
|
|
637 | glPopMatrix; |
|
|
638 | #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
|
|
639 | } |
|
|
640 | |
|
|
641 | $self->_draw; |
|
|
642 | glPopMatrix; |
|
|
643 | } |
|
|
644 | |
600 | |
645 | sub _draw { |
601 | sub _draw { |
646 | my ($self) = @_; |
602 | my ($self) = @_; |
647 | |
603 | |
648 | warn "no draw defined for $self\n"; |
604 | warn "no draw defined for $self\n"; |
649 | } |
605 | } |
650 | |
606 | |
651 | my $cntx;#d# |
|
|
652 | sub DESTROY { |
607 | sub DESTROY { |
653 | my ($self) = @_; |
608 | my ($self) = @_; |
654 | |
609 | |
655 | return if CFPlus::in_destruct; |
610 | return if CFPlus::in_destruct; |
656 | |
611 | |
… | |
… | |
769 | sort { $a->{z} <=> $b->{z} } |
724 | sort { $a->{z} <=> $b->{z} } |
770 | @{$self->{children}}, @widgets |
725 | @{$self->{children}}, @widgets |
771 | ]; |
726 | ]; |
772 | |
727 | |
773 | $self->realloc; |
728 | $self->realloc; |
|
|
729 | |
|
|
730 | map $_+0, @widgets |
774 | } |
731 | } |
775 | |
732 | |
776 | sub children { |
733 | sub children { |
777 | @{ $_[0]{children} } |
734 | @{ $_[0]{children} } |
778 | } |
735 | } |
… | |
… | |
1093 | $vp->{parent}{hslider}->set_value ($x); |
1050 | $vp->{parent}{hslider}->set_value ($x); |
1094 | $vp->{parent}{vslider}->set_value ($y); |
1051 | $vp->{parent}{vslider}->set_value ($y); |
1095 | |
1052 | |
1096 | 0 |
1053 | 0 |
1097 | }, |
1054 | }, |
|
|
1055 | on_size_allocate => sub { |
|
|
1056 | my ($vp, $w, $h) = @_; |
|
|
1057 | $vp->{parent}->update_slider; |
|
|
1058 | 0 |
|
|
1059 | }, |
1098 | ; |
1060 | ; |
1099 | |
1061 | |
1100 | $self->SUPER::add ($self->{vp}); |
1062 | $self->SUPER::add ($self->{vp}); |
1101 | |
1063 | |
1102 | $self->add ($child) if $child; |
1064 | $self->add ($child) if $child; |
1103 | |
1065 | |
1104 | $self |
1066 | $self |
1105 | } |
1067 | } |
1106 | |
|
|
1107 | #TODO# update range on size_allocate depending on child? |
|
|
1108 | |
1068 | |
1109 | sub add { |
1069 | sub add { |
1110 | my ($self, $widget) = @_; |
1070 | my ($self, $widget) = @_; |
1111 | |
1071 | |
1112 | $self->{vp}->add ($self->{child} = $widget); |
1072 | $self->{vp}->add ($self->{child} = $widget); |
… | |
… | |
1115 | sub update_slider { |
1075 | sub update_slider { |
1116 | my ($self) = @_; |
1076 | my ($self) = @_; |
1117 | |
1077 | |
1118 | my $child = ($self->{vp} or return)->child; |
1078 | my $child = ($self->{vp} or return)->child; |
1119 | |
1079 | |
|
|
1080 | if ($self->{scroll_x}) { |
1120 | my ($w1, $w2) = ($child->{w}, $self->{vp}{w}); |
1081 | my ($w1, $w2) = ($child->{req_w}, $self->{vp}{w}); |
1121 | $self->{hslider}->set_range ([$self->{hslider}{range}[0], 0, $w1, $w2, 1]); |
1082 | $self->{hslider}->set_range ([$self->{hslider}{range}[0], 0, $w1, $w2, 1]); |
1122 | |
1083 | |
1123 | my $visible = $w1 > $w2; |
1084 | my $visible = $w1 > $w2; |
1124 | if ($visible != $self->{hslider_visible}) { |
1085 | if ($visible != $self->{hslider_visible}) { |
1125 | $self->{hslider_visible} = $visible; |
1086 | $self->{hslider_visible} = $visible; |
1126 | $visible ? $self->SUPER::add ($self->{hslider}) |
1087 | $visible ? $self->SUPER::add ($self->{hslider}) |
1127 | : $self->SUPER::remove ($self->{hslider}); |
1088 | : $self->SUPER::remove ($self->{hslider}); |
|
|
1089 | } |
1128 | } |
1090 | } |
1129 | |
1091 | |
|
|
1092 | if ($self->{scroll_y}) { |
1130 | my ($h1, $h2) = ($child->{h}, $self->{vp}{h}); |
1093 | my ($h1, $h2) = ($child->{req_h}, $self->{vp}{h}); |
1131 | $self->{vslider}->set_range ([$self->{vslider}{range}[0], 0, $h1, $h2, 1]); |
1094 | $self->{vslider}->set_range ([$self->{vslider}{range}[0], 0, $h1, $h2, 1]); |
1132 | |
1095 | |
1133 | my $visible = $h1 > $h2; |
1096 | my $visible = $h1 > $h2; |
1134 | if ($visible != $self->{vslider_visible}) { |
1097 | if ($visible != $self->{vslider_visible}) { |
1135 | $self->{vslider_visible} = $visible; |
1098 | $self->{vslider_visible} = $visible; |
1136 | $visible ? $self->SUPER::add ($self->{vslider}) |
1099 | $visible ? $self->SUPER::add ($self->{vslider}) |
1137 | : $self->SUPER::remove ($self->{vslider}); |
1100 | : $self->SUPER::remove ($self->{vslider}); |
|
|
1101 | } |
|
|
1102 | } |
|
|
1103 | } |
|
|
1104 | |
|
|
1105 | sub start_dragging { |
|
|
1106 | my ($self, $ev) = @_; |
|
|
1107 | |
|
|
1108 | $self->grab_focus; |
|
|
1109 | |
|
|
1110 | my $ox = $self->{vp}{view_x}; |
|
|
1111 | my $oy = $self->{vp}{view_y}; |
|
|
1112 | |
|
|
1113 | $self->{motion} = sub { |
|
|
1114 | my ($ev, $x, $y) = @_; |
|
|
1115 | |
|
|
1116 | $ox -= $ev->{xrel}; |
|
|
1117 | $oy -= $ev->{yrel}; |
|
|
1118 | |
|
|
1119 | $self->{vp}->set_offset ($ox, $oy); |
1138 | } |
1120 | }; |
1139 | } |
|
|
1140 | |
|
|
1141 | sub update { |
|
|
1142 | my ($self) = @_; |
|
|
1143 | |
|
|
1144 | $self->update_slider; |
|
|
1145 | $self->SUPER::update; |
|
|
1146 | } |
1121 | } |
1147 | |
1122 | |
1148 | sub invoke_mouse_wheel { |
1123 | sub invoke_mouse_wheel { |
1149 | my ($self, $ev) = @_; |
1124 | my ($self, $ev) = @_; |
1150 | |
1125 | |
1151 | $self->{vslider}->emit (mouse_wheel => $ev) |
1126 | $self->{vslider}->emit (mouse_wheel => $ev) if $self->{vslider_visible}; |
1152 | if $ev->{dy}; |
|
|
1153 | |
|
|
1154 | $self->{hslider}->emit (mouse_wheel => $ev) |
1127 | $self->{hslider}->emit (mouse_wheel => $ev) if $self->{hslider_visible}; |
1155 | if $ev->{dx}; |
|
|
1156 | |
1128 | |
1157 | 1 |
1129 | 1 |
1158 | } |
1130 | } |
1159 | |
1131 | |
1160 | sub invoke_button_down { |
1132 | sub invoke_button_down { |
1161 | my ($self, $ev, $x, $y) = @_; |
1133 | my ($self, $ev, $x, $y) = @_; |
1162 | |
1134 | |
1163 | if ($ev->{button} == 2) { |
1135 | if ($ev->{button} == 2) { |
1164 | $self->grab_focus; |
1136 | $self->start_dragging ($ev); |
1165 | |
|
|
1166 | my $ox = $self->{vp}{view_x} + $ev->{x}; |
|
|
1167 | my $oy = $self->{vp}{view_y} + $ev->{y}; |
|
|
1168 | |
|
|
1169 | $self->{motion} = sub { |
|
|
1170 | my ($ev, $x, $y) = @_; |
|
|
1171 | |
|
|
1172 | $self->{vp}->set_offset ($ox - $ev->{x}, $oy - $ev->{y}); |
|
|
1173 | $self->update; |
|
|
1174 | }; |
|
|
1175 | |
|
|
1176 | return 1; |
1137 | return 1; |
1177 | } |
1138 | } |
1178 | |
1139 | |
1179 | 0 |
1140 | 0 |
1180 | } |
1141 | } |
… | |
… | |
1725 | |
1686 | |
1726 | use List::Util qw(min max); |
1687 | use List::Util qw(min max); |
1727 | |
1688 | |
1728 | our @ISA = CFPlus::UI::Container::; |
1689 | our @ISA = CFPlus::UI::Container::; |
1729 | |
1690 | |
1730 | sub add { |
|
|
1731 | my ($self, $child, $posmode, $x, $y, $sizemode, $w, $h) = @_; |
|
|
1732 | |
|
|
1733 | $child->{_fixed} = [$posmode, $x, $y, $sizemode, $w, $h]; |
|
|
1734 | $self->SUPER::add ($child); |
|
|
1735 | } |
|
|
1736 | |
|
|
1737 | sub _scale($$$) { |
1691 | sub _scale($$$) { |
1738 | my ($mode, $val, $max) = @_; |
1692 | my ($rel, $val, $max) = @_; |
1739 | |
1693 | |
1740 | $mode eq "abs" ? $val |
1694 | $rel ? $val * $max : $val |
1741 | : $mode eq "rel" ? $val * $max |
|
|
1742 | : 0 |
|
|
1743 | } |
1695 | } |
1744 | |
1696 | |
1745 | sub size_request { |
1697 | sub size_request { |
1746 | my ($self) = @_; |
1698 | my ($self) = @_; |
1747 | |
1699 | |
1748 | my ($x1, $y1, $x2, $y2) = (0, 0, 0, 0); |
1700 | my ($x1, $y1, $x2, $y2) = (0, 0, 0, 0); |
1749 | |
1701 | |
1750 | # determine overall size by querying abs widgets |
1702 | # determine overall size by querying abs widgets |
1751 | for my $child ($self->visible_children) { |
1703 | for my $child ($self->visible_children) { |
1752 | 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}; |
1753 | |
1707 | |
1754 | if ($pos eq "abs") { |
|
|
1755 | $w = _scale $size, $w, $child->{req_w}; |
|
|
1756 | $h = _scale $size, $h, $child->{req_h}; |
|
|
1757 | |
|
|
1758 | $x1 = min $x1, $x; $x2 = max $x2, $x + $w; |
1708 | $x1 = min $x1, $x; $x2 = max $x2, $x + $child->{req_w}; |
1759 | $y1 = min $y1, $y; $y2 = max $y2, $y + $h; |
1709 | $y1 = min $y1, $y; $y2 = max $y2, $y + $child->{req_h}; |
1760 | } |
1710 | } |
1761 | } |
1711 | } |
1762 | |
1712 | |
1763 | my $W = $x2 - $x1; |
1713 | my $W = $x2 - $x1; |
1764 | my $H = $y2 - $y1; |
1714 | my $H = $y2 - $y1; |
1765 | |
1715 | |
1766 | # now layout remaining widgets |
1716 | # now layout remaining widgets |
1767 | for my $child ($self->visible_children) { |
1717 | for my $child ($self->visible_children) { |
1768 | 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; |
1769 | |
1721 | |
1770 | if ($pos ne "abs") { |
|
|
1771 | $x = _scale $pos, $x, $W; |
|
|
1772 | $y = _scale $pos, $x, $H; |
|
|
1773 | $w = _scale $size, $w, $child->{req_w}; |
|
|
1774 | $h = _scale $size, $h, $child->{req_h}; |
|
|
1775 | |
|
|
1776 | $x1 = min $x1, $x; $x2 = max $x2, $x + $w; |
1722 | $x1 = min $x1, $x; $x2 = max $x2, $x + $child->{req_w}; |
1777 | $y1 = min $y1, $y; $y2 = max $y2, $y + $h; |
1723 | $y1 = min $y1, $y; $y2 = max $y2, $y + $child->{req_h}; |
1778 | } |
1724 | } |
1779 | } |
1725 | } |
1780 | |
1726 | |
1781 | my $W = $x2 - $x1; |
1727 | my $W = $x2 - $x1; |
1782 | my $H = $y2 - $y1; |
1728 | my $H = $y2 - $y1; |
… | |
… | |
1786 | |
1732 | |
1787 | sub invoke_size_allocate { |
1733 | sub invoke_size_allocate { |
1788 | my ($self, $W, $H) = @_; |
1734 | my ($self, $W, $H) = @_; |
1789 | |
1735 | |
1790 | for my $child ($self->visible_children) { |
1736 | for my $child ($self->visible_children) { |
1791 | 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; |
1792 | |
1739 | |
1793 | $x = _scale $pos, $x, $W; |
1740 | $x += $child->{c_halign} * $child->{req_w}; |
1794 | $y = _scale $pos, $x, $H; |
1741 | $y += $child->{c_valign} * $child->{req_h}; |
1795 | $w = _scale $size, $w, $child->{req_w}; |
|
|
1796 | $h = _scale $size, $h, $child->{req_h}; |
|
|
1797 | |
1742 | |
1798 | $child->configure ($x, $y, $w, $h); |
1743 | $child->configure ($x, $y, $child->{req_w}, $child->{req_h}); |
1799 | } |
1744 | } |
1800 | |
1745 | |
1801 | 1 |
1746 | 1 |
1802 | } |
1747 | } |
1803 | |
1748 | |
… | |
… | |
2066 | $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y} |
2011 | $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y} |
2067 | : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y} |
2012 | : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y} |
2068 | : ($self->{h} - $size->[1]) * 0.5); |
2013 | : ($self->{h} - $size->[1]) * 0.5); |
2069 | }; |
2014 | }; |
2070 | |
2015 | |
2071 | my $w = List::Util::min $self->{w} + 4, $size->[0]; |
2016 | # unless ($self->{list}) { |
2072 | my $h = List::Util::min $self->{h} + 2, $size->[1]; |
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}; |
2073 | |
2024 | |
2074 | $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
2025 | $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
2075 | } |
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 | #} |
2076 | |
2035 | |
2077 | ############################################################################# |
2036 | ############################################################################# |
2078 | |
2037 | |
2079 | package CFPlus::UI::EntryBase; |
2038 | package CFPlus::UI::EntryBase; |
2080 | |
2039 | |
… | |
… | |
2865 | |
2824 | |
2866 | $self->SUPER::invoke_button_down ($ev, $x, $y); |
2825 | $self->SUPER::invoke_button_down ($ev, $x, $y); |
2867 | |
2826 | |
2868 | $self->{click} = [$self->{range}[0], $self->{vertical} ? $y : $x]; |
2827 | $self->{click} = [$self->{range}[0], $self->{vertical} ? $y : $x]; |
2869 | |
2828 | |
2870 | $self->invoke_mouse_motion ($ev, $x, $y) |
2829 | $self->invoke_mouse_motion ($ev, $x, $y); |
|
|
2830 | |
|
|
2831 | 1 |
2871 | } |
2832 | } |
2872 | |
2833 | |
2873 | sub invoke_mouse_motion { |
2834 | sub invoke_mouse_motion { |
2874 | my ($self, $ev, $x, $y) = @_; |
2835 | my ($self, $ev, $x, $y) = @_; |
2875 | |
2836 | |
… | |
… | |
2895 | |
2856 | |
2896 | my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2; |
2857 | my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2; |
2897 | |
2858 | |
2898 | $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart); |
2859 | $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart); |
2899 | |
2860 | |
2900 | ! ! $delta |
2861 | 1 |
2901 | } |
2862 | } |
2902 | |
2863 | |
2903 | sub update { |
2864 | sub update { |
2904 | my ($self) = @_; |
2865 | my ($self) = @_; |
2905 | |
2866 | |
… | |
… | |
3478 | |
3439 | |
3479 | if ($self->{anim} && $self->{animspeed}) { |
3440 | if ($self->{anim} && $self->{animspeed}) { |
3480 | CFPlus::weaken (my $widget = $self); |
3441 | CFPlus::weaken (my $widget = $self); |
3481 | |
3442 | |
3482 | $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed}; |
3443 | $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed}; |
3483 | $widget->{anim_start} = $self->{animspeed} * Event::time / $self->{animspeed}; |
3444 | $widget->{anim_start} = $self->{animspeed} * int Event::time / $self->{animspeed}; |
3484 | $self->{timer} = Event->timer ( |
3445 | $self->{timer} = Event->timer ( |
3485 | parked => 1, |
3446 | parked => 1, |
3486 | cb => sub { |
3447 | cb => sub { |
3487 | return unless $::CONN && $widget; |
3448 | return unless $::CONN && $widget; |
3488 | |
3449 | |
… | |
… | |
3525 | |
3486 | |
3526 | if (my $anim = $::CONN->{anim}[$self->{anim}]) { |
3487 | if (my $anim = $::CONN->{anim}[$self->{anim}]) { |
3527 | if ($anim && @$anim) { |
3488 | if ($anim && @$anim) { |
3528 | delete $self->{wait_face}; |
3489 | delete $self->{wait_face}; |
3529 | $self->{face} = $anim->[ $self->{frame} % @$anim ]; |
3490 | $self->{face} = $anim->[ $self->{frame} % @$anim ]; |
|
|
3491 | $self->{tex} = $::CONN->{texture}[ $::CONN->{faceid}[$self->{face}] ]; |
3530 | } |
3492 | } |
3531 | } |
3493 | } |
3532 | } |
3494 | } |
3533 | |
3495 | |
3534 | sub size_request { |
3496 | sub size_request { |
3535 | my ($self) = @_; |
3497 | my ($self) = @_; |
3536 | |
3498 | |
3537 | if ($::CONN) { |
3499 | if ($::CONN) { |
3538 | if (my $faceid = $::CONN->{faceid}[$self->{face}]) { |
3500 | if (my $faceid = $::CONN->{faceid}[$self->{face}]) { |
3539 | if (my $tex = $::CONN->{texture}[$faceid]) { |
3501 | if (my $tex = $::CONN->{texture}[$faceid]) { |
|
|
3502 | $self->{tex} = $tex; |
3540 | return ($self->{size_w} || $tex->{w}, $self->{size_h} || $tex->{h}); |
3503 | return ($self->{size_w} || $tex->{w}, $self->{size_h} || $tex->{h}); |
3541 | } else { |
3504 | } else { |
3542 | $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub { |
3505 | $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub { |
3543 | $self->realloc; |
3506 | $self->realloc; |
3544 | }); |
3507 | }); |
… | |
… | |
3566 | } |
3529 | } |
3567 | |
3530 | |
3568 | sub _draw { |
3531 | sub _draw { |
3569 | my ($self) = @_; |
3532 | my ($self) = @_; |
3570 | |
3533 | |
3571 | return unless $::CONN; |
|
|
3572 | |
|
|
3573 | $self->SUPER::_draw; |
3534 | $self->SUPER::_draw; |
3574 | |
3535 | |
3575 | my $faceid = $::CONN->{faceid}[$self->{face}] |
3536 | if (my $tex = $self->{tex}) { |
3576 | or return; |
|
|
3577 | |
|
|
3578 | my $tex = $::CONN->{texture}[$faceid]; |
|
|
3579 | |
|
|
3580 | if ($tex) { |
|
|
3581 | glEnable GL_TEXTURE_2D; |
3537 | glEnable GL_TEXTURE_2D; |
3582 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
3538 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
3583 | glColor 0, 0, 0, 1; |
3539 | glColor 0, 0, 0, 1; |
3584 | $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
3540 | $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
3585 | glDisable GL_TEXTURE_2D; |
3541 | glDisable GL_TEXTURE_2D; |
… | |
… | |
3795 | sub add { |
3751 | sub add { |
3796 | my ($self, $title, $widget, $tooltip) = @_; |
3752 | my ($self, $title, $widget, $tooltip) = @_; |
3797 | |
3753 | |
3798 | CFPlus::weaken $self; |
3754 | CFPlus::weaken $self; |
3799 | |
3755 | |
3800 | $self->{buttonbar}->add (new CFPlus::UI::Button |
3756 | unless (ref $title) { |
|
|
3757 | $title = new CFPlus::UI::Button |
3801 | markup => $title, |
3758 | markup => $title, |
3802 | tooltip => $tooltip, |
3759 | tooltip => $tooltip, |
|
|
3760 | ; |
|
|
3761 | } |
|
|
3762 | |
3803 | on_activate => sub { $self->set_current_page ($widget) }, |
3763 | $title->connect (activate => sub { $self->set_current_page ($widget) }); |
3804 | ); |
3764 | $self->{buttonbar}->add ($title); |
3805 | |
3765 | |
3806 | $self->{multiplexer}->add ($widget); |
3766 | $self->{multiplexer}->add ($widget); |
3807 | } |
3767 | } |
3808 | |
3768 | |
3809 | sub get_current_page { |
3769 | sub get_current_page { |
… | |
… | |
4141 | while ($self->{refresh_hook}) { |
4101 | while ($self->{refresh_hook}) { |
4142 | $_->() |
4102 | $_->() |
4143 | for values %{delete $self->{refresh_hook}}; |
4103 | for values %{delete $self->{refresh_hook}}; |
4144 | } |
4104 | } |
4145 | |
4105 | |
4146 | if ($self->{realloc}) { |
4106 | while ($self->{realloc}) { |
4147 | my %queue; |
4107 | my %queue; |
4148 | my @queue; |
4108 | my @queue; |
4149 | my $widget; |
4109 | my $widget; |
4150 | |
4110 | |
4151 | outer: |
4111 | outer: |
… | |
… | |
4198 | } |
4158 | } |
4199 | } |
4159 | } |
4200 | |
4160 | |
4201 | delete $self->{realloc}{$widget+0}; |
4161 | delete $self->{realloc}{$widget+0}; |
4202 | } |
4162 | } |
4203 | } |
|
|
4204 | |
4163 | |
4205 | while (my $size_alloc = delete $self->{size_alloc}) { |
4164 | while (my $size_alloc = delete $self->{size_alloc}) { |
4206 | my @queue = sort { $b->{visible} <=> $a->{visible} } |
4165 | my @queue = sort { $a->{visible} <=> $b->{visible} } |
4207 | values %$size_alloc; |
4166 | values %$size_alloc; |
4208 | |
4167 | |
4209 | while () { |
4168 | while () { |
4210 | my $widget = pop @queue || last; |
4169 | my $widget = pop @queue || last; |
4211 | |
4170 | |
4212 | my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; |
4171 | my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; |
4213 | |
4172 | |
4214 | $w = 0 if $w < 0; |
|
|
4215 | $h = 0 if $h < 0; |
|
|
4216 | |
|
|
4217 | $w = max $widget->{min_w}, $w; |
4173 | $w = max $widget->{min_w}, $w; |
4218 | $h = max $widget->{min_h}, $h; |
4174 | $h = max $widget->{min_h}, $h; |
4219 | |
4175 | |
4220 | # $w = min $self->{w} - $widget->{x}, $w if $self->{w}; |
4176 | # $w = min $self->{w} - $widget->{x}, $w if $self->{w}; |
4221 | # $h = min $self->{h} - $widget->{y}, $h if $self->{h}; |
4177 | # $h = min $self->{h} - $widget->{y}, $h if $self->{h}; |
4222 | |
4178 | |
4223 | $w = min $widget->{max_w}, $w if exists $widget->{max_w}; |
4179 | $w = min $widget->{max_w}, $w if exists $widget->{max_w}; |
4224 | $h = min $widget->{max_h}, $h if exists $widget->{max_h}; |
4180 | $h = min $widget->{max_h}, $h if exists $widget->{max_h}; |
4225 | |
4181 | |
4226 | $w = int $w + 0.5; |
4182 | $w = int $w + 0.5; |
4227 | $h = int $h + 0.5; |
4183 | $h = int $h + 0.5; |
4228 | |
4184 | |
4229 | if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { |
4185 | if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { |
4230 | $widget->{old_w} = $widget->{w}; |
4186 | $widget->{old_w} = $widget->{w}; |
4231 | $widget->{old_h} = $widget->{h}; |
4187 | $widget->{old_h} = $widget->{h}; |
4232 | |
4188 | |
4233 | $widget->{w} = $w; |
4189 | $widget->{w} = $w; |
4234 | $widget->{h} = $h; |
4190 | $widget->{h} = $h; |
4235 | |
4191 | |
4236 | $widget->emit (size_allocate => $w, $h); |
4192 | $widget->emit (size_allocate => $w, $h); |
|
|
4193 | } |
4237 | } |
4194 | } |
4238 | } |
4195 | } |
4239 | } |
4196 | } |
4240 | |
4197 | |
4241 | while ($self->{post_alloc_hook}) { |
4198 | while ($self->{post_alloc_hook}) { |