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.362 by root, Sat Dec 9 21:26:46 2006 UTC vs.
Revision 1.366 by root, Mon Apr 23 19:17:41 2007 UTC

22our $TOOLTIP_WATCHER = Event->idle (min => 1/60, cb => sub { 22our $TOOLTIP_WATCHER = Event->idle (min => 1/60, cb => sub {
23 if (!$GRAB) { 23 if (!$GRAB) {
24 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { 24 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) {
25 if (length $widget->{tooltip}) { 25 if (length $widget->{tooltip}) {
26 if ($TOOLTIP->{owner} != $widget) { 26 if ($TOOLTIP->{owner} != $widget) {
27 $TOOLTIP->{owner}->emit ("tooltip_hide") if $TOOLTIP->{owner};
27 $TOOLTIP->hide; 28 $TOOLTIP->hide;
28 29
29 $TOOLTIP->{owner} = $widget; 30 $TOOLTIP->{owner} = $widget;
31 $TOOLTIP->{owner}->emit ("tooltip_show") if $TOOLTIP->{owner};
30 32
31 return if $ENV{CFPLUS_DEBUG} & 8; 33 return if $ENV{CFPLUS_DEBUG} & 8;
32 34
33 my $tip = $widget->{tooltip}; 35 my $tip = $widget->{tooltip};
34 36
42 } 44 }
43 } 45 }
44 } 46 }
45 47
46 $TOOLTIP->hide; 48 $TOOLTIP->hide;
49 $TOOLTIP->{owner}->emit ("tooltip_hide") if $TOOLTIP->{owner};
47 delete $TOOLTIP->{owner}; 50 delete $TOOLTIP->{owner};
48}); 51});
49 52
50sub get_layout { 53sub get_layout {
51 my $layout; 54 my $layout;
1976 } elsif ($sym == CFPlus::SDLK_LEFT) { 1979 } elsif ($sym == CFPlus::SDLK_LEFT) {
1977 --$self->{cursor} if $self->{cursor}; 1980 --$self->{cursor} if $self->{cursor};
1978 } elsif ($sym == CFPlus::SDLK_RIGHT) { 1981 } elsif ($sym == CFPlus::SDLK_RIGHT) {
1979 ++$self->{cursor} if $self->{cursor} < length $self->{text}; 1982 ++$self->{cursor} if $self->{cursor} < length $self->{text};
1980 } elsif ($sym == CFPlus::SDLK_HOME) { 1983 } elsif ($sym == CFPlus::SDLK_HOME) {
1984 # what a hack
1981 $self->{cursor} = 0; 1985 $self->{cursor} =
1986 (substr $self->{text}, 0, $self->{cursor}) =~ /^(.*\012)/
1987 ? length $1
1988 : 0;
1982 } elsif ($sym == CFPlus::SDLK_END) { 1989 } elsif ($sym == CFPlus::SDLK_END) {
1990 # uh, again
1991 $self->{cursor} =
1992 (substr $self->{text}, $self->{cursor}) =~ /^([^\012]*)\012/
1983 $self->{cursor} = length $text; 1993 ? $self->{cursor} + length $1
1994 : length $self->{text};
1984 } elsif ($uni == 21) { # ctrl-u 1995 } elsif ($uni == 21) { # ctrl-u
1985 $text = ""; 1996 $text = "";
1986 $self->{cursor} = 0; 1997 $self->{cursor} = 0;
1987 } elsif ($uni == 27) { 1998 } elsif ($uni == 27) {
1988 $self->emit ('escape'); 1999 $self->emit ('escape');
1989 } elsif ($uni >= 0x20 || $uni == 0x0d) { 2000 } elsif ($uni == 0x0d) {
2001 substr $text, $self->{cursor}++, 0, "\012";
2002 } elsif ($uni >= 0x20) {
1990 substr $text, $self->{cursor}++, 0, chr $uni; 2003 substr $text, $self->{cursor}++, 0, chr $uni;
1991 } else { 2004 } else {
1992 return 0; 2005 return 0;
1993 } 2006 }
1994 2007
2698sub invoke_mouse_wheel { 2711sub invoke_mouse_wheel {
2699 my ($self, $ev) = @_; 2712 my ($self, $ev) = @_;
2700 2713
2701 my $delta = $self->{vertical} ? $ev->{dy} : $ev->{dx}; 2714 my $delta = $self->{vertical} ? $ev->{dy} : $ev->{dx};
2702 2715
2716 my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2;
2717
2703 $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * 0.2); 2718 $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart);
2704 2719
2705 ! ! $delta 2720 ! ! $delta
2706} 2721}
2707 2722
2708sub update { 2723sub update {
2818 #font => default_font 2833 #font => default_font
2819 @_, 2834 @_,
2820 2835
2821 layout => (new CFPlus::Layout), 2836 layout => (new CFPlus::Layout),
2822 par => [], 2837 par => [],
2838 max_par => 0,
2823 height => 0, 2839 height => 0,
2824 children => [ 2840 children => [
2825 (new CFPlus::UI::Empty expand => 1), 2841 (new CFPlus::UI::Empty expand => 1),
2826 (new CFPlus::UI::Slider vertical => 1), 2842 (new CFPlus::UI::Slider vertical => 1),
2827 ], 2843 ],
2950 wrapped => 1, 2966 wrapped => 1,
2951 }; 2967 };
2952 2968
2953 $self->add (@{ $para->{widget} }) if @{ $para->{widget} }; 2969 $self->add (@{ $para->{widget} }) if @{ $para->{widget} };
2954 push @{$self->{par}}, $para; 2970 push @{$self->{par}}, $para;
2971 }
2972
2973 if (my $max = $self->{max_par}) {
2974 shift @{$self->{par}} while @{$self->{par}} > $max;
2955 } 2975 }
2956 2976
2957 $self->{need_reflow}++; 2977 $self->{need_reflow}++;
2958 $self->update; 2978 $self->update;
2959} 2979}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines