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.161 by root, Mon Apr 24 03:43:51 2006 UTC vs.
Revision 1.162 by root, Mon Apr 24 06:05:35 2006 UTC

23 23
24 my $tip = $widget->{tooltip}; 24 my $tip = $widget->{tooltip};
25 25
26 $tip = $tip->($widget) if CODE:: eq ref $tip; 26 $tip = $tip->($widget) if CODE:: eq ref $tip;
27 27
28 $TOOLTIP->set_text ($widget->{tooltip}); 28 $TOOLTIP->set_markup ($widget->{tooltip});
29 $TOOLTIP->move ($widget->coord2global ($widget->{w}, 0)); 29 $TOOLTIP->move ($widget->coord2global ($widget->{w}, 0));
30 $TOOLTIP->show; 30 $TOOLTIP->show;
31 } 31 }
32 32
33 return; 33 return;
320 glVertex $x + $self->{w}, $y + $self->{h}; 320 glVertex $x + $self->{w}, $y + $self->{h};
321 glVertex $x , $y + $self->{h}; 321 glVertex $x , $y + $self->{h};
322 glEnd; 322 glEnd;
323 glDisable GL_BLEND; 323 glDisable GL_BLEND;
324 } 324 }
325
326 if ($ENV{PCLIENT_DEBUG}) {
327 glPushMatrix;
328 glColor 1, 1, 0, 1;
329 glTranslate $self->{x} + 0.375, $self->{y} + 0.375;
330 glBegin GL_LINE_LOOP;
331 glVertex 0 , 0;
332 glVertex $self->{w}, 0;
333 glVertex $self->{w}, $self->{h};
334 glVertex 0 , $self->{h};
335 glEnd;
336 glPopMatrix;
337 CFClient::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw;
338 }
325} 339}
326 340
327sub _draw { 341sub _draw {
328 my ($self) = @_; 342 my ($self) = @_;
329 343
497 511
498 $self->{children} = [ grep $_ != $child, @{ $self->{children} } ]; 512 $self->{children} = [ grep $_ != $child, @{ $self->{children} } ];
499 513
500 $self->check_size; 514 $self->check_size;
501 $self->update; 515 $self->update;
516}
517
518sub clear {
519 my ($self) = @_;
520
521 delete $_->{parent}
522 for @{ delete $self->{children} };
523
524 $self->{children} = [];
502} 525}
503 526
504sub find_widget { 527sub find_widget {
505 my ($self, $x, $y) = @_; 528 my ($self, $x, $y) = @_;
506 529
1131 $self->set_markup (delete $self->{markup}) if exists $self->{markup}; 1154 $self->set_markup (delete $self->{markup}) if exists $self->{markup};
1132 1155
1133 $self 1156 $self
1134} 1157}
1135 1158
1136sub escape_text { 1159sub escape {
1137 local $_ = $_[1]; 1160 local $_ = $_[1];
1138 1161
1139 s/&/&/g; 1162 s/&/&/g;
1140 s/>/>/g; 1163 s/>/>/g;
1141 s/</&lt;/g; 1164 s/</&lt;/g;
2183 @_, 2206 @_,
2184 can_events => 0, 2207 can_events => 0,
2185 ) 2208 )
2186} 2209}
2187 2210
2188sub set_text { 2211sub set_markup {
2189 my ($self, $text) = @_; 2212 my ($self, $text) = @_;
2190 2213
2191 $self->{label} ||= new CFClient::UI::Label fontsize => 0.8, fg => [0, 0, 0]; 2214 $self->{label} ||= new CFClient::UI::Label fontsize => 0.8, fg => [0, 0, 0];
2192 $self->{label}->set_text ($text); 2215 $self->{label}->set_markup ($text);
2193 $self->add ($self->{label}); 2216 $self->add ($self->{label});
2194} 2217}
2195 2218
2196sub size_request { 2219sub size_request {
2197 my ($self) = @_; 2220 my ($self) = @_;
2199 $self->child->set_max_size ($::WIDTH * 0.3); 2222 $self->child->set_max_size ($::WIDTH * 0.3);
2200 2223
2201 my ($w, $h) = @{$self->child}{qw(req_w req_h)}; 2224 my ($w, $h) = @{$self->child}{qw(req_w req_h)};
2202 2225
2203 ($w + 4, $h + 4) 2226 ($w + 4, $h + 4)
2227}
2228
2229sub size_allocate {
2230 my ($self, $w, $h) = @_;
2231
2232 $self->SUPER::size_allocate ($w - 4, $h - 4);
2204} 2233}
2205 2234
2206sub _draw { 2235sub _draw {
2207 my ($self) = @_; 2236 my ($self) = @_;
2208 2237
2233 $self->SUPER::_draw; 2262 $self->SUPER::_draw;
2234} 2263}
2235 2264
2236############################################################################# 2265#############################################################################
2237 2266
2267package CFClient::UI::Face;
2268
2269our @ISA = CFClient::UI::Base::;
2270
2271use CFClient::OpenGL;
2272
2273sub new {
2274 my $class = shift;
2275
2276 $class->SUPER::new (
2277 aspect => 1,
2278 @_,
2279 )
2280}
2281
2282sub size_request {
2283 (32, 8)
2284}
2285
2286sub draw {
2287 my ($self) = @_;
2288
2289 my $tex = $::CONN->{texture}[$::CONN->{faceid}[$self->{face}]];
2290
2291 if ($tex) {
2292 glEnable GL_BLEND;
2293 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
2294 glEnable GL_TEXTURE_2D;
2295 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2296 glColor 1, 1, 1, 1;
2297 $tex->draw_quad (0, 0, $self->{w}, $self->{h});
2298 glDisable GL_TEXTURE_2D;
2299 glDisable GL_BLEND;
2300 }
2301}
2302
2303#############################################################################
2304
2238package CFClient::UI::Root; 2305package CFClient::UI::Root;
2239 2306
2240our @ISA = CFClient::UI::Container::; 2307our @ISA = CFClient::UI::Container::;
2241 2308
2242use CFClient::OpenGL; 2309use CFClient::OpenGL;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines