--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/23 00:57:39 1.151 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/23 02:50:42 1.156 @@ -20,6 +20,11 @@ if ($TOOLTIP->{owner} != $widget) { $TOOLTIP->{owner} = $widget; + + my $tip = $widget->{tooltip}; + + $tip = $tip->($widget) if CODE:: eq ref $tip; + $TOOLTIP->set_text ($widget->{tooltip}); $TOOLTIP->move ($widget->coord2global ($widget->{w}, 0)); $TOOLTIP->show; @@ -1181,7 +1186,9 @@ my ($self, $fontsize) = @_; $self->{fontsize} = $fontsize; + delete $self->{texture}; $self->check_size; + $self->update; } sub _draw { @@ -1723,9 +1730,9 @@ %arg, ); - $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999"); - $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1); - $self->add ($self->{max} = new CFClient::UI::Label valign => -1, align => 0, template => "999"); + $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999", can_events => 1, can_hover => 1); + $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, can_events => 1, can_hover => 1); + $self->add ($self->{max} = new CFClient::UI::Label valign => -1, align => 0, template => "999", can_events => 1, can_hover => 1); $self } @@ -2131,6 +2138,72 @@ ############################################################################# +package CFClient::UI::Tooltip; + +our @ISA = CFClient::UI::Bin::; + +use CFClient::OpenGL; + +sub new { + my $class = shift; + + $class->SUPER::new ( + @_, + can_events => 0, + ) +} + +sub set_text { + my ($self, $text) = @_; + + $self->{label} ||= new CFClient::UI::Label fontsize => 0.8, fg => [0, 0, 0]; + $self->{label}->set_text ($text); + $self->add ($self->{label}); +} + +sub size_request { + my ($self) = @_; + + my ($w, $h) = @{$self->child}{qw(req_w req_h)}; + + $w = List::Util::min $::WIDTH * 0.2, $w; + $h = List::Util::max $::HEIGHT * 0.2, $h; + + ($w + 4, $h + 4) +} + +sub _draw { + my ($self) = @_; + + glPushMatrix; + glTranslate 0.375, 0.375; + + my ($w, $h) = @$self{qw(w h)}; + + glColor 1, 0.8, 0.4; + glBegin GL_QUADS; + glVertex 0 , 0; + glVertex 0 , $h; + glVertex $w, $h; + glVertex $w, 0; + glEnd; + + glColor 0, 0, 0; + glBegin GL_LINE_LOOP; + glVertex 0 , 0; + glVertex 0 , $h; + glVertex $w, $h; + glVertex $w, 0; + glEnd; + + glPopMatrix; + + glTranslate 2, 2; + $self->SUPER::_draw; +} + +############################################################################# + package CFClient::UI::Root; our @ISA = CFClient::UI::Container::; @@ -2215,7 +2288,7 @@ package CFClient::UI; $ROOT = new CFClient::UI::Root; -$TOOLTIP = new CFClient::UI::Label fontsize => 0.8, can_events => 0; +$TOOLTIP = new CFClient::UI::Tooltip; 1