ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.371 by root, Sun Jul 15 22:07:48 2007 UTC vs.
Revision 1.413 by root, Mon Jul 23 15:30:45 2007 UTC

113 } 113 }
114 114
115 if ($GRAB) { 115 if ($GRAB) {
116 if ($ev->{button} == 4 || $ev->{button} == 5) { 116 if ($ev->{button} == 4 || $ev->{button} == 5) {
117 # mousewheel 117 # mousewheel
118 $ev->{dx} = 0;
119 $ev->{dy} = $ev->{button} * 2 - 9; 118 my $delta = $ev->{button} * 2 - 9;
119 my $shift = $ev->{mod} & CFPlus::KMOD_SHIFT;
120
121 $ev->{dx} = $shift ? $delta : 0;
122 $ev->{dy} = $shift ? 0 : $delta;
123
120 $GRAB->emit (mouse_wheel => $ev); 124 $GRAB->emit (mouse_wheel => $ev);
121 } else { 125 } else {
122 $GRAB->emit (button_down => $ev) 126 $GRAB->emit (button_down => $ev)
123 } 127 }
124 } 128 }
547 551
548 # parent 552 # parent
549 $self->{parent} && $self->{parent}->emit ($signal, @args) 553 $self->{parent} && $self->{parent}->emit ($signal, @args)
550} 554}
551 555
552sub find_widget { 556#sub find_widget {
553 my ($self, $x, $y) = @_; 557# in .xs
554
555 return () unless $self->{can_events};
556
557 return $self
558 if $x >= $self->{x} && $x < $self->{x} + $self->{w}
559 && $y >= $self->{y} && $y < $self->{y} + $self->{h};
560
561 ()
562}
563 558
564sub set_parent { 559sub set_parent {
565 my ($self, $parent) = @_; 560 my ($self, $parent) = @_;
566 561
567 CFPlus::weaken ($self->{parent} = $parent); 562 CFPlus::weaken ($self->{parent} = $parent);
598 593
599# 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
600# functions seems pointless. 595# functions seems pointless.
601our ($draw_x, $draw_y, $draw_w, $draw_h); # screen rectangle being drawn 596our ($draw_x, $draw_y, $draw_w, $draw_h); # screen rectangle being drawn
602 597
603sub draw { 598#sub draw {
604 my ($self) = @_; 599#CFPlus.xs
605
606 return unless $self->{h} && $self->{w};
607
608 # update screen rectangle
609 local $draw_x = $draw_x + $self->{x};
610 local $draw_y = $draw_y + $self->{y};
611
612 # skip widgets that are entirely outside the drawing area
613 return if ($draw_x + $self->{w} < 0) || ($draw_x >= $draw_w)
614 || ($draw_y + $self->{h} < 0) || ($draw_y >= $draw_h);
615
616 glPushMatrix;
617 glTranslate $self->{x}, $self->{y}, 0;
618
619 if ($self == $HOVER && $self->{can_hover}) {
620 glColor 1*0.2, 0.8*0.2, 0.5*0.2, 0.2;
621 glEnable GL_BLEND;
622 glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA;
623 glBegin GL_QUADS;
624 glVertex 0 , 0;
625 glVertex $self->{w}, 0;
626 glVertex $self->{w}, $self->{h};
627 glVertex 0 , $self->{h};
628 glEnd;
629 glDisable GL_BLEND;
630 }
631
632 if ($ENV{CFPLUS_DEBUG} & 1) {
633 glPushMatrix;
634 glColor 1, 1, 0, 1;
635 glTranslate 0.375, 0.375;
636 glBegin GL_LINE_LOOP;
637 glVertex 0 , 0;
638 glVertex $self->{w} - 1, 0;
639 glVertex $self->{w} - 1, $self->{h} - 1;
640 glVertex 0 , $self->{h} - 1;
641 glEnd;
642 glPopMatrix;
643 #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw;
644 }
645
646 $self->_draw;
647 glPopMatrix;
648}
649 600
650sub _draw { 601sub _draw {
651 my ($self) = @_; 602 my ($self) = @_;
652 603
653 warn "no draw defined for $self\n"; 604 warn "no draw defined for $self\n";
654} 605}
655 606
656my $cntx;#d#
657sub DESTROY { 607sub DESTROY {
658 my ($self) = @_; 608 my ($self) = @_;
659 609
660 return if CFPlus::in_destruct; 610 return if CFPlus::in_destruct;
661 611
746 can_events => 0, 696 can_events => 0,
747 %arg, 697 %arg,
748 ); 698 );
749 699
750 $self->add (@$children) 700 $self->add (@$children)
751 if $children; 701 if $children && @$children;
752 702
753 $self 703 $self
754} 704}
755 705
756sub realloc { 706sub realloc {
765 my ($self, @widgets) = @_; 715 my ($self, @widgets) = @_;
766 716
767 $_->set_parent ($self) 717 $_->set_parent ($self)
768 for @widgets; 718 for @widgets;
769 719
720 # TODO: only do this in widgets that need it, e.g. root, fixed
770 use sort 'stable'; 721 use sort 'stable';
771 722
772 $self->{children} = [ 723 $self->{children} = [
773 sort { $a->{z} <=> $b->{z} } 724 sort { $a->{z} <=> $b->{z} }
774 @{$self->{children}}, @widgets 725 @{$self->{children}}, @widgets
775 ]; 726 ];
776 727
777 $self->realloc; 728 $self->realloc;
729
730 $self->emit (c_add => \@widgets);
731
732 map $_+0, @widgets
778} 733}
779 734
780sub children { 735sub children {
781 @{ $_[0]{children} } 736 @{ $_[0]{children} }
782} 737}
783 738
784sub remove { 739sub remove {
785 my ($self, $child) = @_; 740 my ($self, @widgets) = @_;
786 741
742 $self->emit (c_remove => \@widgets);
743
744 for my $child (@widgets) {
787 delete $child->{parent}; 745 delete $child->{parent};
788 $child->hide; 746 $child->hide;
789
790 $self->{children} = [ grep $_ != $child, @{ $self->{children} } ]; 747 $self->{children} = [ grep $_ != $child, @{ $self->{children} } ];
748 }
791 749
792 $self->realloc; 750 $self->realloc;
793} 751}
794 752
795sub clear { 753sub clear {
796 my ($self) = @_; 754 my ($self) = @_;
797 755
798 my $children = delete $self->{children}; 756 my $children = $self->{children};
799 $self->{children} = []; 757 $self->{children} = [];
800 758
801 for (@$children) { 759 for (@$children) {
802 delete $_->{parent}; 760 delete $_->{parent};
803 $_->hide; 761 $_->hide;
823} 781}
824 782
825sub _draw { 783sub _draw {
826 my ($self) = @_; 784 my ($self) = @_;
827 785
828 $_->draw for @{$self->{children}}; 786 $_->draw for $self->visible_children;
829} 787}
830 788
831############################################################################# 789#############################################################################
832 790
833package CFPlus::UI::Bin; 791package CFPlus::UI::Bin;
843} 801}
844 802
845sub add { 803sub add {
846 my ($self, $child) = @_; 804 my ($self, $child) = @_;
847 805
848 $self->SUPER::remove ($_) for @{ $self->{children} }; 806 $self->clear;
849 $self->SUPER::add ($child); 807 $self->SUPER::add ($child);
850} 808}
851 809
852sub remove { 810sub remove {
853 my ($self, $widget) = @_; 811 my ($self, $widget) = @_;
943} 901}
944 902
945############################################################################# 903#############################################################################
946 904
947package CFPlus::UI::ViewPort; 905package CFPlus::UI::ViewPort;
906
907use List::Util qw(min max);
948 908
949our @ISA = CFPlus::UI::Window::; 909our @ISA = CFPlus::UI::Window::;
950 910
951sub new { 911sub new {
952 my $class = shift; 912 my $class = shift;
961sub size_request { 921sub size_request {
962 my ($self) = @_; 922 my ($self) = @_;
963 923
964 my ($w, $h) = @{$self->child}{qw(req_w req_h)}; 924 my ($w, $h) = @{$self->child}{qw(req_w req_h)};
965 925
966 $w = 10 if $self->{scroll_x}; 926 $w = 1 if $self->{scroll_x};
967 $h = 10 if $self->{scroll_y}; 927 $h = 1 if $self->{scroll_y};
968 928
969 ($w, $h) 929 ($w, $h)
970} 930}
971 931
972sub invoke_size_allocate { 932sub invoke_size_allocate {
984} 944}
985 945
986sub set_offset { 946sub set_offset {
987 my ($self, $x, $y) = @_; 947 my ($self, $x, $y) = @_;
988 948
949 my $x = max 0, min $self->child->{w} - $self->{w}, int $x;
950 my $y = max 0, min $self->child->{h} - $self->{h}, int $y;
951
952 if ($x != $self->{view_x} or $y != $self->{view_y}) {
989 $self->{view_x} = int $x; 953 $self->{view_x} = $x;
990 $self->{view_y} = int $y; 954 $self->{view_y} = $y;
991 955
956 $self->emit (changed => $x, $y);
992 $self->update; 957 $self->update;
958 }
993} 959}
994 960
995# hmm, this does not work for topleft of $self... but we should not ask for that 961# hmm, this does not work for topleft of $self... but we should not ask for that
996sub coord2local { 962sub coord2local {
997 my ($self, $x, $y) = @_; 963 my ($self, $x, $y) = @_;
1012 my ($self, $x, $y) = @_; 978 my ($self, $x, $y) = @_;
1013 979
1014 if ( $x >= $self->{x} && $x < $self->{x} + $self->{w} 980 if ( $x >= $self->{x} && $x < $self->{x} + $self->{w}
1015 && $y >= $self->{y} && $y < $self->{y} + $self->{h} 981 && $y >= $self->{y} && $y < $self->{y} + $self->{h}
1016 ) { 982 ) {
1017 $self->child->find_widget ($x + $self->{view_x}, $y + $self->{view_y}) 983 $self->child->find_widget ($x + $self->{view_x}, $y + $self->{view_y})
1018 } else { 984 } else {
1019 $self->CFPlus::UI::Base::find_widget ($x, $y) 985 $self->CFPlus::UI::Base::find_widget ($x, $y)
1020 } 986 }
1021} 987}
1022 988
1043 my $child = delete $arg{child}; 1009 my $child = delete $arg{child};
1044 1010
1045 my $self; 1011 my $self;
1046 1012
1047 my $hslider = new CFPlus::UI::Slider 1013 my $hslider = new CFPlus::UI::Slider
1014 col => 0,
1015 row => 1,
1048 vertical => 0, 1016 vertical => 0,
1049 range => [0, 0, 1, 0.01], # HACK fix 1017 range => [0, 0, 1, 0.01], # HACK fix
1050 on_changed => sub { 1018 on_changed => sub {
1051 $self->{hpos} = $_[1]; 1019 $self->{hpos} = $_[1];
1052 $self->{vp}->set_offset ($self->{hpos}, $self->{vpos}); 1020 $self->{vp}->set_offset ($self->{hpos}, $self->{vpos});
1053 }, 1021 },
1054 ; 1022 ;
1055 1023
1056 my $vslider = new CFPlus::UI::Slider 1024 my $vslider = new CFPlus::UI::Slider
1025 col => 1,
1026 row => 0,
1057 vertical => 1, 1027 vertical => 1,
1058 range => [0, 0, 1, 0.01], # HACK fix 1028 range => [0, 0, 1, 0.01], # HACK fix
1059 on_changed => sub { 1029 on_changed => sub {
1060 $self->{vpos} = $_[1]; 1030 $self->{vpos} = $_[1];
1061 $self->{vp}->set_offset ($self->{hpos}, $self->{vpos}); 1031 $self->{vp}->set_offset ($self->{hpos}, $self->{vpos});
1062 }, 1032 },
1063 ; 1033 ;
1064 1034
1065 $self = $class->SUPER::new ( 1035 $self = $class->SUPER::new (
1066 vp => (new CFPlus::UI::ViewPort expand => 1), 1036 scroll_x => 0,
1037 scroll_y => 1,
1067 can_events => 1, 1038 can_events => 1,
1068 hslider => $hslider, 1039 hslider => $hslider,
1069 vslider => $vslider, 1040 vslider => $vslider,
1070 col_expand => [1, 0], 1041 col_expand => [1, 0],
1071 row_expand => [1, 0], 1042 row_expand => [1, 0],
1072 %arg, 1043 %arg,
1073 ); 1044 );
1074 1045
1046 $self->{vp} = new CFPlus::UI::ViewPort
1047 col => 0,
1048 row => 0,
1049 expand => 1,
1050 scroll_x => $self->{scroll_x},
1051 scroll_y => $self->{scroll_y},
1052 on_changed => sub {
1053 my ($vp, $x, $y) = @_;
1054
1055 $vp->{parent}{hslider}->set_value ($x);
1056 $vp->{parent}{vslider}->set_value ($y);
1057
1058 0
1059 },
1060 on_size_allocate => sub {
1061 my ($vp, $w, $h) = @_;
1062 $vp->{parent}->update_slider;
1063 0
1064 },
1065 ;
1066
1075 $self->SUPER::add (0, 0, $self->{vp}); 1067 $self->SUPER::add ($self->{vp});
1076 $self->SUPER::add (1, 0, $self->{vslider});
1077 $self->SUPER::add (0, 1, $self->{hslider});
1078 1068
1079 $self->add ($child) if $child; 1069 $self->add ($child) if $child;
1080 1070
1081 $self 1071 $self
1082} 1072}
1083
1084#TODO# update range on size_allocate depending on child
1085 1073
1086sub add { 1074sub add {
1087 my ($self, $widget) = @_; 1075 my ($self, $widget) = @_;
1088 1076
1089 $self->{vp}->add ($self->{child} = $widget); 1077 $self->{vp}->add ($self->{child} = $widget);
1090} 1078}
1091 1079
1080sub update_slider {
1081 my ($self) = @_;
1082
1083 my $child = ($self->{vp} or return)->child;
1084
1085 if ($self->{scroll_x}) {
1086 my ($w1, $w2) = ($child->{req_w}, $self->{vp}{w});
1087 $self->{hslider}->set_range ([$self->{hslider}{range}[0], 0, $w1, $w2, 1]);
1088
1089 my $visible = $w1 > $w2;
1090 if ($visible != $self->{hslider_visible}) {
1091 $self->{hslider_visible} = $visible;
1092 $visible ? $self->SUPER::add ($self->{hslider})
1093 : $self->SUPER::remove ($self->{hslider});
1094 }
1095 }
1096
1097 if ($self->{scroll_y}) {
1098 my ($h1, $h2) = ($child->{req_h}, $self->{vp}{h});
1099 $self->{vslider}->set_range ([$self->{vslider}{range}[0], 0, $h1, $h2, 1]);
1100
1101 my $visible = $h1 > $h2;
1102 if ($visible != $self->{vslider_visible}) {
1103 $self->{vslider_visible} = $visible;
1104 $visible ? $self->SUPER::add ($self->{vslider})
1105 : $self->SUPER::remove ($self->{vslider});
1106 }
1107 }
1108}
1109
1110sub start_dragging {
1111 my ($self, $ev) = @_;
1112
1113 $self->grab_focus;
1114
1115 my $ox = $self->{vp}{view_x};
1116 my $oy = $self->{vp}{view_y};
1117
1118 $self->{motion} = sub {
1119 my ($ev, $x, $y) = @_;
1120
1121 $ox -= $ev->{xrel};
1122 $oy -= $ev->{yrel};
1123
1124 $self->{vp}->set_offset ($ox, $oy);
1125 };
1126}
1127
1092sub invoke_mouse_wheel { 1128sub invoke_mouse_wheel {
1093 my ($self, $ev) = @_; 1129 my ($self, $ev) = @_;
1094 1130
1095 return 0 unless $ev->{dy}; # only vertical movements
1096
1097 $self->{vslider}->emit (mouse_wheel => $ev); 1131 $self->{vslider}->emit (mouse_wheel => $ev) if $self->{vslider_visible};
1132 $self->{hslider}->emit (mouse_wheel => $ev) if $self->{hslider_visible};
1098 1133
1099 1 1134 1
1100} 1135}
1101 1136
1102sub update_slider { 1137sub invoke_button_down {
1103 my ($self) = @_; 1138 my ($self, $ev, $x, $y) = @_;
1104 1139
1105 my $child = ($self->{vp} or return)->child; 1140 if ($ev->{button} == 2) {
1141 $self->start_dragging ($ev);
1142 return 1;
1143 }
1106 1144
1107 my ($w1, $w2) = ($child->{w}, $self->{vp}{w}); 1145 0
1108 $self->{hslider}->set_range ([$self->{hslider}{range}[0], 0, $w1, $w2, 1]);
1109 #$self->{hslider}->set_visibility ($w1 != $w2);
1110
1111 my ($h1, $h2) = ($child->{h}, $self->{vp}{h});
1112 $self->{vslider}->set_range ([$self->{vslider}{range}[0], 0, $h1, $h2, 1]);
1113 #$self->{vslider}->set_visibility ($h1 != $h2);
1114} 1146}
1115 1147
1116sub update { 1148sub invoke_button_up {
1117 my ($self) = @_; 1149 my ($self, $ev, $x, $y) = @_;
1118 1150
1119 $self->SUPER::update; 1151 if (delete $self->{motion}) {
1120 $self->update_slider; 1152 return 1;
1153 }
1154
1155 0
1156}
1157
1158sub invoke_mouse_motion {
1159 my ($self, $ev, $x, $y) = @_;
1160
1161 if ($self->{motion}) {
1162 $self->{motion}->($ev, $x, $y);
1163 return 1;
1164 }
1165
1166 0
1121} 1167}
1122 1168
1123sub invoke_size_allocate { 1169sub invoke_size_allocate {
1124 my ($self, $w, $h) = @_; 1170 my ($self, $w, $h) = @_;
1125 1171
1281 1327
1282my @border = 1328my @border =
1283 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 1329 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 }
1284 qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); 1330 qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png);
1285 1331
1332my @icon =
1333 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 }
1334 qw(x1_move.png x1_resize.png);
1335
1286sub new { 1336sub new {
1287 my ($class, %arg) = @_; 1337 my ($class, %arg) = @_;
1288 1338
1289 my $self = $class->SUPER::new ( 1339 my $self = $class->SUPER::new (
1290 bg => [1, 1, 1, 1], 1340 bg => [1, 1, 1, 1],
1458 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 1508 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
1459 1509
1460 my $border = $self->border; 1510 my $border = $self->border;
1461 1511
1462 glColor @{ $self->{border_bg} }; 1512 glColor @{ $self->{border_bg} };
1463 $border[0]->draw_quad_alpha (0, 0, $w, $border); 1513 $border[0]->draw_quad_alpha ( 0, 0, $w, $border);
1464 $border[1]->draw_quad_alpha (0, $border, $border, $ch); 1514 $border[1]->draw_quad_alpha ( 0, $border, $border, $ch);
1465 $border[2]->draw_quad_alpha ($w - $border, $border, $border, $ch); 1515 $border[2]->draw_quad_alpha ($w - $border, $border, $border, $ch);
1466 $border[3]->draw_quad_alpha (0, $h - $border, $w, $border); 1516 $border[3]->draw_quad_alpha ( 0, $h - $border, $w, $border);
1517
1518 # move
1519 my $w2 = ($w - $border) * .5;
1520 my $h2 = ($h - $border) * .5;
1521 $icon[0]->draw_quad_alpha ( 0, $h2, $border, $border);
1522 $icon[0]->draw_quad_alpha ($w - $border, $h2, $border, $border);
1523 $icon[0]->draw_quad_alpha ($w2 , $h - $border, $border, $border);
1524
1525 # resize
1526 $icon[1]->draw_quad_alpha ( 0, 0, $border, $border);
1527 $icon[1]->draw_quad_alpha ($w - $border, 0, $border, $border)
1528 unless $self->{has_close_button};
1529 $icon[1]->draw_quad_alpha ( 0, $h - $border, $border, $border);
1530 $icon[1]->draw_quad_alpha ($w - $border, $h - $border, $border, $border);
1467 1531
1468 if (@{$self->{bg}} < 4 || $self->{bg}[3]) { 1532 if (@{$self->{bg}} < 4 || $self->{bg}[3]) {
1469 glColor @{ $self->{bg} }; 1533 glColor @{ $self->{bg} };
1470 1534
1471 # TODO: repeat texture not scale 1535 # TODO: repeat texture not scale
1492 1556
1493############################################################################# 1557#############################################################################
1494 1558
1495package CFPlus::UI::Table; 1559package CFPlus::UI::Table;
1496 1560
1497our @ISA = CFPlus::UI::Base::; 1561our @ISA = CFPlus::UI::Container::;
1498 1562
1499use List::Util qw(max sum); 1563use List::Util qw(max sum);
1500 1564
1501use CFPlus::OpenGL; 1565use CFPlus::OpenGL;
1502 1566
1508 row_expand => [], 1572 row_expand => [],
1509 @_, 1573 @_,
1510 ) 1574 )
1511} 1575}
1512 1576
1513sub children {
1514 grep $_, map @$_, grep $_, @{ $_[0]{children} }
1515}
1516
1517sub add { 1577sub add {
1578 my ($self, @widgets) = @_;
1579
1580 for my $child (@widgets) {
1581 $child->{rowspan} ||= 1;
1582 $child->{colspan} ||= 1;
1583 }
1584
1585 $self->SUPER::add (@widgets);
1586}
1587
1588sub add_at {
1518 my ($self) = shift; 1589 my $self = shift;
1590
1591 my @widgets;
1519 1592
1520 while (@_) { 1593 while (@_) {
1521 my ($x, $y, $child) = splice @_, 0, 3, (); 1594 my ($col, $row, $child) = splice @_, 0, 3, ();
1522 $child->set_parent ($self);
1523 $self->{children}[$y][$x] = $child;
1524 }
1525 1595
1526 $self->{force_realloc} = 1; 1596 $child->{row} = $row;
1527 $self->{force_size_alloc} = 1; 1597 $child->{col} = $col;
1528 $self->realloc;
1529}
1530 1598
1531sub remove { 1599 push @widgets, $child;
1600 }
1601
1602 $self->add (@widgets);
1603}
1604
1605sub get_wh {
1532 my ($self, $child) = @_; 1606 my ($self) = @_;
1533 1607
1534 # TODO: not yet implemented 1608 my (@w, @h);
1535}
1536
1537# TODO: move to container class maybe? send children a signal on removal?
1538sub clear {
1539 my ($self) = @_;
1540 1609
1541 my @children = $self->children; 1610 my @children = $self->children;
1542 delete $self->{children}; 1611
1612 # first pass, columns
1613 for my $widget (sort { $a->{colspan} <=> $b->{colspan} } @children) {
1614 my ($c, $w, $cs) = @$widget{qw(col req_w colspan)};
1615
1616 my $sw = sum @w[$c .. $c + $cs - 1];
1617
1618 if ($w > $sw) {
1619 $_ += ($w - $sw) / ($sw ? $sw / $_ : $cs) for @w[$c .. $c + $cs - 1];
1620 }
1543 1621 }
1544 for (@children) {
1545 delete $_->{parent};
1546 $_->hide;
1547 }
1548 1622
1549 $self->realloc; 1623 # second pass, rows
1550} 1624 for my $widget (sort { $a->{rowspan} <=> $b->{rowspan} } @children) {
1551
1552sub get_wh {
1553 my ($self) = @_;
1554
1555 my (@w, @h);
1556
1557 for my $y (0 .. $#{$self->{children}}) {
1558 my $row = $self->{children}[$y]
1559 or next;
1560
1561 for my $x (0 .. $#$row) {
1562 my $widget = $row->[$x]
1563 or next;
1564 my ($w, $h) = @$widget{qw(req_w req_h)}; 1625 my ($r, $h, $rs) = @$widget{qw(row req_h rowspan)};
1565 1626
1566 $w[$x] = max $w[$x], $w; 1627 my $sh = sum @h[$r .. $r + $rs - 1];
1567 $h[$y] = max $h[$y], $h; 1628
1629 if ($h > $sh) {
1630 $_ += ($h - $sh) / ($sh ? $sh / $_ : $rs) for @h[$r .. $r + $rs - 1];
1568 } 1631 }
1569 } 1632 }
1570 1633
1571 (\@w, \@h) 1634 (\@w, \@h)
1572} 1635}
1588 my ($ws, $hs) = $self->get_wh; 1651 my ($ws, $hs) = $self->get_wh;
1589 1652
1590 my $req_w = (sum @$ws) || 1; 1653 my $req_w = (sum @$ws) || 1;
1591 my $req_h = (sum @$hs) || 1; 1654 my $req_h = (sum @$hs) || 1;
1592 1655
1593 # TODO: nicer code 1656 # now linearly scale the rows/columns to the allocated size
1594 my @col_expand = @{$self->{col_expand}}; 1657 my @col_expand = @{$self->{col_expand}};
1595 @col_expand = (1) x @$ws unless @col_expand; 1658 @col_expand = (1) x @$ws unless @col_expand;
1596 my $col_expand = (sum @col_expand) || 1; 1659 my $col_expand = (sum @col_expand) || 1;
1597 1660
1598 $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws; 1661 $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws;
1605 1668
1606 $hs->[$_] += $row_expand[$_] / $row_expand * ($h - $req_h) for 0 .. $#$hs; 1669 $hs->[$_] += $row_expand[$_] / $row_expand * ($h - $req_h) for 0 .. $#$hs;
1607 1670
1608 CFPlus::UI::harmonize $hs; 1671 CFPlus::UI::harmonize $hs;
1609 1672
1610 my $y; 1673 my @x; for (0 .. $#$ws) { $x[$_ + 1] = $x[$_] + $ws->[$_] }
1674 my @y; for (0 .. $#$hs) { $y[$_ + 1] = $y[$_] + $hs->[$_] }
1611 1675
1612 for my $r (0 .. $#{$self->{children}}) { 1676 for my $widget ($self->children) {
1613 my $row = $self->{children}[$r] 1677 my ($r, $c, $w, $h, $rs, $cs) = @$widget{qw(row col req_w req_h rowspan colspan)};
1614 or next;
1615 1678
1616 my $x = 0; 1679 $widget->configure (
1617 my $row_h = $hs->[$r]; 1680 $x[$c], $y[$r],
1681 $x[$c + $cs] - $x[$c], $y[$r + $rs] - $y[$r],
1618 1682 );
1619 for my $c (0 .. $#$row) { 1683 }
1620 my $col_w = $ws->[$c];
1621 1684
1622 if (my $widget = $row->[$c]) { 1685 1
1623 $widget->configure ($x, $y, $col_w, $row_h); 1686}
1624 }
1625 1687
1626 $x += $col_w; 1688#############################################################################
1689
1690package CFPlus::UI::Fixed;
1691
1692use List::Util qw(min max);
1693
1694our @ISA = CFPlus::UI::Container::;
1695
1696sub _scale($$$) {
1697 my ($rel, $val, $max) = @_;
1698
1699 $rel ? $val * $max : $val
1700}
1701
1702sub size_request {
1703 my ($self) = @_;
1704
1705 my ($x1, $y1, $x2, $y2) = (0, 0, 0, 0);
1706
1707 # determine overall size by querying abs widgets
1708 for my $child ($self->visible_children) {
1709 unless ($child->{c_rel}) {
1710 my $x = $child->{c_x};
1711 my $y = $child->{c_y};
1712
1713 $x1 = min $x1, $x; $x2 = max $x2, $x + $child->{req_w};
1714 $y1 = min $y1, $y; $y2 = max $y2, $y + $child->{req_h};
1627 } 1715 }
1716 }
1628 1717
1629 $y += $row_h; 1718 my $W = $x2 - $x1;
1719 my $H = $y2 - $y1;
1720
1721 # now layout remaining widgets
1722 for my $child ($self->visible_children) {
1723 if ($child->{c_rel}) {
1724 my $x = _scale $child->{c_rel}, $child->{c_x}, $W;
1725 my $y = _scale $child->{c_rel}, $child->{c_y}, $H;
1726
1727 $x1 = min $x1, $x; $x2 = max $x2, $x + $child->{req_w};
1728 $y1 = min $y1, $y; $y2 = max $y2, $y + $child->{req_h};
1729 }
1730 }
1731
1732 my $W = $x2 - $x1;
1733 my $H = $y2 - $y1;
1734
1735 ($W, $H)
1736}
1737
1738sub invoke_size_allocate {
1739 my ($self, $W, $H) = @_;
1740
1741 for my $child ($self->visible_children) {
1742 my $x = _scale $child->{c_rel}, $child->{c_x}, $W;
1743 my $y = _scale $child->{c_rel}, $child->{c_y}, $H;
1744
1745 $x += $child->{c_halign} * $child->{req_w};
1746 $y += $child->{c_valign} * $child->{req_h};
1747
1748 $child->configure (int $x, int $y, $child->{req_w}, $child->{req_h});
1630 } 1749 }
1631 1750
1632 1 1751 1
1633} 1752}
1634 1753
1635sub find_widget {
1636 my ($self, $x, $y) = @_;
1637
1638 $x -= $self->{x};
1639 $y -= $self->{y};
1640
1641 my $res;
1642
1643 for (grep $_, map @$_, grep $_, @{ $self->{children} }) {
1644 $res = $_->find_widget ($x, $y)
1645 and return $res;
1646 }
1647
1648 $self->SUPER::find_widget ($x + $self->{x}, $y + $self->{y})
1649}
1650
1651sub _draw {
1652 my ($self) = @_;
1653
1654 for (grep $_, @{$self->{children}}) {
1655 $_->draw for grep $_, @$_;
1656 }
1657}
1658
1659############################################################################# 1754#############################################################################
1660 1755
1661package CFPlus::UI::Box; 1756package CFPlus::UI::Box;
1662 1757
1663our @ISA = CFPlus::UI::Container::; 1758our @ISA = CFPlus::UI::Container::;
1664 1759
1665sub size_request { 1760sub size_request {
1666 my ($self) = @_; 1761 my ($self) = @_;
1762
1763 my @children = $self->visible_children;
1667 1764
1668 $self->{vertical} 1765 $self->{vertical}
1669 ? ( 1766 ? (
1670 (List::Util::max map $_->{req_w}, @{$self->{children}}), 1767 (List::Util::max map $_->{req_w}, @children),
1671 (List::Util::sum map $_->{req_h}, @{$self->{children}}), 1768 (List::Util::sum map $_->{req_h}, @children),
1672 ) 1769 )
1673 : ( 1770 : (
1674 (List::Util::sum map $_->{req_w}, @{$self->{children}}), 1771 (List::Util::sum map $_->{req_w}, @children),
1675 (List::Util::max map $_->{req_h}, @{$self->{children}}), 1772 (List::Util::max map $_->{req_h}, @children),
1676 ) 1773 )
1677} 1774}
1678 1775
1679sub invoke_size_allocate { 1776sub invoke_size_allocate {
1680 my ($self, $w, $h) = @_; 1777 my ($self, $w, $h) = @_;
1921 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y} 2018 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y}
1922 : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y} 2019 : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y}
1923 : ($self->{h} - $size->[1]) * 0.5); 2020 : ($self->{h} - $size->[1]) * 0.5);
1924 }; 2021 };
1925 2022
1926 my $w = List::Util::min $self->{w} + 4, $size->[0]; 2023# unless ($self->{list}) {
1927 my $h = List::Util::min $self->{h} + 2, $size->[1]; 2024# $self->{list} = CFPlus::OpenGL::glGenList;
2025# CFPlus::OpenGL::glNewList $self->{list};
2026# $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style});
2027# CFPlus::OpenGL::glEndList;
2028# }
2029#
2030# CFPlus::OpenGL::glCallList $self->{list};
1928 2031
1929 $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); 2032 $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style});
1930} 2033}
2034
2035#sub destroy {
2036# my ($self) = @_;
2037#
2038# CFPlus::OpenGL::glDeleteList delete $self->{list} if $self->{list};
2039#
2040# $self->SUPER::destroy;
2041#}
1931 2042
1932############################################################################# 2043#############################################################################
1933 2044
1934package CFPlus::UI::EntryBase; 2045package CFPlus::UI::EntryBase;
1935 2046
2219 2330
2220use CFPlus::OpenGL; 2331use CFPlus::OpenGL;
2221 2332
2222my @tex = 2333my @tex =
2223 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 2334 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 }
2224 qw(b1_button_active.png); 2335 qw(b1_button_inactive.png b1_button_active.png);
2225 2336
2226sub new { 2337sub new {
2227 my $class = shift; 2338 my $class = shift;
2228 2339
2229 $class->SUPER::new ( 2340 $class->SUPER::new (
2230 padding_x => 4, 2341 padding_x => 4,
2231 padding_y => 4, 2342 padding_y => 4,
2232 fg => [1, 1, 1], 2343 fg => [1.0, 1.0, 1.0],
2233 active_fg => [0, 0, 1], 2344 active_fg => [0.8, 0.8, 0.8],
2234 can_hover => 1, 2345 can_hover => 1,
2235 align => 0, 2346 align => 0,
2236 valign => 0, 2347 valign => 0,
2237 can_events => 1, 2348 can_events => 1,
2238 @_ 2349 @_
2256 2367
2257 glEnable GL_TEXTURE_2D; 2368 glEnable GL_TEXTURE_2D;
2258 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 2369 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2259 glColor 0, 0, 0, 1; 2370 glColor 0, 0, 0, 1;
2260 2371
2372 my $tex = $tex[$GRAB == $self];
2261 $tex[0]->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); 2373 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h});
2262 2374
2263 glDisable GL_TEXTURE_2D; 2375 glDisable GL_TEXTURE_2D;
2264 2376
2265 $self->SUPER::_draw; 2377 $self->SUPER::_draw;
2266} 2378}
2719 2831
2720 $self->SUPER::invoke_button_down ($ev, $x, $y); 2832 $self->SUPER::invoke_button_down ($ev, $x, $y);
2721 2833
2722 $self->{click} = [$self->{range}[0], $self->{vertical} ? $y : $x]; 2834 $self->{click} = [$self->{range}[0], $self->{vertical} ? $y : $x];
2723 2835
2724 $self->invoke_mouse_motion ($ev, $x, $y) 2836 $self->invoke_mouse_motion ($ev, $x, $y);
2837
2838 1
2725} 2839}
2726 2840
2727sub invoke_mouse_motion { 2841sub invoke_mouse_motion {
2728 my ($self, $ev, $x, $y) = @_; 2842 my ($self, $ev, $x, $y) = @_;
2729 2843
2749 2863
2750 my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2; 2864 my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2;
2751 2865
2752 $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart); 2866 $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart);
2753 2867
2754 ! ! $delta 2868 1
2755} 2869}
2756 2870
2757sub update { 2871sub update {
2758 my ($self) = @_; 2872 my ($self) = @_;
2759 2873
2890} 3004}
2891 3005
2892sub size_request { 3006sub size_request {
2893 my ($self) = @_; 3007 my ($self) = @_;
2894 3008
2895 my ($empty, $slider) = @{ $self->{children} }; 3009 my ($empty, $slider) = $self->visible_children;
2896 3010
2897 local $self->{children} = [$empty, $slider]; 3011 local $self->{children} = [$empty, $slider];
2898 $self->SUPER::size_request 3012 $self->SUPER::size_request
2899} 3013}
2900 3014
3321 3435
3322sub new { 3436sub new {
3323 my $class = shift; 3437 my $class = shift;
3324 3438
3325 my $self = $class->SUPER::new ( 3439 my $self = $class->SUPER::new (
3440 size_w => 32,
3441 size_h => 8,
3326 aspect => 1, 3442 aspect => 1,
3327 can_events => 0, 3443 can_events => 0,
3328 @_, 3444 @_,
3329 ); 3445 );
3330 3446
3331 if ($self->{anim} && $self->{animspeed}) { 3447 if ($self->{anim} && $self->{animspeed}) {
3332 CFPlus::weaken (my $widget = $self); 3448 CFPlus::weaken (my $widget = $self);
3333 3449
3450 $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed};
3451 $widget->{anim_start} = $self->{animspeed} * int Event::time / $self->{animspeed};
3334 $self->{timer} = Event->timer ( 3452 $self->{timer} = Event->timer (
3335 at => $self->{animspeed} * int $::NOW / $self->{animspeed},
3336 hard => 1, 3453 parked => 1,
3337 interval => $self->{animspeed},
3338 cb => sub { 3454 cb => sub {
3339 delete $self->{wait_face}; 3455 return unless $::CONN && $widget;
3456
3340 ++$widget->{frame}; 3457 ++$widget->{frame};
3458 $widget->update_face;
3341 $widget->update; 3459 $widget->update;
3460
3461 $widget->update_timer;
3342 }, 3462 },
3343 ); 3463 );
3464
3465 $self->update_face;
3466 $self->update_timer;
3344 } 3467 }
3345 3468
3346 $self 3469 $self
3347} 3470}
3348 3471
3472sub update_timer {
3473 my ($self) = @_;
3474
3475 return unless $self->{timer};
3476
3477 if ($self->{visible}) {
3478 $self->{timer}->at (
3479 $self->{anim_start}
3480 + $self->{animspeed}
3481 * int 1.5 + (Event::time - $self->{anim_start}) / $self->{animspeed}
3482 );
3483 $self->{timer}->start;
3484 } else {
3485 $self->{timer}->stop;
3486 }
3487}
3488
3489sub update_face {
3490 my ($self) = @_;
3491
3492 return unless $::CONN;
3493
3494 if (my $anim = $::CONN->{anim}[$self->{anim}]) {
3495 if ($anim && @$anim) {
3496 delete $self->{wait_face};
3497 $self->{face} = $anim->[ $self->{frame} % @$anim ];
3498 $self->{tex} = $::CONN->{texture}[ $::CONN->{faceid}[$self->{face}] ];
3499 }
3500 }
3501}
3502
3349sub size_request { 3503sub size_request {
3350 (32, 8) 3504 my ($self) = @_;
3505
3506 if ($::CONN) {
3507 if (my $faceid = $::CONN->{faceid}[$self->{face}]) {
3508 if (my $tex = $::CONN->{texture}[$faceid]) {
3509 $self->{tex} = $tex;
3510 return ($self->{size_w} || $tex->{w}, $self->{size_h} || $tex->{h});
3511 } else {
3512 $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub {
3513 $self->realloc;
3514 });
3515 }
3516 }
3517 }
3518
3519 ($self->{size_w} || 8, $self->{size_h} || 8)
3351} 3520}
3352 3521
3353sub update { 3522sub update {
3354 my ($self) = @_; 3523 my ($self) = @_;
3355 3524
3356 return unless $self->{visible}; 3525 return unless $self->{visible};
3357 3526
3358 $self->SUPER::update; 3527 $self->SUPER::update;
3359} 3528}
3360 3529
3530sub invoke_visibility_change {
3531 my ($self) = @_;
3532
3533 $self->update_timer;
3534
3535 0
3536}
3537
3361sub _draw { 3538sub _draw {
3362 my ($self) = @_; 3539 my ($self) = @_;
3363 3540
3364 return unless $::CONN;
3365
3366 $self->SUPER::_draw; 3541 $self->SUPER::_draw;
3367 3542
3368 my $face; 3543 if (my $tex = $self->{tex}) {
3369
3370 if ($self->{frame}) {
3371 my $anim = $::CONN->{anim}[$self->{anim}];
3372
3373 $face = $anim->[ $self->{frame} % @$anim ]
3374 if $anim && @$anim;
3375 }
3376
3377 my $faceid = $::CONN->{faceid}[$face || $self->{face}]
3378 or return;
3379
3380 my $tex = $::CONN->{texture}[$faceid];
3381
3382 if ($tex) {
3383 glEnable GL_TEXTURE_2D; 3544 glEnable GL_TEXTURE_2D;
3384 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 3545 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
3385 glColor 0, 0, 0, 1; 3546 glColor 0, 0, 0, 1;
3386 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); 3547 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h});
3387 glDisable GL_TEXTURE_2D; 3548 glDisable GL_TEXTURE_2D;
3388 } else {
3389 $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub {
3390 $self->update;
3391 });
3392 } 3549 }
3393} 3550}
3394 3551
3395sub destroy { 3552sub destroy {
3396 my ($self) = @_; 3553 my ($self) = @_;
3397 3554
3398 $self->{timer}->cancel 3555 (delete $self->{timer})->cancel
3399 if $self->{timer}; 3556 if $self->{timer};
3400 3557
3401 $self->SUPER::destroy; 3558 $self->SUPER::destroy;
3402} 3559}
3403 3560
3593 ); 3750 );
3594 3751
3595 $self->{filter}->add ($self->{multiplexer}) if $self->{filter}; 3752 $self->{filter}->add ($self->{multiplexer}) if $self->{filter};
3596 $self->SUPER::add ($self->{buttonbar}, $self->{filter} || $self->{multiplexer}); 3753 $self->SUPER::add ($self->{buttonbar}, $self->{filter} || $self->{multiplexer});
3597 3754
3755 {
3756 Scalar::Util::weaken (my $wself = $self);
3757
3758 $self->{multiplexer}->connect (c_add => sub {
3759 my ($mplex, $widgets) = @_;
3760
3761 for my $child (@$widgets) {
3762 Scalar::Util::weaken $child;
3763 $child->{c_tab_} ||= do {
3764 my $tab =
3765 (UNIVERSAL::isa $child->{c_tab}, "CFPlus::UI::Base")
3766 ? $child->{c_tab}
3767 : new CFPlus::UI::Button markup => $child->{c_tab}[0], tooltip => $child->{c_tab}[1];
3768
3769 $tab->connect (activate => sub {
3770 $wself->set_current_page ($child);
3771 });
3772
3773 $tab
3774 };
3775
3776 $self->{buttonbar}->add ($child->{c_tab_});
3777 }
3778 });
3779
3780 $self->{multiplexer}->connect (c_remove => sub {
3781 my ($mplex, $widgets) = @_;
3782
3783 for my $child (@$widgets) {
3784 $wself->{buttonbar}->remove ($child->{c_tab_});
3785 }
3786 });
3787 }
3788
3598 $self 3789 $self
3599} 3790}
3600 3791
3601sub add { 3792sub add {
3793 my ($self, @widgets) = @_;
3794
3795 $self->{multiplexer}->add (@widgets)
3796}
3797
3798sub remove {
3799 my ($self, @widgets) = @_;
3800
3801 $self->{multiplexer}->remove (@widgets)
3802}
3803
3804sub add_tab {
3602 my ($self, $title, $widget, $tooltip) = @_; 3805 my ($self, $title, $widget, $tooltip) = @_;
3603 3806
3604 CFPlus::weaken $self; 3807 $title = [$title, $tooltip] unless ref $title;
3808 $widget->{c_tab} = $title;
3605 3809
3606 $self->{buttonbar}->add (new CFPlus::UI::Button
3607 markup => $title,
3608 tooltip => $tooltip,
3609 on_activate => sub { $self->set_current_page ($widget) },
3610 );
3611
3612 $self->{multiplexer}->add ($widget); 3810 $self->add ($widget);
3613} 3811}
3614 3812
3615sub get_current_page { 3813sub get_current_page {
3616 my ($self) = @_; 3814 my ($self) = @_;
3617 3815
3947 while ($self->{refresh_hook}) { 4145 while ($self->{refresh_hook}) {
3948 $_->() 4146 $_->()
3949 for values %{delete $self->{refresh_hook}}; 4147 for values %{delete $self->{refresh_hook}};
3950 } 4148 }
3951 4149
3952 if ($self->{realloc}) { 4150 while ($self->{realloc}) {
3953 my %queue; 4151 my %queue;
3954 my @queue; 4152 my @queue;
3955 my $widget; 4153 my $widget;
3956 4154
3957 outer: 4155 outer:
4004 } 4202 }
4005 } 4203 }
4006 4204
4007 delete $self->{realloc}{$widget+0}; 4205 delete $self->{realloc}{$widget+0};
4008 } 4206 }
4009 }
4010 4207
4011 while (my $size_alloc = delete $self->{size_alloc}) { 4208 while (my $size_alloc = delete $self->{size_alloc}) {
4012 my @queue = sort { $b->{visible} <=> $a->{visible} } 4209 my @queue = sort { $a->{visible} <=> $b->{visible} }
4013 values %$size_alloc; 4210 values %$size_alloc;
4014 4211
4015 while () { 4212 while () {
4016 my $widget = pop @queue || last; 4213 my $widget = pop @queue || last;
4017 4214
4018 my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; 4215 my ($w, $h) = @$widget{qw(alloc_w alloc_h)};
4019 4216
4020 $w = 0 if $w < 0;
4021 $h = 0 if $h < 0;
4022
4023 $w = max $widget->{min_w}, $w; 4217 $w = max $widget->{min_w}, $w;
4024 $h = max $widget->{min_h}, $h; 4218 $h = max $widget->{min_h}, $h;
4025 4219
4026# $w = min $self->{w} - $widget->{x}, $w if $self->{w}; 4220# $w = min $self->{w} - $widget->{x}, $w if $self->{w};
4027# $h = min $self->{h} - $widget->{y}, $h if $self->{h}; 4221# $h = min $self->{h} - $widget->{y}, $h if $self->{h};
4028 4222
4029 $w = min $widget->{max_w}, $w if exists $widget->{max_w}; 4223 $w = min $widget->{max_w}, $w if exists $widget->{max_w};
4030 $h = min $widget->{max_h}, $h if exists $widget->{max_h}; 4224 $h = min $widget->{max_h}, $h if exists $widget->{max_h};
4031 4225
4032 $w = int $w + 0.5; 4226 $w = int $w + 0.5;
4033 $h = int $h + 0.5; 4227 $h = int $h + 0.5;
4034 4228
4035 if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { 4229 if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) {
4036 $widget->{old_w} = $widget->{w}; 4230 $widget->{old_w} = $widget->{w};
4037 $widget->{old_h} = $widget->{h}; 4231 $widget->{old_h} = $widget->{h};
4038 4232
4039 $widget->{w} = $w; 4233 $widget->{w} = $w;
4040 $widget->{h} = $h; 4234 $widget->{h} = $h;
4041 4235
4042 $widget->emit (size_allocate => $w, $h); 4236 $widget->emit (size_allocate => $w, $h);
4237 }
4043 } 4238 }
4044 } 4239 }
4045 } 4240 }
4046 4241
4047 while ($self->{post_alloc_hook}) { 4242 while ($self->{post_alloc_hook}) {
4048 $_->() 4243 $_->()
4049 for values %{delete $self->{post_alloc_hook}}; 4244 for values %{delete $self->{post_alloc_hook}};
4050 } 4245 }
4051
4052 4246
4053 glViewport 0, 0, $::WIDTH, $::HEIGHT; 4247 glViewport 0, 0, $::WIDTH, $::HEIGHT;
4054 glClearColor +($::CFG->{fow_intensity}) x 3, 1; 4248 glClearColor +($::CFG->{fow_intensity}) x 3, 1;
4055 glClear GL_COLOR_BUFFER_BIT; 4249 glClear GL_COLOR_BUFFER_BIT;
4056 4250

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines