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.436 by root, Wed Aug 22 21:40:57 2007 UTC vs.
Revision 1.440 by root, Sun Sep 16 18:27:48 2007 UTC

269 $self->emit ("destroy"); 269 $self->emit ("destroy");
270 %$self = (); 270 %$self = ();
271} 271}
272 272
273sub TO_JSON { 273sub TO_JSON {
274 { __w_ => $_[0]{s_id} } 274 { "\fw" => $_[0]{s_id} }
275} 275}
276 276
277sub show { 277sub show {
278 my ($self) = @_; 278 my ($self) = @_;
279 279
358 358
359 $self->{force_w} = $w; 359 $self->{force_w} = $w;
360 $self->{force_h} = $h; 360 $self->{force_h} = $h;
361 361
362 $self->realloc; 362 $self->realloc;
363}
364
365# traverse the widget chain up to find the maximum "physical" size constraints
366sub get_max_wh {
367 my ($self) = @_;
368
369 return $self->{parent}->get_max_wh
370 if $self->{parent};
371
372 ($::WIDTH, $::HEIGHT)
363} 373}
364 374
365sub size_request { 375sub size_request {
366 require Carp; 376 require Carp;
367 Carp::confess "size_request is abstract"; 377 Carp::confess "size_request is abstract";
817 827
818 1 828 1
819} 829}
820 830
821############################################################################# 831#############################################################################
822
823# back-buffered drawing area 832# back-buffered drawing area
824 833
825package CFPlus::UI::Window; 834package CFPlus::UI::Window;
826 835
827our @ISA = CFPlus::UI::Bin::; 836our @ISA = CFPlus::UI::Bin::;
1376 $self->CFPlus::UI::Container::add ($self->{title_widget}) if $self->{title_widget}; 1385 $self->CFPlus::UI::Container::add ($self->{title_widget}) if $self->{title_widget};
1377} 1386}
1378 1387
1379sub border { 1388sub border {
1380 int $_[0]{border} * $::FONTSIZE 1389 int $_[0]{border} * $::FONTSIZE
1390}
1391
1392sub get_max_wh {
1393 my ($self) = @_;
1394
1395 return ($self->{w}, $self->{h})
1396 if $self->{visible} && $self->{w};
1397
1398 $self->SUPER::get_max_wh
1381} 1399}
1382 1400
1383sub size_request { 1401sub size_request {
1384 my ($self) = @_; 1402 my ($self) = @_;
1385 1403
1942 1960
1943sub size_request { 1961sub size_request {
1944 my ($self) = @_; 1962 my ($self) = @_;
1945 1963
1946 $self->{size_req} ||= do { 1964 $self->{size_req} ||= do {
1965 my ($max_w, $max_h) = $self->get_max_wh;
1966
1947 $self->{layout}->set_font ($self->{font}) if $self->{font}; 1967 $self->{layout}->set_font ($self->{font}) if $self->{font};
1948 $self->{layout}->set_width ($self->{max_w} || -1); 1968 $self->{layout}->set_width ($self->{max_w} || $max_w || -1);
1949 $self->{layout}->set_ellipsise ($self->{ellipsise}); 1969 $self->{layout}->set_ellipsise ($self->{ellipsise});
1950 $self->{layout}->set_single_paragraph_mode ($self->{ellipsise}); 1970 $self->{layout}->set_single_paragraph_mode ($self->{ellipsise});
1951 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); 1971 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE);
1952 1972
1953 my ($w, $h) = $self->{layout}->size; 1973 my ($w, $h) = $self->{layout}->size;
2233 @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text); 2253 @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text);
2234 } 2254 }
2235 2255
2236 glColor_premultiply @{$self->{active_fg}}; 2256 glColor_premultiply @{$self->{active_fg}};
2237 glBegin GL_LINES; 2257 glBegin GL_LINES;
2238 glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy}; 2258 glVertex $self->{cur_x} + $self->{ox} + .5, $self->{cur_y} + $self->{oy};
2239 glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy} + $self->{cur_h}; 2259 glVertex $self->{cur_x} + $self->{ox} + .5, $self->{cur_y} + $self->{oy} + $self->{cur_h};
2240 glEnd; 2260 glEnd;
2241 2261
2242 glLineWidth 3; 2262 glLineWidth 3;
2243 glColor @{$self->{active_outline}}; 2263 glColor @{$self->{active_outline}};
2244 glRect_lineloop 0, 0, $self->{w} - 1, $self->{h} - 1; 2264 glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5;
2245 glLineWidth 1; 2265 glLineWidth 1;
2246 2266
2247 } else { 2267 } else {
2248 glColor @{$self->{outline}}; 2268 glColor @{$self->{outline}};
2249 glTranslate .375, .375;
2250 glBegin GL_LINE_STRIP; 2269 glBegin GL_LINE_STRIP;
2251 glVertex 0, $self->{h} * .5; 2270 glVertex .5, $self->{h} * .5;
2252 glVertex 0, $self->{h} - 3; 2271 glVertex .5, $self->{h} - 2.5;
2253 glVertex $self->{w} - 1, $self->{h} - 3; 2272 glVertex $self->{w} - .5, $self->{h} - 2.5;
2254 glVertex $self->{w} - 1, $self->{h} * .5; 2273 glVertex $self->{w} - .5, $self->{h} * .5;
2255 glEnd; 2274 glEnd;
2256 } 2275 }
2257} 2276}
2258 2277
2259############################################################################# 2278#############################################################################
2508sub _draw { 2527sub _draw {
2509 my ($self) = @_; 2528 my ($self) = @_;
2510 2529
2511 $self->SUPER::_draw; 2530 $self->SUPER::_draw;
2512 2531
2513 glTranslate $self->{padding_x} + 0.375, $self->{padding_y} + 0.375, 0; 2532 glTranslate $self->{padding_x}, $self->{padding_y}, 0;
2514 2533
2515 my ($w, $h) = @$self{qw(w h)}; 2534 my ($w, $h) = @$self{qw(w h)};
2516 2535
2517 my $s = List::Util::min $w - $self->{padding_x} * 2, $h - $self->{padding_y} * 2; 2536 my $s = List::Util::min $w - $self->{padding_x} * 2, $h - $self->{padding_y} * 2;
2518 2537
2837 2856
2838 glEnable GL_BLEND; 2857 glEnable GL_BLEND;
2839 glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; 2858 glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA;
2840 2859
2841 if ($self->{value} >= 0) { 2860 if ($self->{value} >= 0) {
2842 my $s = 3 + ($self->{w} - 6) * $self->{value}; 2861 my $s = int 2 + ($self->{w} - 4) * $self->{value};
2843 2862
2844 glColor_premultiply @{$self->{bar}}; 2863 glColor_premultiply @{$self->{bar}};
2845 glRect 2, 2, $s, $self->{h} - 2; 2864 glRect 2, 2, $s, $self->{h} - 2;
2846 glColor_premultiply @{$self->{bg}}; 2865 glColor_premultiply @{$self->{bg}};
2847 glRect $s + 1, 0, $self->{w} - 2, $self->{h} - 2; 2866 glRect $s, 2, $self->{w} - 2, $self->{h} - 2;
2848 } 2867 }
2849 2868
2850 glColor_premultiply @{$self->{outline}}; 2869 glColor_premultiply @{$self->{outline}};
2851 glRect_lineloop 1, 1, $self->{w} - 2, $self->{h} - 2; 2870 glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5;
2852 2871
2853 glDisable GL_BLEND; 2872 glDisable GL_BLEND;
2854 2873
2855 { 2874 {
2856 local $self->{bg}; # do not draw background 2875 local $self->{bg}; # do not draw background
3618} 3637}
3619 3638
3620sub _draw { 3639sub _draw {
3621 my ($self) = @_; 3640 my ($self) = @_;
3622 3641
3623 glTranslate 0.375, 0.375;
3624
3625 my ($w, $h) = @$self{qw(w h)}; 3642 my ($w, $h) = @$self{qw(w h)};
3626 3643
3627 glColor 1, 0.8, 0.4; 3644 glColor 1, 0.8, 0.4;
3628 glRect 0, 0, $w, $h; 3645 glRect 0, 0, $w, $h;
3629 3646
3630 glColor 0, 0, 0; 3647 glColor 0, 0, 0;
3631 glRect_lineloop 0, 0, $w, $h; 3648 glRect_lineloop .5, .5, $w + .5, $h + .5;
3632 3649
3633 glTranslate 2 - 0.375, 2 - 0.375; 3650 glTranslate 2, 2;
3634 3651
3635 $self->SUPER::_draw; 3652 $self->SUPER::_draw;
3636} 3653}
3637 3654
3638############################################################################# 3655#############################################################################
3965 my $class = shift; 3982 my $class = shift;
3966 3983
3967 my $self = $class->SUPER::new ( 3984 my $self = $class->SUPER::new (
3968 buttonbar => (new CFPlus::UI::Buttonbar), 3985 buttonbar => (new CFPlus::UI::Buttonbar),
3969 multiplexer => (new CFPlus::UI::Multiplexer expand => 1), 3986 multiplexer => (new CFPlus::UI::Multiplexer expand => 1),
3970 active_outline => [1, 1, 0], 3987 active_outline => [.7, .7, 0.2],
3971 # filter => # will be put between multiplexer and $self 3988 # filter => # will be put between multiplexer and $self
3972 @_, 3989 @_,
3973 ); 3990 );
3974 3991
3975 $self->{filter}->add ($self->{multiplexer}) if $self->{filter}; 3992 $self->{filter}->add ($self->{multiplexer}) if $self->{filter};
4056 4073
4057 $self->SUPER::_draw (); 4074 $self->SUPER::_draw ();
4058 4075
4059 if (my $cur = $self->{multiplexer}{current}) { 4076 if (my $cur = $self->{multiplexer}{current}) {
4060 if ($cur = $cur->{c_tab_}) { 4077 if ($cur = $cur->{c_tab_}) {
4061 glTranslate $cur->{x}, $cur->{y}; 4078 glTranslate $self->{buttonbar}{x} + $cur->{x},
4079 $self->{buttonbar}{y} + $cur->{y};
4062 glLineWidth 3; 4080 glLineWidth 3;
4081 #glEnable GL_BLEND;
4082 #glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA;
4063 glColor @{$self->{active_outline}}; 4083 glColor @{$self->{active_outline}};
4064 glRect_lineloop 1, 1, $cur->{w} - 2, $cur->{h} - 2; 4084 glRect_lineloop 1.5, 1.5, $cur->{w} - 1.5, $cur->{h} - 1.5;
4065 glLineWidth 1; 4085 glLineWidth 1;
4086 #glDisable GL_BLEND;
4066 } 4087 }
4067 } 4088 }
4068} 4089}
4069 4090
4070############################################################################# 4091#############################################################################

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines