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.402 by root, Sat Jul 21 20:49:44 2007 UTC vs.
Revision 1.408 by root, Sun Jul 22 15:26:01 2007 UTC

593 593
594# using global variables seems a bit hacky, but passing through all drawing 594# using global variables seems a bit hacky, but passing through all drawing
595# functions seems pointless. 595# functions seems pointless.
596our ($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
597 597
598sub draw { 598#sub draw {
599 my ($self) = @_; 599#CFPlus.xs
600
601 return unless $self->{h} && $self->{w};
602
603 # update screen rectangle
604 local $draw_x = $draw_x + $self->{x};
605 local $draw_y = $draw_y + $self->{y};
606
607 # skip widgets that are entirely outside the drawing area
608 return if ($draw_x + $self->{w} < 0) || ($draw_x >= $draw_w)
609 || ($draw_y + $self->{h} < 0) || ($draw_y >= $draw_h);
610
611 glPushMatrix;
612 glTranslate $self->{x}, $self->{y}, 0;
613
614 if ($self == $HOVER && $self->{can_hover}) {
615 glColor 1*0.2, 0.8*0.2, 0.5*0.2, 0.2;
616 glEnable GL_BLEND;
617 glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA;
618 glBegin GL_QUADS;
619 glVertex 0 , 0;
620 glVertex $self->{w}, 0;
621 glVertex $self->{w}, $self->{h};
622 glVertex 0 , $self->{h};
623 glEnd;
624 glDisable GL_BLEND;
625 }
626
627 if ($ENV{CFPLUS_DEBUG} & 1) {
628 glPushMatrix;
629 glColor 1, 1, 0, 1;
630 glTranslate 0.375, 0.375;
631 glBegin GL_LINE_LOOP;
632 glVertex 0 , 0;
633 glVertex $self->{w} - 1, 0;
634 glVertex $self->{w} - 1, $self->{h} - 1;
635 glVertex 0 , $self->{h} - 1;
636 glEnd;
637 glPopMatrix;
638 #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw;
639 }
640
641 $self->_draw;
642 glPopMatrix;
643}
644 600
645sub _draw { 601sub _draw {
646 my ($self) = @_; 602 my ($self) = @_;
647 603
648 warn "no draw defined for $self\n"; 604 warn "no draw defined for $self\n";
2071 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y} 2027 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y}
2072 : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y} 2028 : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y}
2073 : ($self->{h} - $size->[1]) * 0.5); 2029 : ($self->{h} - $size->[1]) * 0.5);
2074 }; 2030 };
2075 2031
2076 my $w = List::Util::min $self->{w} + 4, $size->[0]; 2032# unless ($self->{list}) {
2077 my $h = List::Util::min $self->{h} + 2, $size->[1]; 2033# $self->{list} = CFPlus::OpenGL::glGenList;
2034# CFPlus::OpenGL::glNewList $self->{list};
2035# $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style});
2036# CFPlus::OpenGL::glEndList;
2037# }
2038#
2039# CFPlus::OpenGL::glCallList $self->{list};
2078 2040
2079 $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); 2041 $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style});
2080} 2042}
2043
2044#sub destroy {
2045# my ($self) = @_;
2046#
2047# CFPlus::OpenGL::glDeleteList delete $self->{list} if $self->{list};
2048#
2049# $self->SUPER::destroy;
2050#}
2081 2051
2082############################################################################# 2052#############################################################################
2083 2053
2084package CFPlus::UI::EntryBase; 2054package CFPlus::UI::EntryBase;
2085 2055
3483 3453
3484 if ($self->{anim} && $self->{animspeed}) { 3454 if ($self->{anim} && $self->{animspeed}) {
3485 CFPlus::weaken (my $widget = $self); 3455 CFPlus::weaken (my $widget = $self);
3486 3456
3487 $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed}; 3457 $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed};
3488 $widget->{anim_start} = $self->{animspeed} * Event::time / $self->{animspeed}; 3458 $widget->{anim_start} = $self->{animspeed} * int Event::time / $self->{animspeed};
3489 $self->{timer} = Event->timer ( 3459 $self->{timer} = Event->timer (
3490 parked => 1, 3460 parked => 1,
3491 cb => sub { 3461 cb => sub {
3492 return unless $::CONN && $widget; 3462 return unless $::CONN && $widget;
3493 3463
3530 3500
3531 if (my $anim = $::CONN->{anim}[$self->{anim}]) { 3501 if (my $anim = $::CONN->{anim}[$self->{anim}]) {
3532 if ($anim && @$anim) { 3502 if ($anim && @$anim) {
3533 delete $self->{wait_face}; 3503 delete $self->{wait_face};
3534 $self->{face} = $anim->[ $self->{frame} % @$anim ]; 3504 $self->{face} = $anim->[ $self->{frame} % @$anim ];
3505 $self->{tex} = $::CONN->{texture}[ $::CONN->{faceid}[$self->{face}] ];
3535 } 3506 }
3536 } 3507 }
3537} 3508}
3538 3509
3539sub size_request { 3510sub size_request {
3794sub add { 3765sub add {
3795 my ($self, $title, $widget, $tooltip) = @_; 3766 my ($self, $title, $widget, $tooltip) = @_;
3796 3767
3797 CFPlus::weaken $self; 3768 CFPlus::weaken $self;
3798 3769
3799 $self->{buttonbar}->add (new CFPlus::UI::Button 3770 unless (ref $title) {
3771 $title = new CFPlus::UI::Button
3800 markup => $title, 3772 markup => $title,
3801 tooltip => $tooltip, 3773 tooltip => $tooltip,
3774 );
3775 }
3776
3802 on_activate => sub { $self->set_current_page ($widget) }, 3777 $title->connect (activate => sub { $self->set_current_page ($widget) });
3803 ); 3778 $self->{buttonbar}->add ($title);
3804 3779
3805 $self->{multiplexer}->add ($widget); 3780 $self->{multiplexer}->add ($widget);
3806} 3781}
3807 3782
3808sub get_current_page { 3783sub get_current_page {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines