… | |
… | |
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 | } |
… | |
… | |
789 | } |
746 | } |
790 | |
747 | |
791 | sub clear { |
748 | sub clear { |
792 | my ($self) = @_; |
749 | my ($self) = @_; |
793 | |
750 | |
794 | my $children = delete $self->{children}; |
751 | my $children = $self->{children}; |
795 | $self->{children} = []; |
752 | $self->{children} = []; |
796 | |
753 | |
797 | for (@$children) { |
754 | for (@$children) { |
798 | delete $_->{parent}; |
755 | delete $_->{parent}; |
799 | $_->hide; |
756 | $_->hide; |
… | |
… | |
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}) { |
|
|
1086 | $self->{hslider_visible} = $visible; |
1125 | $visible ? $self->SUPER::add ($self->{hslider}) |
1087 | $visible ? $self->SUPER::add ($self->{hslider}) |
1126 | : $self->SUPER::remove ($self->{hslider}); |
1088 | : $self->SUPER::remove ($self->{hslider}); |
|
|
1089 | } |
1127 | } |
1090 | } |
1128 | |
1091 | |
|
|
1092 | if ($self->{scroll_y}) { |
1129 | my ($h1, $h2) = ($child->{h}, $self->{vp}{h}); |
1093 | my ($h1, $h2) = ($child->{req_h}, $self->{vp}{h}); |
1130 | $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]); |
1131 | |
1095 | |
1132 | my $visible = $h1 > $h2; |
1096 | my $visible = $h1 > $h2; |
1133 | if ($visible != $self->{vslider}{visible}) { |
1097 | if ($visible != $self->{vslider_visible}) { |
|
|
1098 | $self->{vslider_visible} = $visible; |
1134 | $visible ? $self->SUPER::add ($self->{vslider}) |
1099 | $visible ? $self->SUPER::add ($self->{vslider}) |
1135 | : $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); |
1136 | } |
1120 | }; |
1137 | } |
|
|
1138 | |
|
|
1139 | sub update { |
|
|
1140 | my ($self) = @_; |
|
|
1141 | |
|
|
1142 | $self->update_slider; |
|
|
1143 | $self->SUPER::update; |
|
|
1144 | } |
1121 | } |
1145 | |
1122 | |
1146 | sub invoke_mouse_wheel { |
1123 | sub invoke_mouse_wheel { |
1147 | my ($self, $ev) = @_; |
1124 | my ($self, $ev) = @_; |
1148 | |
1125 | |
1149 | $self->{vslider}->emit (mouse_wheel => $ev) |
1126 | $self->{vslider}->emit (mouse_wheel => $ev) if $self->{vslider_visible}; |
1150 | if $ev->{dy}; |
|
|
1151 | |
|
|
1152 | $self->{hslider}->emit (mouse_wheel => $ev) |
1127 | $self->{hslider}->emit (mouse_wheel => $ev) if $self->{hslider_visible}; |
1153 | if $ev->{dx}; |
|
|
1154 | |
1128 | |
1155 | 1 |
1129 | 1 |
1156 | } |
1130 | } |
1157 | |
1131 | |
1158 | sub invoke_button_down { |
1132 | sub invoke_button_down { |
1159 | my ($self, $ev, $x, $y) = @_; |
1133 | my ($self, $ev, $x, $y) = @_; |
1160 | |
1134 | |
1161 | if ($ev->{button} == 2) { |
1135 | if ($ev->{button} == 2) { |
1162 | $self->grab_focus; |
1136 | $self->start_dragging ($ev); |
1163 | |
|
|
1164 | my $ox = $self->{vp}{view_x} + $ev->{x}; |
|
|
1165 | my $oy = $self->{vp}{view_y} + $ev->{y}; |
|
|
1166 | |
|
|
1167 | $self->{motion} = sub { |
|
|
1168 | my ($ev, $x, $y) = @_; |
|
|
1169 | |
|
|
1170 | $self->{vp}->set_offset ($ox - $ev->{x}, $oy - $ev->{y}); |
|
|
1171 | $self->update; |
|
|
1172 | }; |
|
|
1173 | |
|
|
1174 | return 1; |
1137 | return 1; |
1175 | } |
1138 | } |
1176 | |
1139 | |
1177 | 0 |
1140 | 0 |
1178 | } |
1141 | } |
… | |
… | |
1646 | my ($c, $w, $cs) = @$widget{qw(col req_w colspan)}; |
1609 | my ($c, $w, $cs) = @$widget{qw(col req_w colspan)}; |
1647 | |
1610 | |
1648 | my $sw = sum @w[$c .. $c + $cs - 1]; |
1611 | my $sw = sum @w[$c .. $c + $cs - 1]; |
1649 | |
1612 | |
1650 | if ($w > $sw) { |
1613 | if ($w > $sw) { |
1651 | $_ += ($w - $sw) / $cs for @w[$c .. $c + $cs - 1]; |
1614 | $_ += ($w - $sw) / ($sw ? $sw / $_ : $cs) for @w[$c .. $c + $cs - 1]; |
1652 | } |
1615 | } |
1653 | } |
1616 | } |
1654 | |
1617 | |
1655 | # second pass, rows |
1618 | # second pass, rows |
1656 | for my $widget (sort { $a->{rowspan} <=> $b->{rowspan} } @children) { |
1619 | for my $widget (sort { $a->{rowspan} <=> $b->{rowspan} } @children) { |
1657 | my ($r, $h, $rs) = @$widget{qw(row req_h rowspan)}; |
1620 | my ($r, $h, $rs) = @$widget{qw(row req_h rowspan)}; |
1658 | |
1621 | |
1659 | my $sh = sum @h[$r .. $r + $rs - 1]; |
1622 | my $sh = sum @h[$r .. $r + $rs - 1]; |
1660 | |
1623 | |
1661 | if ($h > $sh) { |
1624 | if ($h > $sh) { |
1662 | $_ += ($h - $sh) / $rs for @h[$r .. $r + $rs - 1]; |
1625 | $_ += ($h - $sh) / ($sh ? $sh / $_ : $rs) for @h[$r .. $r + $rs - 1]; |
1663 | } |
1626 | } |
1664 | } |
1627 | } |
1665 | |
1628 | |
1666 | (\@w, \@h) |
1629 | (\@w, \@h) |
1667 | } |
1630 | } |
… | |
… | |
1723 | |
1686 | |
1724 | use List::Util qw(min max); |
1687 | use List::Util qw(min max); |
1725 | |
1688 | |
1726 | our @ISA = CFPlus::UI::Container::; |
1689 | our @ISA = CFPlus::UI::Container::; |
1727 | |
1690 | |
1728 | sub add { |
1691 | sub add_fixed { |
1729 | my ($self, $child, $posmode, $x, $y, $sizemode, $w, $h) = @_; |
1692 | my ($self, $child, $posmode, $x, $y, $sizemode, $w, $h) = @_; |
1730 | |
1693 | |
1731 | $child->{_fixed} = [$posmode, $x, $y, $sizemode, $w, $h]; |
1694 | $child->{_fixed} = [$posmode, $x, $y, $sizemode, $w, $h]; |
1732 | $self->SUPER::add ($child); |
1695 | $self->SUPER::add ($child); |
1733 | } |
1696 | } |
… | |
… | |
1788 | for my $child ($self->visible_children) { |
1751 | for my $child ($self->visible_children) { |
1789 | my ($pos, $x, $y, $size, $w, $h) = @{ $child->{_fixed} }; |
1752 | my ($pos, $x, $y, $size, $w, $h) = @{ $child->{_fixed} }; |
1790 | |
1753 | |
1791 | $x = _scale $pos, $x, $W; |
1754 | $x = _scale $pos, $x, $W; |
1792 | $y = _scale $pos, $x, $H; |
1755 | $y = _scale $pos, $x, $H; |
1793 | $w = _scale $size, $w, $child->{req_w}; |
1756 | $w = _scale $size, $w, $W; |
1794 | $h = _scale $size, $h, $child->{req_h}; |
1757 | $h = _scale $size, $h, $H; |
1795 | |
1758 | |
1796 | $child->configure ($x, $y, $w, $h); |
1759 | $child->configure ($x, $y, $w, $h); |
1797 | } |
1760 | } |
1798 | |
1761 | |
1799 | 1 |
1762 | 1 |
… | |
… | |
2064 | $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y} |
2027 | $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y} |
2065 | : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y} |
2028 | : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y} |
2066 | : ($self->{h} - $size->[1]) * 0.5); |
2029 | : ($self->{h} - $size->[1]) * 0.5); |
2067 | }; |
2030 | }; |
2068 | |
2031 | |
2069 | my $w = List::Util::min $self->{w} + 4, $size->[0]; |
2032 | # unless ($self->{list}) { |
2070 | my $h = List::Util::min $self->{h} + 2, $size->[1]; |
2033 | # $self->{list} = CFPlus::OpenGL::glGenList; |
|
|
2034 | # CFPlus::OpenGL::glNewList $self->{list}; |
|
|
2035 | # $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
|
|
2036 | # CFPlus::OpenGL::glEndList; |
|
|
2037 | # } |
|
|
2038 | # |
|
|
2039 | # CFPlus::OpenGL::glCallList $self->{list}; |
2071 | |
2040 | |
2072 | $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
2041 | $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
2073 | } |
2042 | } |
|
|
2043 | |
|
|
2044 | #sub destroy { |
|
|
2045 | # my ($self) = @_; |
|
|
2046 | # |
|
|
2047 | # CFPlus::OpenGL::glDeleteList delete $self->{list} if $self->{list}; |
|
|
2048 | # |
|
|
2049 | # $self->SUPER::destroy; |
|
|
2050 | #} |
2074 | |
2051 | |
2075 | ############################################################################# |
2052 | ############################################################################# |
2076 | |
2053 | |
2077 | package CFPlus::UI::EntryBase; |
2054 | package CFPlus::UI::EntryBase; |
2078 | |
2055 | |
… | |
… | |
3476 | |
3453 | |
3477 | if ($self->{anim} && $self->{animspeed}) { |
3454 | if ($self->{anim} && $self->{animspeed}) { |
3478 | CFPlus::weaken (my $widget = $self); |
3455 | CFPlus::weaken (my $widget = $self); |
3479 | |
3456 | |
3480 | $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed}; |
3457 | $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed}; |
3481 | $widget->{anim_start} = $self->{animspeed} * Event::time / $self->{animspeed}; |
3458 | $widget->{anim_start} = $self->{animspeed} * int Event::time / $self->{animspeed}; |
3482 | $self->{timer} = Event->timer ( |
3459 | $self->{timer} = Event->timer ( |
3483 | parked => 1, |
3460 | parked => 1, |
3484 | cb => sub { |
3461 | cb => sub { |
3485 | return unless $::CONN && $widget; |
3462 | return unless $::CONN && $widget; |
3486 | |
3463 | |
… | |
… | |
3523 | |
3500 | |
3524 | if (my $anim = $::CONN->{anim}[$self->{anim}]) { |
3501 | if (my $anim = $::CONN->{anim}[$self->{anim}]) { |
3525 | if ($anim && @$anim) { |
3502 | if ($anim && @$anim) { |
3526 | delete $self->{wait_face}; |
3503 | delete $self->{wait_face}; |
3527 | $self->{face} = $anim->[ $self->{frame} % @$anim ]; |
3504 | $self->{face} = $anim->[ $self->{frame} % @$anim ]; |
|
|
3505 | $self->{tex} = $::CONN->{texture}[ $::CONN->{faceid}[$self->{face}] ]; |
3528 | } |
3506 | } |
3529 | } |
3507 | } |
3530 | } |
3508 | } |
3531 | |
3509 | |
3532 | sub size_request { |
3510 | sub size_request { |
3533 | my ($self) = @_; |
3511 | my ($self) = @_; |
3534 | |
3512 | |
3535 | if ($::CONN) { |
3513 | if ($::CONN) { |
3536 | if (my $faceid = $::CONN->{faceid}[$self->{face}]) { |
3514 | if (my $faceid = $::CONN->{faceid}[$self->{face}]) { |
3537 | if (my $tex = $::CONN->{texture}[$faceid]) { |
3515 | if (my $tex = $::CONN->{texture}[$faceid]) { |
|
|
3516 | $self->{tex} = $tex; |
3538 | return ($self->{size_w} || $tex->{w}, $self->{size_h} || $tex->{h}); |
3517 | return ($self->{size_w} || $tex->{w}, $self->{size_h} || $tex->{h}); |
3539 | } else { |
3518 | } else { |
3540 | $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub { |
3519 | $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub { |
3541 | $self->realloc; |
3520 | $self->realloc; |
3542 | }); |
3521 | }); |
… | |
… | |
3564 | } |
3543 | } |
3565 | |
3544 | |
3566 | sub _draw { |
3545 | sub _draw { |
3567 | my ($self) = @_; |
3546 | my ($self) = @_; |
3568 | |
3547 | |
3569 | return unless $::CONN; |
|
|
3570 | |
|
|
3571 | $self->SUPER::_draw; |
3548 | $self->SUPER::_draw; |
3572 | |
3549 | |
3573 | my $faceid = $::CONN->{faceid}[$self->{face}] |
3550 | if (my $tex = $self->{tex}) { |
3574 | or return; |
|
|
3575 | |
|
|
3576 | my $tex = $::CONN->{texture}[$faceid]; |
|
|
3577 | |
|
|
3578 | if ($tex) { |
|
|
3579 | glEnable GL_TEXTURE_2D; |
3551 | glEnable GL_TEXTURE_2D; |
3580 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
3552 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
3581 | glColor 0, 0, 0, 1; |
3553 | glColor 0, 0, 0, 1; |
3582 | $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
3554 | $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
3583 | glDisable GL_TEXTURE_2D; |
3555 | glDisable GL_TEXTURE_2D; |
… | |
… | |
4139 | while ($self->{refresh_hook}) { |
4111 | while ($self->{refresh_hook}) { |
4140 | $_->() |
4112 | $_->() |
4141 | for values %{delete $self->{refresh_hook}}; |
4113 | for values %{delete $self->{refresh_hook}}; |
4142 | } |
4114 | } |
4143 | |
4115 | |
4144 | if ($self->{realloc}) { |
4116 | while ($self->{realloc}) { |
4145 | my %queue; |
4117 | my %queue; |
4146 | my @queue; |
4118 | my @queue; |
4147 | my $widget; |
4119 | my $widget; |
4148 | |
4120 | |
4149 | outer: |
4121 | outer: |
… | |
… | |
4196 | } |
4168 | } |
4197 | } |
4169 | } |
4198 | |
4170 | |
4199 | delete $self->{realloc}{$widget+0}; |
4171 | delete $self->{realloc}{$widget+0}; |
4200 | } |
4172 | } |
4201 | } |
|
|
4202 | |
4173 | |
4203 | while (my $size_alloc = delete $self->{size_alloc}) { |
4174 | while (my $size_alloc = delete $self->{size_alloc}) { |
4204 | my @queue = sort { $b->{visible} <=> $a->{visible} } |
4175 | my @queue = sort { $a->{visible} <=> $b->{visible} } |
4205 | values %$size_alloc; |
4176 | values %$size_alloc; |
4206 | |
4177 | |
4207 | while () { |
4178 | while () { |
4208 | my $widget = pop @queue || last; |
4179 | my $widget = pop @queue || last; |
4209 | |
4180 | |
4210 | my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; |
4181 | my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; |
4211 | |
4182 | |
4212 | $w = 0 if $w < 0; |
|
|
4213 | $h = 0 if $h < 0; |
|
|
4214 | |
|
|
4215 | $w = max $widget->{min_w}, $w; |
4183 | $w = max $widget->{min_w}, $w; |
4216 | $h = max $widget->{min_h}, $h; |
4184 | $h = max $widget->{min_h}, $h; |
4217 | |
4185 | |
4218 | # $w = min $self->{w} - $widget->{x}, $w if $self->{w}; |
4186 | # $w = min $self->{w} - $widget->{x}, $w if $self->{w}; |
4219 | # $h = min $self->{h} - $widget->{y}, $h if $self->{h}; |
4187 | # $h = min $self->{h} - $widget->{y}, $h if $self->{h}; |
4220 | |
4188 | |
4221 | $w = min $widget->{max_w}, $w if exists $widget->{max_w}; |
4189 | $w = min $widget->{max_w}, $w if exists $widget->{max_w}; |
4222 | $h = min $widget->{max_h}, $h if exists $widget->{max_h}; |
4190 | $h = min $widget->{max_h}, $h if exists $widget->{max_h}; |
4223 | |
4191 | |
4224 | $w = int $w + 0.5; |
4192 | $w = int $w + 0.5; |
4225 | $h = int $h + 0.5; |
4193 | $h = int $h + 0.5; |
4226 | |
4194 | |
4227 | if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { |
4195 | if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { |
4228 | $widget->{old_w} = $widget->{w}; |
4196 | $widget->{old_w} = $widget->{w}; |
4229 | $widget->{old_h} = $widget->{h}; |
4197 | $widget->{old_h} = $widget->{h}; |
4230 | |
4198 | |
4231 | $widget->{w} = $w; |
4199 | $widget->{w} = $w; |
4232 | $widget->{h} = $h; |
4200 | $widget->{h} = $h; |
4233 | |
4201 | |
4234 | $widget->emit (size_allocate => $w, $h); |
4202 | $widget->emit (size_allocate => $w, $h); |
|
|
4203 | } |
4235 | } |
4204 | } |
4236 | } |
4205 | } |
4237 | } |
4206 | } |
4238 | |
4207 | |
4239 | while ($self->{post_alloc_hook}) { |
4208 | while ($self->{post_alloc_hook}) { |