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.202 by root, Sun May 14 20:51:19 2006 UTC vs.
Revision 1.205 by root, Mon May 15 00:15:08 2006 UTC

31 $TOOLTIP->set_tooltip_from ($widget); 31 $TOOLTIP->set_tooltip_from ($widget);
32 $TOOLTIP->show; 32 $TOOLTIP->show;
33 33
34 my ($x, $y) = $widget->coord2global ($widget->{w}, 0); 34 my ($x, $y) = $widget->coord2global ($widget->{w}, 0);
35 35
36 if ($x + $TOOLTIP->{w} > $::WIDTH) {
37 ($x, $y) = $widget->coord2global (-$TOOLTIP->{w}, 0); 36 ($x, $y) = $widget->coord2global (-$TOOLTIP->{w}, 0)
38 } 37 if $x + $TOOLTIP->{w} > $::WIDTH;
39 38
40 $TOOLTIP->move ($x, $y); 39 $TOOLTIP->move ($x, $y);
41 $TOOLTIP->check_size; 40 $TOOLTIP->check_size;
42 $TOOLTIP->update; 41 $TOOLTIP->update;
43 } 42 }
199sub show { 198sub show {
200 my ($self) = @_; 199 my ($self) = @_;
201 200
202 return if $self->{parent}; 201 return if $self->{parent};
203 202
204 $self->{toplevel} = 1;
205 $CFClient::UI::ROOT->add ($self); 203 $CFClient::UI::ROOT->add ($self);
206} 204}
207 205
208sub hide { 206sub hide {
209 my ($self) = @_; 207 my ($self) = @_;
377 glVertex $self->{w}, 0; 375 glVertex $self->{w}, 0;
378 glVertex $self->{w}, $self->{h}; 376 glVertex $self->{w}, $self->{h};
379 glVertex 0 , $self->{h}; 377 glVertex 0 , $self->{h};
380 glEnd; 378 glEnd;
381 glPopMatrix; 379 glPopMatrix;
382 CFClient::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; 380 #CFClient::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw;
383 } 381 }
384} 382}
385 383
386sub _draw { 384sub _draw {
387 my ($self) = @_; 385 my ($self) = @_;
2691 ? "<b>$item->{count} ×</b> $item->{text}" 2689 ? "<b>$item->{count} ×</b> $item->{text}"
2692 : $item->{text}; 2690 : $item->{text};
2693 2691
2694 for ($short) { 2692 for ($short) {
2695 s/^\s+//; 2693 s/^\s+//;
2696 s/\012.*/…/s; 2694 s/\s+/ /g;
2697 my $len = int 40 / $item->{fontsize}; 2695 my $len = int 40 / $item->{fontsize};
2698 substr $_, $len, length, "…" if $len < length; 2696 substr $_, $len, length, "…" if $len < length;
2699 } 2697 }
2700 2698
2701 new CFClient::UI::Label 2699 new CFClient::UI::Label
2702 markup => $short, 2700 markup => $short,
2703 tooltip => $item->{tooltip}, 2701 tooltip => $item->{tooltip},
2704 tooltip_font => $::FONT_PROP, 2702 tooltip_font => $::FONT_PROP,
2705 tooltip_width => 0.67, 2703 tooltip_width => 0.67,
2706 fontsize => $item->{fontsize}, 2704 fontsize => $item->{fontsize},
2707 color => $item->{color}, 2705 fg => $item->{fg},
2708 can_events => 1, 2706 can_events => 1,
2709 can_hover => 1 2707 can_hover => 1
2710 }; 2708 };
2711 } 2709 }
2712 2710
2739 id => ++$self->{id}, 2737 id => ++$self->{id},
2740 text => $text, 2738 text => $text,
2741 timeout => $timeout, 2739 timeout => $timeout,
2742 tooltip => $text, 2740 tooltip => $text,
2743 fontsize => 0.8, 2741 fontsize => 0.8,
2744 color => [0.8, 0.8, 0.8, 0.8], 2742 fg => [0.8, 0.8, 0.8, 0.8],
2745 pri => 0, 2743 pri => 0,
2746 count => 1, 2744 count => 1,
2747 %arg, 2745 %arg,
2748 }; 2746 };
2749 } 2747 }
2797 if $old_w && $old_h && ($old_w != $w || $old_h != $h); 2795 if $old_w && $old_h && ($old_w != $w || $old_h != $h);
2798 2796
2799 for my $child ($self->children) { 2797 for my $child ($self->children) {
2800 my ($X, $Y, $W, $H) = @$child{qw(x y req_w req_h)}; 2798 my ($X, $Y, $W, $H) = @$child{qw(x y req_w req_h)};
2801 2799
2800 $X = $child->{req_x} > 0 ? $child->{req_x} : $w - $W - $child->{req_x} + 1
2801 if exists $child->{req_x};
2802
2803 $Y = $child->{req_y} > 0 ? $child->{req_y} : $h - $H - $child->{req_y} + 1
2804 if exists $child->{req_y};
2805
2802 $X = List::Util::max 0, List::Util::min $w - $W, $X; 2806 $X = List::Util::max 0, List::Util::min $w - $W, int $X + 0.5;
2803 $Y = List::Util::max 0, List::Util::min $h - $H, $Y; 2807 $Y = List::Util::max 0, List::Util::min $h - $H, int $Y + 0.5;
2808
2804 $child->configure ($X, $Y, $W, $H); 2809 $child->configure ($X, $Y, $W, $H);
2805 } 2810 }
2806} 2811}
2807 2812
2808sub coord2local { 2813sub coord2local {
2823 $self->check_size; 2828 $self->check_size;
2824 $::WANT_REFRESH++; 2829 $::WANT_REFRESH++;
2825} 2830}
2826 2831
2827sub add { 2832sub add {
2828 my ($self, $child) = @_; 2833 my ($self, @children) = @_;
2829 2834
2835 for my $child (@children) {
2836 $child->{toplevel} = 1;
2837
2830 # integerise window positions 2838 # integerise window positions
2831 $child->{x} = int $child->{x}; 2839 $child->{x} = int $child->{x};
2832 $child->{y} = int $child->{y}; 2840 $child->{y} = int $child->{y};
2841 }
2833 2842
2834 $self->SUPER::add ($child); 2843 $self->SUPER::add (@children);
2835} 2844}
2836 2845
2837sub on_refresh { 2846sub on_refresh {
2838 my ($self, $id, $cb) = @_; 2847 my ($self, $id, $cb) = @_;
2839 2848

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines