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.372 by root, Sun Jul 15 22:13:43 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});
1072 row_expand => [1, 0], 1042 row_expand => [1, 0],
1073 %arg, 1043 %arg,
1074 ); 1044 );
1075 1045
1076 $self->{vp} = new CFPlus::UI::ViewPort 1046 $self->{vp} = new CFPlus::UI::ViewPort
1047 col => 0,
1048 row => 0,
1077 expand => 1, 1049 expand => 1,
1078 scroll_x => $self->{scroll_x}, 1050 scroll_x => $self->{scroll_x},
1079 scroll_y => $self->{scroll_y}, 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 },
1080 ; 1065 ;
1081 1066
1082 $self->SUPER::add (0, 0, $self->{vp}); 1067 $self->SUPER::add ($self->{vp});
1083 $self->SUPER::add (1, 0, $self->{vslider}) if $self->{scroll_y};
1084 $self->SUPER::add (0, 1, $self->{hslider}) if $self->{scroll_x};
1085 1068
1086 $self->add ($child) if $child; 1069 $self->add ($child) if $child;
1087 1070
1088 $self 1071 $self
1089} 1072}
1090
1091#TODO# update range on size_allocate depending on child
1092 1073
1093sub add { 1074sub add {
1094 my ($self, $widget) = @_; 1075 my ($self, $widget) = @_;
1095 1076
1096 $self->{vp}->add ($self->{child} = $widget); 1077 $self->{vp}->add ($self->{child} = $widget);
1097} 1078}
1098 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
1099sub invoke_mouse_wheel { 1128sub invoke_mouse_wheel {
1100 my ($self, $ev) = @_; 1129 my ($self, $ev) = @_;
1101 1130
1102 return 0 unless $ev->{dy}; # only vertical movements
1103
1104 $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};
1105 1133
1106 1 1134 1
1107} 1135}
1108 1136
1109sub update_slider { 1137sub invoke_button_down {
1110 my ($self) = @_; 1138 my ($self, $ev, $x, $y) = @_;
1111 1139
1112 my $child = ($self->{vp} or return)->child; 1140 if ($ev->{button} == 2) {
1141 $self->start_dragging ($ev);
1142 return 1;
1143 }
1113 1144
1114 my ($w1, $w2) = ($child->{w}, $self->{vp}{w}); 1145 0
1115 $self->{hslider}->set_range ([$self->{hslider}{range}[0], 0, $w1, $w2, 1]);
1116 #$self->{hslider}->set_visibility ($w1 != $w2);
1117
1118 my ($h1, $h2) = ($child->{h}, $self->{vp}{h});
1119 $self->{vslider}->set_range ([$self->{vslider}{range}[0], 0, $h1, $h2, 1]);
1120 #$self->{vslider}->set_visibility ($h1 != $h2);
1121} 1146}
1122 1147
1123sub update { 1148sub invoke_button_up {
1124 my ($self) = @_; 1149 my ($self, $ev, $x, $y) = @_;
1125 1150
1126 $self->SUPER::update; 1151 if (delete $self->{motion}) {
1127 $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
1128} 1167}
1129 1168
1130sub invoke_size_allocate { 1169sub invoke_size_allocate {
1131 my ($self, $w, $h) = @_; 1170 my ($self, $w, $h) = @_;
1132 1171
1288 1327
1289my @border = 1328my @border =
1290 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 1329 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 }
1291 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);
1292 1331
1332my @icon =
1333 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 }
1334 qw(x1_move.png x1_resize.png);
1335
1293sub new { 1336sub new {
1294 my ($class, %arg) = @_; 1337 my ($class, %arg) = @_;
1295 1338
1296 my $self = $class->SUPER::new ( 1339 my $self = $class->SUPER::new (
1297 bg => [1, 1, 1, 1], 1340 bg => [1, 1, 1, 1],
1465 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 1508 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
1466 1509
1467 my $border = $self->border; 1510 my $border = $self->border;
1468 1511
1469 glColor @{ $self->{border_bg} }; 1512 glColor @{ $self->{border_bg} };
1470 $border[0]->draw_quad_alpha (0, 0, $w, $border); 1513 $border[0]->draw_quad_alpha ( 0, 0, $w, $border);
1471 $border[1]->draw_quad_alpha (0, $border, $border, $ch); 1514 $border[1]->draw_quad_alpha ( 0, $border, $border, $ch);
1472 $border[2]->draw_quad_alpha ($w - $border, $border, $border, $ch); 1515 $border[2]->draw_quad_alpha ($w - $border, $border, $border, $ch);
1473 $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);
1474 1531
1475 if (@{$self->{bg}} < 4 || $self->{bg}[3]) { 1532 if (@{$self->{bg}} < 4 || $self->{bg}[3]) {
1476 glColor @{ $self->{bg} }; 1533 glColor @{ $self->{bg} };
1477 1534
1478 # TODO: repeat texture not scale 1535 # TODO: repeat texture not scale
1499 1556
1500############################################################################# 1557#############################################################################
1501 1558
1502package CFPlus::UI::Table; 1559package CFPlus::UI::Table;
1503 1560
1504our @ISA = CFPlus::UI::Base::; 1561our @ISA = CFPlus::UI::Container::;
1505 1562
1506use List::Util qw(max sum); 1563use List::Util qw(max sum);
1507 1564
1508use CFPlus::OpenGL; 1565use CFPlus::OpenGL;
1509 1566
1515 row_expand => [], 1572 row_expand => [],
1516 @_, 1573 @_,
1517 ) 1574 )
1518} 1575}
1519 1576
1520sub children {
1521 grep $_, map @$_, grep $_, @{ $_[0]{children} }
1522}
1523
1524sub 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 {
1525 my ($self) = shift; 1589 my $self = shift;
1590
1591 my @widgets;
1526 1592
1527 while (@_) { 1593 while (@_) {
1528 my ($x, $y, $child) = splice @_, 0, 3, (); 1594 my ($col, $row, $child) = splice @_, 0, 3, ();
1529 $child->set_parent ($self);
1530 $self->{children}[$y][$x] = $child;
1531 }
1532 1595
1533 $self->{force_realloc} = 1; 1596 $child->{row} = $row;
1534 $self->{force_size_alloc} = 1; 1597 $child->{col} = $col;
1535 $self->realloc;
1536}
1537 1598
1538sub remove { 1599 push @widgets, $child;
1600 }
1601
1602 $self->add (@widgets);
1603}
1604
1605sub get_wh {
1539 my ($self, $child) = @_; 1606 my ($self) = @_;
1540 1607
1541 # TODO: not yet implemented 1608 my (@w, @h);
1542}
1543
1544# TODO: move to container class maybe? send children a signal on removal?
1545sub clear {
1546 my ($self) = @_;
1547 1609
1548 my @children = $self->children; 1610 my @children = $self->children;
1549 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 }
1550 1621 }
1551 for (@children) {
1552 delete $_->{parent};
1553 $_->hide;
1554 }
1555 1622
1556 $self->realloc; 1623 # second pass, rows
1557} 1624 for my $widget (sort { $a->{rowspan} <=> $b->{rowspan} } @children) {
1558
1559sub get_wh {
1560 my ($self) = @_;
1561
1562 my (@w, @h);
1563
1564 for my $y (0 .. $#{$self->{children}}) {
1565 my $row = $self->{children}[$y]
1566 or next;
1567
1568 for my $x (0 .. $#$row) {
1569 my $widget = $row->[$x]
1570 or next;
1571 my ($w, $h) = @$widget{qw(req_w req_h)}; 1625 my ($r, $h, $rs) = @$widget{qw(row req_h rowspan)};
1572 1626
1573 $w[$x] = max $w[$x], $w; 1627 my $sh = sum @h[$r .. $r + $rs - 1];
1574 $h[$y] = max $h[$y], $h; 1628
1629 if ($h > $sh) {
1630 $_ += ($h - $sh) / ($sh ? $sh / $_ : $rs) for @h[$r .. $r + $rs - 1];
1575 } 1631 }
1576 } 1632 }
1577 1633
1578 (\@w, \@h) 1634 (\@w, \@h)
1579} 1635}
1595 my ($ws, $hs) = $self->get_wh; 1651 my ($ws, $hs) = $self->get_wh;
1596 1652
1597 my $req_w = (sum @$ws) || 1; 1653 my $req_w = (sum @$ws) || 1;
1598 my $req_h = (sum @$hs) || 1; 1654 my $req_h = (sum @$hs) || 1;
1599 1655
1600 # TODO: nicer code 1656 # now linearly scale the rows/columns to the allocated size
1601 my @col_expand = @{$self->{col_expand}}; 1657 my @col_expand = @{$self->{col_expand}};
1602 @col_expand = (1) x @$ws unless @col_expand; 1658 @col_expand = (1) x @$ws unless @col_expand;
1603 my $col_expand = (sum @col_expand) || 1; 1659 my $col_expand = (sum @col_expand) || 1;
1604 1660
1605 $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws; 1661 $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws;
1612 1668
1613 $hs->[$_] += $row_expand[$_] / $row_expand * ($h - $req_h) for 0 .. $#$hs; 1669 $hs->[$_] += $row_expand[$_] / $row_expand * ($h - $req_h) for 0 .. $#$hs;
1614 1670
1615 CFPlus::UI::harmonize $hs; 1671 CFPlus::UI::harmonize $hs;
1616 1672
1617 my $y; 1673 my @x; for (0 .. $#$ws) { $x[$_ + 1] = $x[$_] + $ws->[$_] }
1674 my @y; for (0 .. $#$hs) { $y[$_ + 1] = $y[$_] + $hs->[$_] }
1618 1675
1619 for my $r (0 .. $#{$self->{children}}) { 1676 for my $widget ($self->children) {
1620 my $row = $self->{children}[$r] 1677 my ($r, $c, $w, $h, $rs, $cs) = @$widget{qw(row col req_w req_h rowspan colspan)};
1621 or next;
1622 1678
1623 my $x = 0; 1679 $widget->configure (
1624 my $row_h = $hs->[$r]; 1680 $x[$c], $y[$r],
1681 $x[$c + $cs] - $x[$c], $y[$r + $rs] - $y[$r],
1625 1682 );
1626 for my $c (0 .. $#$row) { 1683 }
1627 my $col_w = $ws->[$c];
1628 1684
1629 if (my $widget = $row->[$c]) { 1685 1
1630 $widget->configure ($x, $y, $col_w, $row_h); 1686}
1631 }
1632 1687
1633 $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};
1634 } 1715 }
1716 }
1635 1717
1636 $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});
1637 } 1749 }
1638 1750
1639 1 1751 1
1640} 1752}
1641 1753
1642sub find_widget {
1643 my ($self, $x, $y) = @_;
1644
1645 $x -= $self->{x};
1646 $y -= $self->{y};
1647
1648 my $res;
1649
1650 for (grep $_, map @$_, grep $_, @{ $self->{children} }) {
1651 $res = $_->find_widget ($x, $y)
1652 and return $res;
1653 }
1654
1655 $self->SUPER::find_widget ($x + $self->{x}, $y + $self->{y})
1656}
1657
1658sub _draw {
1659 my ($self) = @_;
1660
1661 for (grep $_, @{$self->{children}}) {
1662 $_->draw for grep $_, @$_;
1663 }
1664}
1665
1666############################################################################# 1754#############################################################################
1667 1755
1668package CFPlus::UI::Box; 1756package CFPlus::UI::Box;
1669 1757
1670our @ISA = CFPlus::UI::Container::; 1758our @ISA = CFPlus::UI::Container::;
1671 1759
1672sub size_request { 1760sub size_request {
1673 my ($self) = @_; 1761 my ($self) = @_;
1762
1763 my @children = $self->visible_children;
1674 1764
1675 $self->{vertical} 1765 $self->{vertical}
1676 ? ( 1766 ? (
1677 (List::Util::max map $_->{req_w}, @{$self->{children}}), 1767 (List::Util::max map $_->{req_w}, @children),
1678 (List::Util::sum map $_->{req_h}, @{$self->{children}}), 1768 (List::Util::sum map $_->{req_h}, @children),
1679 ) 1769 )
1680 : ( 1770 : (
1681 (List::Util::sum map $_->{req_w}, @{$self->{children}}), 1771 (List::Util::sum map $_->{req_w}, @children),
1682 (List::Util::max map $_->{req_h}, @{$self->{children}}), 1772 (List::Util::max map $_->{req_h}, @children),
1683 ) 1773 )
1684} 1774}
1685 1775
1686sub invoke_size_allocate { 1776sub invoke_size_allocate {
1687 my ($self, $w, $h) = @_; 1777 my ($self, $w, $h) = @_;
1928 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y} 2018 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y}
1929 : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y} 2019 : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y}
1930 : ($self->{h} - $size->[1]) * 0.5); 2020 : ($self->{h} - $size->[1]) * 0.5);
1931 }; 2021 };
1932 2022
1933 my $w = List::Util::min $self->{w} + 4, $size->[0]; 2023# unless ($self->{list}) {
1934 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};
1935 2031
1936 $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); 2032 $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style});
1937} 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#}
1938 2042
1939############################################################################# 2043#############################################################################
1940 2044
1941package CFPlus::UI::EntryBase; 2045package CFPlus::UI::EntryBase;
1942 2046
2226 2330
2227use CFPlus::OpenGL; 2331use CFPlus::OpenGL;
2228 2332
2229my @tex = 2333my @tex =
2230 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 2334 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 }
2231 qw(b1_button_active.png); 2335 qw(b1_button_inactive.png b1_button_active.png);
2232 2336
2233sub new { 2337sub new {
2234 my $class = shift; 2338 my $class = shift;
2235 2339
2236 $class->SUPER::new ( 2340 $class->SUPER::new (
2237 padding_x => 4, 2341 padding_x => 4,
2238 padding_y => 4, 2342 padding_y => 4,
2239 fg => [1, 1, 1], 2343 fg => [1.0, 1.0, 1.0],
2240 active_fg => [0, 0, 1], 2344 active_fg => [0.8, 0.8, 0.8],
2241 can_hover => 1, 2345 can_hover => 1,
2242 align => 0, 2346 align => 0,
2243 valign => 0, 2347 valign => 0,
2244 can_events => 1, 2348 can_events => 1,
2245 @_ 2349 @_
2263 2367
2264 glEnable GL_TEXTURE_2D; 2368 glEnable GL_TEXTURE_2D;
2265 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 2369 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2266 glColor 0, 0, 0, 1; 2370 glColor 0, 0, 0, 1;
2267 2371
2372 my $tex = $tex[$GRAB == $self];
2268 $tex[0]->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); 2373 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h});
2269 2374
2270 glDisable GL_TEXTURE_2D; 2375 glDisable GL_TEXTURE_2D;
2271 2376
2272 $self->SUPER::_draw; 2377 $self->SUPER::_draw;
2273} 2378}
2726 2831
2727 $self->SUPER::invoke_button_down ($ev, $x, $y); 2832 $self->SUPER::invoke_button_down ($ev, $x, $y);
2728 2833
2729 $self->{click} = [$self->{range}[0], $self->{vertical} ? $y : $x]; 2834 $self->{click} = [$self->{range}[0], $self->{vertical} ? $y : $x];
2730 2835
2731 $self->invoke_mouse_motion ($ev, $x, $y) 2836 $self->invoke_mouse_motion ($ev, $x, $y);
2837
2838 1
2732} 2839}
2733 2840
2734sub invoke_mouse_motion { 2841sub invoke_mouse_motion {
2735 my ($self, $ev, $x, $y) = @_; 2842 my ($self, $ev, $x, $y) = @_;
2736 2843
2756 2863
2757 my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2; 2864 my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2;
2758 2865
2759 $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart); 2866 $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart);
2760 2867
2761 ! ! $delta 2868 1
2762} 2869}
2763 2870
2764sub update { 2871sub update {
2765 my ($self) = @_; 2872 my ($self) = @_;
2766 2873
2897} 3004}
2898 3005
2899sub size_request { 3006sub size_request {
2900 my ($self) = @_; 3007 my ($self) = @_;
2901 3008
2902 my ($empty, $slider) = @{ $self->{children} }; 3009 my ($empty, $slider) = $self->visible_children;
2903 3010
2904 local $self->{children} = [$empty, $slider]; 3011 local $self->{children} = [$empty, $slider];
2905 $self->SUPER::size_request 3012 $self->SUPER::size_request
2906} 3013}
2907 3014
3328 3435
3329sub new { 3436sub new {
3330 my $class = shift; 3437 my $class = shift;
3331 3438
3332 my $self = $class->SUPER::new ( 3439 my $self = $class->SUPER::new (
3440 size_w => 32,
3441 size_h => 8,
3333 aspect => 1, 3442 aspect => 1,
3334 can_events => 0, 3443 can_events => 0,
3335 @_, 3444 @_,
3336 ); 3445 );
3337 3446
3338 if ($self->{anim} && $self->{animspeed}) { 3447 if ($self->{anim} && $self->{animspeed}) {
3339 CFPlus::weaken (my $widget = $self); 3448 CFPlus::weaken (my $widget = $self);
3340 3449
3450 $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed};
3451 $widget->{anim_start} = $self->{animspeed} * int Event::time / $self->{animspeed};
3341 $self->{timer} = Event->timer ( 3452 $self->{timer} = Event->timer (
3342 at => $self->{animspeed} * int $::NOW / $self->{animspeed},
3343 hard => 1, 3453 parked => 1,
3344 interval => $self->{animspeed},
3345 cb => sub { 3454 cb => sub {
3346 delete $self->{wait_face}; 3455 return unless $::CONN && $widget;
3456
3347 ++$widget->{frame}; 3457 ++$widget->{frame};
3458 $widget->update_face;
3348 $widget->update; 3459 $widget->update;
3460
3461 $widget->update_timer;
3349 }, 3462 },
3350 ); 3463 );
3464
3465 $self->update_face;
3466 $self->update_timer;
3351 } 3467 }
3352 3468
3353 $self 3469 $self
3354} 3470}
3355 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
3356sub size_request { 3503sub size_request {
3357 (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)
3358} 3520}
3359 3521
3360sub update { 3522sub update {
3361 my ($self) = @_; 3523 my ($self) = @_;
3362 3524
3363 return unless $self->{visible}; 3525 return unless $self->{visible};
3364 3526
3365 $self->SUPER::update; 3527 $self->SUPER::update;
3366} 3528}
3367 3529
3530sub invoke_visibility_change {
3531 my ($self) = @_;
3532
3533 $self->update_timer;
3534
3535 0
3536}
3537
3368sub _draw { 3538sub _draw {
3369 my ($self) = @_; 3539 my ($self) = @_;
3370 3540
3371 return unless $::CONN;
3372
3373 $self->SUPER::_draw; 3541 $self->SUPER::_draw;
3374 3542
3375 my $face; 3543 if (my $tex = $self->{tex}) {
3376
3377 if ($self->{frame}) {
3378 my $anim = $::CONN->{anim}[$self->{anim}];
3379
3380 $face = $anim->[ $self->{frame} % @$anim ]
3381 if $anim && @$anim;
3382 }
3383
3384 my $faceid = $::CONN->{faceid}[$face || $self->{face}]
3385 or return;
3386
3387 my $tex = $::CONN->{texture}[$faceid];
3388
3389 if ($tex) {
3390 glEnable GL_TEXTURE_2D; 3544 glEnable GL_TEXTURE_2D;
3391 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 3545 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
3392 glColor 0, 0, 0, 1; 3546 glColor 0, 0, 0, 1;
3393 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); 3547 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h});
3394 glDisable GL_TEXTURE_2D; 3548 glDisable GL_TEXTURE_2D;
3395 } else {
3396 $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub {
3397 $self->update;
3398 });
3399 } 3549 }
3400} 3550}
3401 3551
3402sub destroy { 3552sub destroy {
3403 my ($self) = @_; 3553 my ($self) = @_;
3404 3554
3405 $self->{timer}->cancel 3555 (delete $self->{timer})->cancel
3406 if $self->{timer}; 3556 if $self->{timer};
3407 3557
3408 $self->SUPER::destroy; 3558 $self->SUPER::destroy;
3409} 3559}
3410 3560
3600 ); 3750 );
3601 3751
3602 $self->{filter}->add ($self->{multiplexer}) if $self->{filter}; 3752 $self->{filter}->add ($self->{multiplexer}) if $self->{filter};
3603 $self->SUPER::add ($self->{buttonbar}, $self->{filter} || $self->{multiplexer}); 3753 $self->SUPER::add ($self->{buttonbar}, $self->{filter} || $self->{multiplexer});
3604 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
3605 $self 3789 $self
3606} 3790}
3607 3791
3608sub 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 {
3609 my ($self, $title, $widget, $tooltip) = @_; 3805 my ($self, $title, $widget, $tooltip) = @_;
3610 3806
3611 CFPlus::weaken $self; 3807 $title = [$title, $tooltip] unless ref $title;
3808 $widget->{c_tab} = $title;
3612 3809
3613 $self->{buttonbar}->add (new CFPlus::UI::Button
3614 markup => $title,
3615 tooltip => $tooltip,
3616 on_activate => sub { $self->set_current_page ($widget) },
3617 );
3618
3619 $self->{multiplexer}->add ($widget); 3810 $self->add ($widget);
3620} 3811}
3621 3812
3622sub get_current_page { 3813sub get_current_page {
3623 my ($self) = @_; 3814 my ($self) = @_;
3624 3815
3954 while ($self->{refresh_hook}) { 4145 while ($self->{refresh_hook}) {
3955 $_->() 4146 $_->()
3956 for values %{delete $self->{refresh_hook}}; 4147 for values %{delete $self->{refresh_hook}};
3957 } 4148 }
3958 4149
3959 if ($self->{realloc}) { 4150 while ($self->{realloc}) {
3960 my %queue; 4151 my %queue;
3961 my @queue; 4152 my @queue;
3962 my $widget; 4153 my $widget;
3963 4154
3964 outer: 4155 outer:
4011 } 4202 }
4012 } 4203 }
4013 4204
4014 delete $self->{realloc}{$widget+0}; 4205 delete $self->{realloc}{$widget+0};
4015 } 4206 }
4016 }
4017 4207
4018 while (my $size_alloc = delete $self->{size_alloc}) { 4208 while (my $size_alloc = delete $self->{size_alloc}) {
4019 my @queue = sort { $b->{visible} <=> $a->{visible} } 4209 my @queue = sort { $a->{visible} <=> $b->{visible} }
4020 values %$size_alloc; 4210 values %$size_alloc;
4021 4211
4022 while () { 4212 while () {
4023 my $widget = pop @queue || last; 4213 my $widget = pop @queue || last;
4024 4214
4025 my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; 4215 my ($w, $h) = @$widget{qw(alloc_w alloc_h)};
4026 4216
4027 $w = 0 if $w < 0;
4028 $h = 0 if $h < 0;
4029
4030 $w = max $widget->{min_w}, $w; 4217 $w = max $widget->{min_w}, $w;
4031 $h = max $widget->{min_h}, $h; 4218 $h = max $widget->{min_h}, $h;
4032 4219
4033# $w = min $self->{w} - $widget->{x}, $w if $self->{w}; 4220# $w = min $self->{w} - $widget->{x}, $w if $self->{w};
4034# $h = min $self->{h} - $widget->{y}, $h if $self->{h}; 4221# $h = min $self->{h} - $widget->{y}, $h if $self->{h};
4035 4222
4036 $w = min $widget->{max_w}, $w if exists $widget->{max_w}; 4223 $w = min $widget->{max_w}, $w if exists $widget->{max_w};
4037 $h = min $widget->{max_h}, $h if exists $widget->{max_h}; 4224 $h = min $widget->{max_h}, $h if exists $widget->{max_h};
4038 4225
4039 $w = int $w + 0.5; 4226 $w = int $w + 0.5;
4040 $h = int $h + 0.5; 4227 $h = int $h + 0.5;
4041 4228
4042 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}) {
4043 $widget->{old_w} = $widget->{w}; 4230 $widget->{old_w} = $widget->{w};
4044 $widget->{old_h} = $widget->{h}; 4231 $widget->{old_h} = $widget->{h};
4045 4232
4046 $widget->{w} = $w; 4233 $widget->{w} = $w;
4047 $widget->{h} = $h; 4234 $widget->{h} = $h;
4048 4235
4049 $widget->emit (size_allocate => $w, $h); 4236 $widget->emit (size_allocate => $w, $h);
4237 }
4050 } 4238 }
4051 } 4239 }
4052 } 4240 }
4053 4241
4054 while ($self->{post_alloc_hook}) { 4242 while ($self->{post_alloc_hook}) {
4055 $_->() 4243 $_->()
4056 for values %{delete $self->{post_alloc_hook}}; 4244 for values %{delete $self->{post_alloc_hook}};
4057 } 4245 }
4058
4059 4246
4060 glViewport 0, 0, $::WIDTH, $::HEIGHT; 4247 glViewport 0, 0, $::WIDTH, $::HEIGHT;
4061 glClearColor +($::CFG->{fow_intensity}) x 3, 1; 4248 glClearColor +($::CFG->{fow_intensity}) x 3, 1;
4062 glClear GL_COLOR_BUFFER_BIT; 4249 glClear GL_COLOR_BUFFER_BIT;
4063 4250

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines