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.310 by root, Fri Jun 23 20:28:20 2006 UTC vs.
Revision 1.312 by root, Fri Jun 23 23:54:30 2006 UTC

335sub size_request { 335sub size_request {
336 require Carp; 336 require Carp;
337 Carp::confess "size_request is abstract"; 337 Carp::confess "size_request is abstract";
338} 338}
339 339
340sub baseline_shift {
341 0
342}
343
340sub configure { 344sub configure {
341 my ($self, $x, $y, $w, $h) = @_; 345 my ($self, $x, $y, $w, $h) = @_;
342 346
343 if ($self->{aspect}) { 347 if ($self->{aspect}) {
344 my ($ow, $oh) = ($w, $h); 348 my ($ow, $oh) = ($w, $h);
535 return unless $self->{h} && $self->{w}; 539 return unless $self->{h} && $self->{w};
536 540
537 # update screen rectangle 541 # update screen rectangle
538 local $draw_x = $draw_x + $self->{x}; 542 local $draw_x = $draw_x + $self->{x};
539 local $draw_y = $draw_y + $self->{y}; 543 local $draw_y = $draw_y + $self->{y};
540 local $draw_w = $draw_x + $self->{w};
541 local $draw_h = $draw_y + $self->{h};
542 544
543 # skip widgets that are entirely outside the drawing area 545 # skip widgets that are entirely outside the drawing area
544 return if ($draw_x + $self->{w} < 0) || ($draw_x >= $draw_w) 546 return if ($draw_x + $self->{w} < 0) || ($draw_x >= $draw_w)
545 || ($draw_y + $self->{h} < 0) || ($draw_y >= $draw_h); 547 || ($draw_y + $self->{h} < 0) || ($draw_y >= $draw_h);
546 548
1631 }; 1633 };
1632 1634
1633 @{ $self->{size_req} } 1635 @{ $self->{size_req} }
1634} 1636}
1635 1637
1638sub baseline_shift {
1639 $_[0]{layout}->descent
1640}
1641
1636sub invoke_size_allocate { 1642sub invoke_size_allocate {
1637 my ($self, $w, $h) = @_; 1643 my ($self, $w, $h) = @_;
1638 1644
1639 delete $self->{ox}; 1645 delete $self->{ox};
1640 1646
2567 2573
2568 $self->{fontsize} = $fontsize; 2574 $self->{fontsize} = $fontsize;
2569 $self->reflow; 2575 $self->reflow;
2570} 2576}
2571 2577
2572sub visible_children { 2578sub size_request {
2573 my ($self) = @_; 2579 my ($self) = @_;
2574 2580
2575 @{$self->{children}}[0,1] 2581 my ($empty, $slider) = @{ $self->{children} };
2582
2583 local $self->{children} = [$empty, $slider];
2584 $self->SUPER::size_request
2576} 2585}
2577 2586
2578sub invoke_size_allocate { 2587sub invoke_size_allocate {
2579 my ($self, $w, $h) = @_; 2588 my ($self, $w, $h) = @_;
2580 2589
2581 my (undef, undef, @other) = @{ $self->{children} }; 2590 my ($empty, $slider, @other) = @{ $self->{children} };
2582 $_->configure (@$_{qw(x y req_w req_h)}) for @other; 2591 $_->configure (@$_{qw(x y req_w req_h)}) for @other;
2583 2592
2584 $self->{layout}->set_font ($self->{font}) if $self->{font}; 2593 $self->{layout}->set_font ($self->{font}) if $self->{font};
2585 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); 2594 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE);
2586 $self->{layout}->set_width ($self->{children}[0]{w}); 2595 $self->{layout}->set_width ($empty->{w});
2587 $self->{layout}->set_indent ($self->{fontsize} * $::FONTSIZE * $self->{indent}); 2596 $self->{layout}->set_indent ($self->{fontsize} * $::FONTSIZE * $self->{indent});
2588 2597
2589 $self->reflow; 2598 $self->reflow;
2590 2599
2600 local $self->{children} = [$empty, $slider];
2591 $self->SUPER::invoke_size_allocate ($w, $h) 2601 $self->SUPER::invoke_size_allocate ($w, $h)
2592} 2602}
2593 2603
2594sub get_layout { 2604sub get_layout {
2595 my ($self, $para) = @_; 2605 my ($self, $para) = @_;
2596 2606
2597 my $layout = $self->{layout}; 2607 my $layout = $self->{layout};
2598 2608
2599 $layout->set_font ($self->{font}) if $self->{font}; 2609 $layout->set_font ($self->{font}) if $self->{font};
2610 $layout->set_foreground (@{$para->{fg}});
2600 $layout->set_height ($self->{fontsize} * $::FONTSIZE); 2611 $layout->set_height ($self->{fontsize} * $::FONTSIZE);
2601 $layout->set_width ($self->{children}[0]{w} - $para->{indent}); 2612 $layout->set_width ($self->{children}[0]{w} - $para->{indent});
2602 $layout->set_indent ($self->{fontsize} * $::FONTSIZE * $self->{indent}); 2613 $layout->set_indent ($self->{fontsize} * $::FONTSIZE * $self->{indent});
2603 $layout->set_markup ($para->{markup}); 2614 $layout->set_markup ($para->{markup});
2604 $layout->set_shapes (map +($_->{req_w}, $_->{req_h}), @{$para->{widget}}); 2615
2616 $layout->set_shapes (
2617 map
2618 +(0, $_->baseline_shift +$_->{padding_y} - $_->{h}, $_->{w}, $_->{h}),
2619 @{$para->{widget}}
2620 );
2605 2621
2606 $layout 2622 $layout
2607} 2623}
2608 2624
2609sub reflow { 2625sub reflow {
2677 for my $para (@{$self->{par}}) { 2693 for my $para (@{$self->{par}}) {
2678 if ($para->{w} != $W && ($para->{wrapped} || $para->{w} > $W)) { 2694 if ($para->{w} != $W && ($para->{wrapped} || $para->{w} > $W)) {
2679 my $layout = $self->get_layout ($para); 2695 my $layout = $self->get_layout ($para);
2680 my ($w, $h) = $layout->size; 2696 my ($w, $h) = $layout->size;
2681 2697
2682 $para->{w} = $w + $para->{indent}; 2698 $para->{w} = $w + $para->{indent};
2683 $para->{h} = $h; 2699 $para->{h} = $h;
2684 $para->{wrapped} = $layout->has_wrapped; 2700 $para->{wrapped} = $layout->has_wrapped;
2685 } 2701 }
2686 2702
2687 $height += $para->{h}; 2703 $height += $para->{h};
2688 } 2704 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines