… | |
… | |
514 | ); |
514 | ); |
515 | |
515 | |
516 | sub emit { |
516 | sub emit { |
517 | my ($self, $signal, @args) = @_; |
517 | my ($self, $signal, @args) = @_; |
518 | |
518 | |
519 | # I do not really like this solution, but I dislike duplication |
519 | # I do not really like this solution, but I do not like duplication |
520 | # and needlessly verbose code, too. |
520 | # and needlessly verbose code, either. |
521 | my @append |
521 | my @append |
522 | = $has_coords{$signal} |
522 | = $has_coords{$signal} |
523 | ? $args[0]->xy ($self) |
523 | ? $args[0]->xy ($self) |
524 | : (); |
524 | : (); |
525 | |
525 | |
… | |
… | |
1900 | active_fg => [0, 0, 0], |
1900 | active_fg => [0, 0, 0], |
1901 | can_hover => 1, |
1901 | can_hover => 1, |
1902 | can_focus => 1, |
1902 | can_focus => 1, |
1903 | valign => 0, |
1903 | valign => 0, |
1904 | can_events => 1, |
1904 | can_events => 1, |
|
|
1905 | ellipsise => 0, |
1905 | #text => ... |
1906 | #text => ... |
1906 | #hidden => "*", |
1907 | #hidden => "*", |
1907 | @_ |
1908 | @_ |
1908 | ) |
1909 | ) |
1909 | } |
1910 | } |
… | |
… | |
1980 | } |
1981 | } |
1981 | |
1982 | |
1982 | $self->_set_text ($text); |
1983 | $self->_set_text ($text); |
1983 | |
1984 | |
1984 | $self->realloc; |
1985 | $self->realloc; |
|
|
1986 | $self->update; |
1985 | |
1987 | |
1986 | 1 |
1988 | 1 |
1987 | } |
1989 | } |
1988 | |
1990 | |
1989 | sub invoke_focus_in { |
1991 | sub invoke_focus_in { |
… | |
… | |
2057 | 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}; |
2058 | 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}; |
2059 | glEnd; |
2061 | glEnd; |
2060 | } |
2062 | } |
2061 | } |
2063 | } |
|
|
2064 | |
|
|
2065 | ############################################################################# |
2062 | |
2066 | |
2063 | package CFPlus::UI::Entry; |
2067 | package CFPlus::UI::Entry; |
2064 | |
2068 | |
2065 | our @ISA = CFPlus::UI::EntryBase::; |
2069 | our @ISA = CFPlus::UI::EntryBase::; |
2066 | |
2070 | |
… | |
… | |
2100 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
2104 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
2101 | } else { |
2105 | } else { |
2102 | $self->set_text ($self->{history_saveback}); |
2106 | $self->set_text ($self->{history_saveback}); |
2103 | } |
2107 | } |
2104 | |
2108 | |
|
|
2109 | } elsif ($ev->{unicode} >= 0x20) { |
|
|
2110 | return $self->SUPER::invoke_key_down ($ev) |
|
|
2111 | } |
|
|
2112 | |
|
|
2113 | 1 |
|
|
2114 | } |
|
|
2115 | |
|
|
2116 | ############################################################################# |
|
|
2117 | |
|
|
2118 | package CFPlus::UI::TextEdit; |
|
|
2119 | |
|
|
2120 | our @ISA = CFPlus::UI::EntryBase::; |
|
|
2121 | |
|
|
2122 | use CFPlus::OpenGL; |
|
|
2123 | |
|
|
2124 | sub move_cursor_ver { |
|
|
2125 | my ($self, $dy) = @_; |
|
|
2126 | |
|
|
2127 | my ($y, $x) = $self->{layout}->index_to_line_x ($self->{cursor}); |
|
|
2128 | |
|
|
2129 | $y += $dy; |
|
|
2130 | |
|
|
2131 | if (defined (my $index = $self->{layout}->line_x_to_index ($y, $x))) { |
|
|
2132 | $self->{cursor} = $index; |
|
|
2133 | delete $self->{cur_h}; |
|
|
2134 | $self->update; |
|
|
2135 | return; |
|
|
2136 | } |
|
|
2137 | } |
|
|
2138 | |
|
|
2139 | sub 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); |
2105 | } else { |
2148 | } else { |
2106 | return $self->SUPER::invoke_key_down ($ev) |
2149 | return $self->SUPER::invoke_key_down ($ev) |
2107 | } |
2150 | } |
2108 | |
2151 | |
2109 | 1 |
2152 | 1 |
… | |
… | |
3827 | if ($ev->{button} == 1) { |
3870 | if ($ev->{button} == 1) { |
3828 | $::CONN->user_send ("cast $spell->{name}"); |
3871 | $::CONN->user_send ("cast $spell->{name}"); |
3829 | } elsif ($ev->{button} == 2) { |
3872 | } elsif ($ev->{button} == 2) { |
3830 | $::CONN->user_send ("invoke $spell->{name}"); |
3873 | $::CONN->user_send ("invoke $spell->{name}"); |
3831 | } elsif ($ev->{button} == 3) { |
3874 | } elsif ($ev->{button} == 3) { |
|
|
3875 | my $shortname = CFPlus::shorten $spell->{name}, 14; |
3832 | (new CFPlus::UI::Menu |
3876 | (new CFPlus::UI::Menu |
3833 | items => [ |
3877 | items => [ |
3834 | ["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}"]) }], |
3835 | ["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}"]) }], |
3836 | ], |
3880 | ], |
3837 | )->popup ($ev); |
3881 | )->popup ($ev); |
3838 | } else { |
3882 | } else { |
3839 | return 0; |
3883 | return 0; |
3840 | } |
3884 | } |