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.354 by root, Sat Nov 18 23:31:23 2006 UTC vs.
Revision 1.358 by root, Fri Dec 8 14:59:54 2006 UTC

523 ? $args[0]->xy ($self) 523 ? $args[0]->xy ($self)
524 : (); 524 : ();
525 525
526 #warn +(caller(1))[3] . "emit $signal on $self (parent $self->{parent})\n";#d# 526 #warn +(caller(1))[3] . "emit $signal on $self (parent $self->{parent})\n";#d#
527 527
528 if ($self->{tooltip} =~ /Apply.*audio/) {
529 warn "2 ", join ":", @{ $self->{signal_cb}{$signal} || []}, "\n";#d#
530 warn "3 $self->{parent}\n";#d#
531 }
532
533 #d##TODO# stop propagating at first true, do not use sum 528 #d##TODO# stop propagating at first true, do not use sum
534 my $res =
535 (List::Util::sum map $_->($self, @args, @append), @{$self->{signal_cb}{$signal} || []}) # before 529 (List::Util::sum map $_->($self, @args, @append), @{$self->{signal_cb}{$signal} || []}) # before
536 || ($self->can ("invoke_$signal") || sub { 1 })->($self, @args, @append) # closure 530 || ($self->can ("invoke_$signal") || sub { 1 })->($self, @args, @append) # closure
537 || ($self->{parent} && $self->{parent}->emit ($signal, @args)) # parent 531 || ($self->{parent} && $self->{parent}->emit ($signal, @args)) # parent
538 ;
539 if ($self->{tooltip} =~ /Apply.*audio/) {
540 warn "4 ", join ":", @{ $self->{signal_cb}{$signal} || []}, "\n";#d#
541 warn "5 $self->{parent}\n";#d#
542 }
543
544 $res
545} 532}
546 533
547sub find_widget { 534sub find_widget {
548 my ($self, $x, $y) = @_; 535 my ($self, $x, $y) = @_;
549 536
1913 active_fg => [0, 0, 0], 1900 active_fg => [0, 0, 0],
1914 can_hover => 1, 1901 can_hover => 1,
1915 can_focus => 1, 1902 can_focus => 1,
1916 valign => 0, 1903 valign => 0,
1917 can_events => 1, 1904 can_events => 1,
1905 ellipsise => 0,
1918 #text => ... 1906 #text => ...
1919 #hidden => "*", 1907 #hidden => "*",
1920 @_ 1908 @_
1921 ) 1909 )
1922} 1910}
1984 } elsif ($uni == 21) { # ctrl-u 1972 } elsif ($uni == 21) { # ctrl-u
1985 $text = ""; 1973 $text = "";
1986 $self->{cursor} = 0; 1974 $self->{cursor} = 0;
1987 } elsif ($uni == 27) { 1975 } elsif ($uni == 27) {
1988 $self->emit ('escape'); 1976 $self->emit ('escape');
1989 } elsif ($uni) { 1977 } elsif ($uni >= 0x20) {
1990 substr $text, $self->{cursor}++, 0, chr $uni; 1978 substr $text, $self->{cursor}++, 0, chr $uni;
1991 } else { 1979 } else {
1992 return 0; 1980 return 0;
1993 } 1981 }
1994 1982
1995 $self->_set_text ($text); 1983 $self->_set_text ($text);
1996 1984
1997 $self->realloc; 1985 $self->realloc;
1986 $self->update;
1998 1987
1999 1 1988 1
2000} 1989}
2001 1990
2002sub invoke_focus_in { 1991sub invoke_focus_in {
2070 glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy}; 2059 glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy};
2071 glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy} + $self->{cur_h}; 2060 glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy} + $self->{cur_h};
2072 glEnd; 2061 glEnd;
2073 } 2062 }
2074} 2063}
2064
2065#############################################################################
2075 2066
2076package CFPlus::UI::Entry; 2067package CFPlus::UI::Entry;
2077 2068
2078our @ISA = CFPlus::UI::EntryBase::; 2069our @ISA = CFPlus::UI::EntryBase::;
2079 2070
2113 $self->set_text ($self->{history}->[$self->{history_pointer}]); 2104 $self->set_text ($self->{history}->[$self->{history_pointer}]);
2114 } else { 2105 } else {
2115 $self->set_text ($self->{history_saveback}); 2106 $self->set_text ($self->{history_saveback});
2116 } 2107 }
2117 2108
2109 } else {
2110 return $self->SUPER::invoke_key_down ($ev)
2111 }
2112
2113 1
2114}
2115
2116#############################################################################
2117
2118package CFPlus::UI::TextEdit;
2119
2120our @ISA = CFPlus::UI::EntryBase::;
2121
2122use CFPlus::OpenGL;
2123
2124sub move_cursor_ver {
2125 my ($self, $dy) = @_;
2126
2127 my ($y, $x) = $self->{layout}->index_to_line_x ($self->{cursor});
2128
2129 do {
2130 if (defined (my $index = $self->{layout}->line_x_to_index ($y + $dy, $x))) {
2131 $self->{cursor} = $index;
2132 delete $self->{cur_h};
2133 $self->update;
2134 return;
2135 }
2136 } while --$x >= 0;
2137}
2138
2139sub invoke_key_down {
2140 my ($self, $ev) = @_;
2141
2142 my $sym = $ev->{sym};
2143
2144 if ($sym == CFPlus::SDLK_UP) {
2145 $self->move_cursor_ver (-1);
2146 } elsif ($sym == CFPlus::SDLK_DOWN) {
2147 $self->move_cursor_ver (+1);
2118 } else { 2148 } else {
2119 return $self->SUPER::invoke_key_down ($ev) 2149 return $self->SUPER::invoke_key_down ($ev)
2120 } 2150 }
2121 2151
2122 1 2152 1
3840 if ($ev->{button} == 1) { 3870 if ($ev->{button} == 1) {
3841 $::CONN->user_send ("cast $spell->{name}"); 3871 $::CONN->user_send ("cast $spell->{name}");
3842 } elsif ($ev->{button} == 2) { 3872 } elsif ($ev->{button} == 2) {
3843 $::CONN->user_send ("invoke $spell->{name}"); 3873 $::CONN->user_send ("invoke $spell->{name}");
3844 } elsif ($ev->{button} == 3) { 3874 } elsif ($ev->{button} == 3) {
3875 my $shortname = CFPlus::shorten $spell->{name}, 14;
3845 (new CFPlus::UI::Menu 3876 (new CFPlus::UI::Menu
3846 items => [ 3877 items => [
3847 ["bind <i>cast $spell->{name}</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }], 3878 ["bind <i>cast $shortname</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }],
3848 ["bind <i>invoke $spell->{name}</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["invoke $spell->{name}"]) }], 3879 ["bind <i>invoke $shortname</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["invoke $spell->{name}"]) }],
3849 ], 3880 ],
3850 )->popup ($ev); 3881 )->popup ($ev);
3851 } else { 3882 } else {
3852 return 0; 3883 return 0;
3853 } 3884 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines