… | |
… | |
646 | my ($self) = @_; |
646 | my ($self) = @_; |
647 | |
647 | |
648 | warn "no draw defined for $self\n"; |
648 | warn "no draw defined for $self\n"; |
649 | } |
649 | } |
650 | |
650 | |
651 | my $cntx;#d# |
|
|
652 | sub DESTROY { |
651 | sub DESTROY { |
653 | my ($self) = @_; |
652 | my ($self) = @_; |
654 | |
653 | |
655 | return if CFPlus::in_destruct; |
654 | return if CFPlus::in_destruct; |
656 | |
655 | |
… | |
… | |
741 | can_events => 0, |
740 | can_events => 0, |
742 | %arg, |
741 | %arg, |
743 | ); |
742 | ); |
744 | |
743 | |
745 | $self->add (@$children) |
744 | $self->add (@$children) |
746 | if $children; |
745 | if $children && @$children; |
747 | |
746 | |
748 | $self |
747 | $self |
749 | } |
748 | } |
750 | |
749 | |
751 | sub realloc { |
750 | sub realloc { |
… | |
… | |
760 | my ($self, @widgets) = @_; |
759 | my ($self, @widgets) = @_; |
761 | |
760 | |
762 | $_->set_parent ($self) |
761 | $_->set_parent ($self) |
763 | for @widgets; |
762 | for @widgets; |
764 | |
763 | |
|
|
764 | # TODO: only do this in widgets that need it, e.g. root, fixed |
765 | use sort 'stable'; |
765 | use sort 'stable'; |
766 | |
766 | |
767 | $self->{children} = [ |
767 | $self->{children} = [ |
768 | sort { $a->{z} <=> $b->{z} } |
768 | sort { $a->{z} <=> $b->{z} } |
769 | @{$self->{children}}, @widgets |
769 | @{$self->{children}}, @widgets |
770 | ]; |
770 | ]; |
771 | |
771 | |
772 | $self->realloc; |
772 | $self->realloc; |
|
|
773 | |
|
|
774 | map $_+0, @widgets |
773 | } |
775 | } |
774 | |
776 | |
775 | sub children { |
777 | sub children { |
776 | @{ $_[0]{children} } |
778 | @{ $_[0]{children} } |
777 | } |
779 | } |
… | |
… | |
788 | } |
790 | } |
789 | |
791 | |
790 | sub clear { |
792 | sub clear { |
791 | my ($self) = @_; |
793 | my ($self) = @_; |
792 | |
794 | |
793 | my $children = delete $self->{children}; |
795 | my $children = $self->{children}; |
794 | $self->{children} = []; |
796 | $self->{children} = []; |
795 | |
797 | |
796 | for (@$children) { |
798 | for (@$children) { |
797 | delete $_->{parent}; |
799 | delete $_->{parent}; |
798 | $_->hide; |
800 | $_->hide; |
… | |
… | |
1046 | my $child = delete $arg{child}; |
1048 | my $child = delete $arg{child}; |
1047 | |
1049 | |
1048 | my $self; |
1050 | my $self; |
1049 | |
1051 | |
1050 | my $hslider = new CFPlus::UI::Slider |
1052 | my $hslider = new CFPlus::UI::Slider |
|
|
1053 | col => 0, |
|
|
1054 | row => 1, |
1051 | vertical => 0, |
1055 | vertical => 0, |
1052 | range => [0, 0, 1, 0.01], # HACK fix |
1056 | range => [0, 0, 1, 0.01], # HACK fix |
1053 | on_changed => sub { |
1057 | on_changed => sub { |
1054 | $self->{hpos} = $_[1]; |
1058 | $self->{hpos} = $_[1]; |
1055 | $self->{vp}->set_offset ($self->{hpos}, $self->{vpos}); |
1059 | $self->{vp}->set_offset ($self->{hpos}, $self->{vpos}); |
1056 | }, |
1060 | }, |
1057 | ; |
1061 | ; |
1058 | |
1062 | |
1059 | my $vslider = new CFPlus::UI::Slider |
1063 | my $vslider = new CFPlus::UI::Slider |
|
|
1064 | col => 1, |
|
|
1065 | row => 0, |
1060 | vertical => 1, |
1066 | vertical => 1, |
1061 | range => [0, 0, 1, 0.01], # HACK fix |
1067 | range => [0, 0, 1, 0.01], # HACK fix |
1062 | on_changed => sub { |
1068 | on_changed => sub { |
1063 | $self->{vpos} = $_[1]; |
1069 | $self->{vpos} = $_[1]; |
1064 | $self->{vp}->set_offset ($self->{hpos}, $self->{vpos}); |
1070 | $self->{vp}->set_offset ($self->{hpos}, $self->{vpos}); |
… | |
… | |
1075 | row_expand => [1, 0], |
1081 | row_expand => [1, 0], |
1076 | %arg, |
1082 | %arg, |
1077 | ); |
1083 | ); |
1078 | |
1084 | |
1079 | $self->{vp} = new CFPlus::UI::ViewPort |
1085 | $self->{vp} = new CFPlus::UI::ViewPort |
|
|
1086 | col => 0, |
|
|
1087 | row => 0, |
1080 | expand => 1, |
1088 | expand => 1, |
1081 | scroll_x => $self->{scroll_x}, |
1089 | scroll_x => $self->{scroll_x}, |
1082 | scroll_y => $self->{scroll_y}, |
1090 | scroll_y => $self->{scroll_y}, |
1083 | on_changed => sub { |
1091 | on_changed => sub { |
1084 | my ($vp, $x, $y) = @_; |
1092 | my ($vp, $x, $y) = @_; |
… | |
… | |
1086 | $vp->{parent}{hslider}->set_value ($x); |
1094 | $vp->{parent}{hslider}->set_value ($x); |
1087 | $vp->{parent}{vslider}->set_value ($y); |
1095 | $vp->{parent}{vslider}->set_value ($y); |
1088 | |
1096 | |
1089 | 0 |
1097 | 0 |
1090 | }, |
1098 | }, |
|
|
1099 | on_size_allocate => sub { |
|
|
1100 | my ($vp, $w, $h) = @_; |
|
|
1101 | $vp->{parent}->update_slider; |
|
|
1102 | 0 |
|
|
1103 | }, |
1091 | ; |
1104 | ; |
1092 | |
1105 | |
1093 | $self->SUPER::add_at (0, 0, $self->{vp}); |
1106 | $self->SUPER::add ($self->{vp}); |
1094 | |
1107 | |
1095 | $self->add ($child) if $child; |
1108 | $self->add ($child) if $child; |
1096 | |
1109 | |
1097 | $self |
1110 | $self |
1098 | } |
1111 | } |
1099 | |
|
|
1100 | #TODO# update range on size_allocate depending on child |
|
|
1101 | |
1112 | |
1102 | sub add { |
1113 | sub add { |
1103 | my ($self, $widget) = @_; |
1114 | my ($self, $widget) = @_; |
1104 | |
1115 | |
1105 | $self->{vp}->add ($self->{child} = $widget); |
1116 | $self->{vp}->add ($self->{child} = $widget); |
… | |
… | |
1108 | sub update_slider { |
1119 | sub update_slider { |
1109 | my ($self) = @_; |
1120 | my ($self) = @_; |
1110 | |
1121 | |
1111 | my $child = ($self->{vp} or return)->child; |
1122 | my $child = ($self->{vp} or return)->child; |
1112 | |
1123 | |
|
|
1124 | if ($self->{scroll_x}) { |
1113 | my ($w1, $w2) = ($child->{w}, $self->{vp}{w}); |
1125 | my ($w1, $w2) = ($child->{req_w}, $self->{vp}{w}); |
1114 | $self->{hslider}->set_range ([$self->{hslider}{range}[0], 0, $w1, $w2, 1]); |
1126 | $self->{hslider}->set_range ([$self->{hslider}{range}[0], 0, $w1, $w2, 1]); |
1115 | |
1127 | |
1116 | my $visible = $w1 > $w2; |
1128 | my $visible = $w1 > $w2; |
1117 | if ($visible != $self->{hslider}{visible}) { |
1129 | if ($visible != $self->{hslider_visible}) { |
|
|
1130 | $self->{hslider_visible} = $visible; |
1118 | $visible ? $self->SUPER::add_at (0, 1, $self->{hslider}) |
1131 | $visible ? $self->SUPER::add ($self->{hslider}) |
1119 | : $self->{hslider}->hide; |
1132 | : $self->SUPER::remove ($self->{hslider}); |
|
|
1133 | } |
1120 | } |
1134 | } |
1121 | |
1135 | |
|
|
1136 | if ($self->{scroll_y}) { |
1122 | my ($h1, $h2) = ($child->{h}, $self->{vp}{h}); |
1137 | my ($h1, $h2) = ($child->{req_h}, $self->{vp}{h}); |
1123 | $self->{vslider}->set_range ([$self->{vslider}{range}[0], 0, $h1, $h2, 1]); |
1138 | $self->{vslider}->set_range ([$self->{vslider}{range}[0], 0, $h1, $h2, 1]); |
1124 | |
1139 | |
1125 | my $visible = $h1 > $h2; |
1140 | my $visible = $h1 > $h2; |
1126 | if ($visible != $self->{vslider}{visible}) { |
1141 | if ($visible != $self->{vslider_visible}) { |
|
|
1142 | $self->{vslider_visible} = $visible; |
1127 | $visible ? $self->SUPER::add_at (1, 0, $self->{vslider}) |
1143 | $visible ? $self->SUPER::add ($self->{vslider}) |
1128 | : $self->{vslider}->hide; |
1144 | : $self->SUPER::remove ($self->{vslider}); |
|
|
1145 | } |
|
|
1146 | } |
|
|
1147 | } |
|
|
1148 | |
|
|
1149 | sub start_dragging { |
|
|
1150 | my ($self, $ev) = @_; |
|
|
1151 | |
|
|
1152 | $self->grab_focus; |
|
|
1153 | |
|
|
1154 | my $ox = $self->{vp}{view_x}; |
|
|
1155 | my $oy = $self->{vp}{view_y}; |
|
|
1156 | |
|
|
1157 | $self->{motion} = sub { |
|
|
1158 | my ($ev, $x, $y) = @_; |
|
|
1159 | |
|
|
1160 | $ox -= $ev->{xrel}; |
|
|
1161 | $oy -= $ev->{yrel}; |
|
|
1162 | |
|
|
1163 | $self->{vp}->set_offset ($ox, $oy); |
1129 | } |
1164 | }; |
1130 | } |
|
|
1131 | |
|
|
1132 | sub update { |
|
|
1133 | my ($self) = @_; |
|
|
1134 | |
|
|
1135 | $self->update_slider; |
|
|
1136 | $self->SUPER::update; |
|
|
1137 | } |
1165 | } |
1138 | |
1166 | |
1139 | sub invoke_mouse_wheel { |
1167 | sub invoke_mouse_wheel { |
1140 | my ($self, $ev) = @_; |
1168 | my ($self, $ev) = @_; |
1141 | |
1169 | |
1142 | $self->{vslider}->emit (mouse_wheel => $ev) |
1170 | $self->{vslider}->emit (mouse_wheel => $ev) if $self->{vslider_visible}; |
1143 | if $ev->{dy}; |
|
|
1144 | |
|
|
1145 | $self->{hslider}->emit (mouse_wheel => $ev) |
1171 | $self->{hslider}->emit (mouse_wheel => $ev) if $self->{hslider_visible}; |
1146 | if $ev->{dx}; |
|
|
1147 | |
1172 | |
1148 | 1 |
1173 | 1 |
1149 | } |
1174 | } |
1150 | |
1175 | |
1151 | sub invoke_button_down { |
1176 | sub invoke_button_down { |
1152 | my ($self, $ev, $x, $y) = @_; |
1177 | my ($self, $ev, $x, $y) = @_; |
1153 | |
1178 | |
1154 | if ($ev->{button} == 2) { |
1179 | if ($ev->{button} == 2) { |
1155 | $self->grab_focus; |
1180 | $self->start_dragging ($ev); |
1156 | |
|
|
1157 | my $ox = $self->{vp}{view_x} + $ev->{x}; |
|
|
1158 | my $oy = $self->{vp}{view_y} + $ev->{y}; |
|
|
1159 | |
|
|
1160 | $self->{motion} = sub { |
|
|
1161 | my ($ev, $x, $y) = @_; |
|
|
1162 | |
|
|
1163 | $self->{vp}->set_offset ($ox - $ev->{x}, $oy - $ev->{y}); |
|
|
1164 | $self->update; |
|
|
1165 | }; |
|
|
1166 | |
|
|
1167 | return 1; |
1181 | return 1; |
1168 | } |
1182 | } |
1169 | |
1183 | |
1170 | 0 |
1184 | 0 |
1171 | } |
1185 | } |
… | |
… | |
1581 | |
1595 | |
1582 | ############################################################################# |
1596 | ############################################################################# |
1583 | |
1597 | |
1584 | package CFPlus::UI::Table; |
1598 | package CFPlus::UI::Table; |
1585 | |
1599 | |
1586 | our @ISA = CFPlus::UI::Base::; |
1600 | our @ISA = CFPlus::UI::Container::; |
1587 | |
1601 | |
1588 | use List::Util qw(max sum); |
1602 | use List::Util qw(max sum); |
1589 | |
1603 | |
1590 | use CFPlus::OpenGL; |
1604 | use CFPlus::OpenGL; |
1591 | |
1605 | |
1592 | sub new { |
1606 | sub new { |
1593 | my $class = shift; |
1607 | my $class = shift; |
1594 | |
1608 | |
1595 | $class->SUPER::new ( |
1609 | $class->SUPER::new ( |
1596 | children => [], |
|
|
1597 | col_expand => [], |
1610 | col_expand => [], |
1598 | row_expand => [], |
1611 | row_expand => [], |
1599 | @_, |
1612 | @_, |
1600 | ) |
1613 | ) |
1601 | } |
1614 | } |
1602 | |
1615 | |
1603 | sub children { |
|
|
1604 | grep $_, map @$_, grep $_, @{ $_[0]{children} } |
|
|
1605 | } |
|
|
1606 | |
|
|
1607 | # TODO: store row/col info in child widget and use standard add/del |
|
|
1608 | sub add { |
1616 | sub add { |
1609 | my $self = shift; |
1617 | my ($self, @widgets) = @_; |
1610 | |
1618 | |
1611 | Carp::cluck "please use the add_at method instead of calling add, thank you.\n";#d# |
1619 | for my $child (@widgets) { |
1612 | $self->add_at (@_); |
1620 | $child->{rowspan} ||= 1; |
|
|
1621 | $child->{colspan} ||= 1; |
|
|
1622 | } |
|
|
1623 | |
|
|
1624 | $self->SUPER::add (@widgets); |
1613 | } |
1625 | } |
1614 | |
1626 | |
1615 | sub add_at { |
1627 | sub add_at { |
1616 | my $self = shift; |
1628 | my $self = shift; |
1617 | |
1629 | |
|
|
1630 | my @widgets; |
|
|
1631 | |
1618 | while (@_) { |
1632 | while (@_) { |
1619 | my ($col, $row, $child) = splice @_, 0, 3, (); |
1633 | my ($col, $row, $child) = splice @_, 0, 3, (); |
1620 | |
1634 | |
1621 | $child->{row} = $row; |
1635 | $child->{row} = $row; |
1622 | $child->{col} = $col; |
1636 | $child->{col} = $col; |
1623 | |
1637 | |
1624 | $child->{rowspan} ||= 1; |
1638 | push @widgets, $child; |
1625 | $child->{colspan} ||= 1; |
|
|
1626 | |
|
|
1627 | $child->set_parent ($self); |
|
|
1628 | $self->{children}[$row][$col] = $child; |
|
|
1629 | } |
1639 | } |
1630 | |
1640 | |
1631 | $self->{force_realloc} = 1; |
1641 | $self->add (@widgets); |
1632 | $self->{force_size_alloc} = 1; |
|
|
1633 | $self->realloc; |
|
|
1634 | } |
1642 | } |
1635 | |
1643 | |
1636 | sub remove { |
1644 | sub get_wh { |
1637 | my ($self, $child) = @_; |
1645 | my ($self) = @_; |
1638 | |
1646 | |
1639 | for (@{ $self->{children} }) { |
1647 | my (@w, @h); |
1640 | for (@{ $_ || [] }) { |
1648 | |
1641 | $_ = undef if $_ == $child; |
1649 | my @children = $self->children; |
|
|
1650 | |
|
|
1651 | # first pass, columns |
|
|
1652 | for my $widget (sort { $a->{colspan} <=> $b->{colspan} } @children) { |
|
|
1653 | my ($c, $w, $cs) = @$widget{qw(col req_w colspan)}; |
|
|
1654 | |
|
|
1655 | my $sw = sum @w[$c .. $c + $cs - 1]; |
|
|
1656 | |
|
|
1657 | if ($w > $sw) { |
|
|
1658 | $_ += ($w - $sw) / ($sw ? $sw / $_ : $cs) for @w[$c .. $c + $cs - 1]; |
1642 | } |
1659 | } |
1643 | } |
1660 | } |
1644 | } |
|
|
1645 | |
1661 | |
1646 | # TODO: move to container class maybe? send children a signal on removal? |
1662 | # second pass, rows |
1647 | sub clear { |
1663 | for my $widget (sort { $a->{rowspan} <=> $b->{rowspan} } @children) { |
1648 | my ($self) = @_; |
|
|
1649 | |
|
|
1650 | my @children = $self->children; |
|
|
1651 | delete $self->{children}; |
|
|
1652 | |
|
|
1653 | for (@children) { |
|
|
1654 | delete $_->{parent}; |
|
|
1655 | $_->hide; |
|
|
1656 | } |
|
|
1657 | |
|
|
1658 | $self->realloc; |
|
|
1659 | } |
|
|
1660 | |
|
|
1661 | sub get_wh { |
|
|
1662 | my ($self) = @_; |
|
|
1663 | |
|
|
1664 | my (@w, @h); |
|
|
1665 | |
|
|
1666 | my @children = $self->children; |
|
|
1667 | |
|
|
1668 | for my $widget (sort { $b->{rowspan} * $b->{colspan} <=> $a->{rowspan} * $a->{colspan} } @children) { |
|
|
1669 | my ($r, $c, $w, $h, $rs, $cs) = @$widget{qw(row col req_w req_h rowspan colspan)}; |
1664 | my ($r, $h, $rs) = @$widget{qw(row req_h rowspan)}; |
1670 | |
1665 | |
1671 | my $sw = sum @w[$c .. $c + $cs - 1]; |
|
|
1672 | my $sh = sum @h[$r .. $r + $rs - 1]; |
1666 | my $sh = sum @h[$r .. $r + $rs - 1]; |
1673 | |
1667 | |
1674 | if ($w > $sw) { |
|
|
1675 | $_ += ($w - $sw) / $cs for @w[$c .. $c + $cs - 1]; |
|
|
1676 | } |
|
|
1677 | |
|
|
1678 | if ($h > $sh) { |
1668 | if ($h > $sh) { |
1679 | $_ += ($h - $sh) / $rs for @h[$r .. $r + $rs - 1]; |
1669 | $_ += ($h - $sh) / ($sh ? $sh / $_ : $rs) for @h[$r .. $r + $rs - 1]; |
1680 | } |
1670 | } |
1681 | } |
1671 | } |
1682 | |
1672 | |
1683 | (\@w, \@h) |
1673 | (\@w, \@h) |
1684 | } |
1674 | } |
… | |
… | |
1717 | |
1707 | |
1718 | $hs->[$_] += $row_expand[$_] / $row_expand * ($h - $req_h) for 0 .. $#$hs; |
1708 | $hs->[$_] += $row_expand[$_] / $row_expand * ($h - $req_h) for 0 .. $#$hs; |
1719 | |
1709 | |
1720 | CFPlus::UI::harmonize $hs; |
1710 | CFPlus::UI::harmonize $hs; |
1721 | |
1711 | |
1722 | my (@x, @y); |
|
|
1723 | |
|
|
1724 | for (0 .. $#$ws) { $x[$_ + 1] = $x[$_] + $ws->[$_] } |
1712 | my @x; for (0 .. $#$ws) { $x[$_ + 1] = $x[$_] + $ws->[$_] } |
1725 | for (0 .. $#$hs) { $y[$_ + 1] = $y[$_] + $hs->[$_] } |
1713 | my @y; for (0 .. $#$hs) { $y[$_ + 1] = $y[$_] + $hs->[$_] } |
1726 | |
1714 | |
1727 | for my $widget ($self->children) { |
1715 | for my $widget ($self->children) { |
1728 | my ($r, $c, $w, $h, $rs, $cs) = @$widget{qw(row col req_w req_h rowspan colspan)}; |
1716 | my ($r, $c, $w, $h, $rs, $cs) = @$widget{qw(row col req_w req_h rowspan colspan)}; |
1729 | |
1717 | |
1730 | $widget->configure ( |
1718 | $widget->configure ( |
… | |
… | |
1734 | } |
1722 | } |
1735 | |
1723 | |
1736 | 1 |
1724 | 1 |
1737 | } |
1725 | } |
1738 | |
1726 | |
1739 | sub find_widget { |
|
|
1740 | my ($self, $x, $y) = @_; |
|
|
1741 | |
|
|
1742 | $x -= $self->{x}; |
|
|
1743 | $y -= $self->{y}; |
|
|
1744 | |
|
|
1745 | my $res; |
|
|
1746 | |
|
|
1747 | for (grep $_, map @$_, grep $_, @{ $self->{children} }) { |
|
|
1748 | $res = $_->find_widget ($x, $y) |
|
|
1749 | and return $res; |
|
|
1750 | } |
|
|
1751 | |
|
|
1752 | $self->SUPER::find_widget ($x + $self->{x}, $y + $self->{y}) |
|
|
1753 | } |
|
|
1754 | |
|
|
1755 | sub _draw { |
|
|
1756 | my ($self) = @_; |
|
|
1757 | |
|
|
1758 | for (grep $_, @{$self->{children}}) { |
|
|
1759 | $_->draw for grep $_, @$_; |
|
|
1760 | } |
|
|
1761 | } |
|
|
1762 | |
|
|
1763 | ############################################################################# |
1727 | ############################################################################# |
1764 | |
1728 | |
1765 | package CFPlus::UI::Fixed; |
1729 | package CFPlus::UI::Fixed; |
1766 | |
1730 | |
1767 | use List::Util qw(min max); |
1731 | use List::Util qw(min max); |
1768 | |
1732 | |
1769 | our @ISA = CFPlus::UI::Container::; |
1733 | our @ISA = CFPlus::UI::Container::; |
1770 | |
1734 | |
1771 | sub add { |
1735 | sub add_fixed { |
1772 | my ($self, $child, $posmode, $x, $y, $sizemode, $w, $h) = @_; |
1736 | my ($self, $child, $posmode, $x, $y, $sizemode, $w, $h) = @_; |
1773 | |
1737 | |
1774 | $child->{_fixed} = [$posmode, $x, $y, $sizemode, $w, $h]; |
1738 | $child->{_fixed} = [$posmode, $x, $y, $sizemode, $w, $h]; |
1775 | $self->SUPER::add ($child); |
1739 | $self->SUPER::add ($child); |
1776 | } |
1740 | } |
… | |
… | |
4182 | while ($self->{refresh_hook}) { |
4146 | while ($self->{refresh_hook}) { |
4183 | $_->() |
4147 | $_->() |
4184 | for values %{delete $self->{refresh_hook}}; |
4148 | for values %{delete $self->{refresh_hook}}; |
4185 | } |
4149 | } |
4186 | |
4150 | |
4187 | if ($self->{realloc}) { |
4151 | while ($self->{realloc}) { |
4188 | my %queue; |
4152 | my %queue; |
4189 | my @queue; |
4153 | my @queue; |
4190 | my $widget; |
4154 | my $widget; |
4191 | |
4155 | |
4192 | outer: |
4156 | outer: |
… | |
… | |
4239 | } |
4203 | } |
4240 | } |
4204 | } |
4241 | |
4205 | |
4242 | delete $self->{realloc}{$widget+0}; |
4206 | delete $self->{realloc}{$widget+0}; |
4243 | } |
4207 | } |
4244 | } |
|
|
4245 | |
4208 | |
4246 | while (my $size_alloc = delete $self->{size_alloc}) { |
4209 | while (my $size_alloc = delete $self->{size_alloc}) { |
4247 | my @queue = sort { $b->{visible} <=> $a->{visible} } |
4210 | my @queue = sort { $a->{visible} <=> $b->{visible} } |
4248 | values %$size_alloc; |
4211 | values %$size_alloc; |
4249 | |
4212 | |
4250 | while () { |
4213 | while () { |
4251 | my $widget = pop @queue || last; |
4214 | my $widget = pop @queue || last; |
4252 | |
4215 | |
4253 | my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; |
4216 | my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; |
4254 | |
4217 | |
4255 | $w = 0 if $w < 0; |
|
|
4256 | $h = 0 if $h < 0; |
|
|
4257 | |
|
|
4258 | $w = max $widget->{min_w}, $w; |
4218 | $w = max $widget->{min_w}, $w; |
4259 | $h = max $widget->{min_h}, $h; |
4219 | $h = max $widget->{min_h}, $h; |
4260 | |
4220 | |
4261 | # $w = min $self->{w} - $widget->{x}, $w if $self->{w}; |
4221 | # $w = min $self->{w} - $widget->{x}, $w if $self->{w}; |
4262 | # $h = min $self->{h} - $widget->{y}, $h if $self->{h}; |
4222 | # $h = min $self->{h} - $widget->{y}, $h if $self->{h}; |
4263 | |
4223 | |
4264 | $w = min $widget->{max_w}, $w if exists $widget->{max_w}; |
4224 | $w = min $widget->{max_w}, $w if exists $widget->{max_w}; |
4265 | $h = min $widget->{max_h}, $h if exists $widget->{max_h}; |
4225 | $h = min $widget->{max_h}, $h if exists $widget->{max_h}; |
4266 | |
4226 | |
4267 | $w = int $w + 0.5; |
4227 | $w = int $w + 0.5; |
4268 | $h = int $h + 0.5; |
4228 | $h = int $h + 0.5; |
4269 | |
4229 | |
4270 | if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { |
4230 | if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { |
4271 | $widget->{old_w} = $widget->{w}; |
4231 | $widget->{old_w} = $widget->{w}; |
4272 | $widget->{old_h} = $widget->{h}; |
4232 | $widget->{old_h} = $widget->{h}; |
4273 | |
4233 | |
4274 | $widget->{w} = $w; |
4234 | $widget->{w} = $w; |
4275 | $widget->{h} = $h; |
4235 | $widget->{h} = $h; |
4276 | |
4236 | |
4277 | $widget->emit (size_allocate => $w, $h); |
4237 | $widget->emit (size_allocate => $w, $h); |
|
|
4238 | } |
4278 | } |
4239 | } |
4279 | } |
4240 | } |
4280 | } |
4241 | } |
4281 | |
4242 | |
4282 | while ($self->{post_alloc_hook}) { |
4243 | while ($self->{post_alloc_hook}) { |