… | |
… | |
18 | for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { |
18 | for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { |
19 | if (exists $widget->{tooltip}) { |
19 | if (exists $widget->{tooltip}) { |
20 | |
20 | |
21 | if ($TOOLTIP->{owner} != $widget) { |
21 | if ($TOOLTIP->{owner} != $widget) { |
22 | $TOOLTIP->{owner} = $widget; |
22 | $TOOLTIP->{owner} = $widget; |
|
|
23 | |
|
|
24 | my $tip = $widget->{tooltip}; |
|
|
25 | |
|
|
26 | $tip = $tip->($widget) if CODE:: eq ref $tip; |
|
|
27 | |
23 | $TOOLTIP->set_text ($widget->{tooltip}); |
28 | $TOOLTIP->set_text ($widget->{tooltip}); |
24 | $TOOLTIP->move ($widget->coord2global ($widget->{w}, 0)); |
29 | $TOOLTIP->move ($widget->coord2global ($widget->{w}, 0)); |
25 | $TOOLTIP->show; |
30 | $TOOLTIP->show; |
26 | } |
31 | } |
27 | |
32 | |
… | |
… | |
2149 | } |
2154 | } |
2150 | |
2155 | |
2151 | sub set_text { |
2156 | sub set_text { |
2152 | my ($self, $text) = @_; |
2157 | my ($self, $text) = @_; |
2153 | |
2158 | |
2154 | $self->{label} ||= new CFClient::UI::Label fontsize => 0.8; |
2159 | $self->{label} ||= new CFClient::UI::Label fontsize => 0.8, fg => [0, 0, 0]; |
2155 | $self->{label}->set_text ($text); |
2160 | $self->{label}->set_text ($text); |
2156 | $self->add ($self->{label}); |
2161 | $self->add ($self->{label}); |
2157 | } |
2162 | } |
2158 | |
2163 | |
2159 | sub size_request { |
2164 | sub size_request { |
2160 | my ($self) = @_; |
2165 | my ($self) = @_; |
2161 | |
2166 | |
2162 | my ($w, $h) = @{$self->child}{qw(req_w req_h)}; |
2167 | my ($w, $h) = @{$self->child}{qw(req_w req_h)}; |
2163 | |
2168 | |
2164 | $w = List::Util::min $::WIDTH * 0.2, $w; |
2169 | $w = List::Util::min $::WIDTH * 0.2, $w; |
|
|
2170 | $h = List::Util::max $::HEIGHT * 0.2, $h; |
2165 | |
2171 | |
2166 | ($w, $h) |
2172 | ($w + 4, $h + 4) |
|
|
2173 | } |
|
|
2174 | |
|
|
2175 | sub _draw { |
|
|
2176 | my ($self) = @_; |
|
|
2177 | |
|
|
2178 | glPushMatrix; |
|
|
2179 | glTranslate 0.375, 0.375; |
|
|
2180 | |
|
|
2181 | my ($w, $h) = @$self{qw(w h)}; |
|
|
2182 | |
|
|
2183 | glColor 1, 0.8, 0.4; |
|
|
2184 | glBegin GL_QUADS; |
|
|
2185 | glVertex 0 , 0; |
|
|
2186 | glVertex 0 , $h; |
|
|
2187 | glVertex $w, $h; |
|
|
2188 | glVertex $w, 0; |
|
|
2189 | glEnd; |
|
|
2190 | |
|
|
2191 | glColor 0, 0, 0; |
|
|
2192 | glBegin GL_LINE_LOOP; |
|
|
2193 | glVertex 0 , 0; |
|
|
2194 | glVertex 0 , $h; |
|
|
2195 | glVertex $w, $h; |
|
|
2196 | glVertex $w, 0; |
|
|
2197 | glEnd; |
|
|
2198 | |
|
|
2199 | glPopMatrix; |
|
|
2200 | |
|
|
2201 | glTranslate 2, 2; |
|
|
2202 | $self->SUPER::_draw; |
2167 | } |
2203 | } |
2168 | |
2204 | |
2169 | ############################################################################# |
2205 | ############################################################################# |
2170 | |
2206 | |
2171 | package CFClient::UI::Root; |
2207 | package CFClient::UI::Root; |