--- deliantra/Deliantra-Client/DC/UI.pm 2006/10/01 12:08:58 1.351
+++ deliantra/Deliantra-Client/DC/UI.pm 2006/12/08 14:59:54 1.358
@@ -516,8 +516,8 @@
sub emit {
my ($self, $signal, @args) = @_;
- # I do not really like this solution, but I dislike duplication
- # and needlessly verbose code, too.
+ # I do not really like this solution, but I do not like duplication
+ # and needlessly verbose code, either.
my @append
= $has_coords{$signal}
? $args[0]->xy ($self)
@@ -902,9 +902,9 @@
local ($draw_x, $draw_y, $draw_w, $draw_h) =
(0, 0, $self->{w}, $self->{h});
- }
- $self->_render;
+ $self->_render;
+ }
};
}
@@ -1902,6 +1902,7 @@
can_focus => 1,
valign => 0,
can_events => 1,
+ ellipsise => 0,
#text => ...
#hidden => "*",
@_
@@ -1973,7 +1974,7 @@
$self->{cursor} = 0;
} elsif ($uni == 27) {
$self->emit ('escape');
- } elsif ($uni) {
+ } elsif ($uni >= 0x20) {
substr $text, $self->{cursor}++, 0, chr $uni;
} else {
return 0;
@@ -1982,6 +1983,7 @@
$self->_set_text ($text);
$self->realloc;
+ $self->update;
1
}
@@ -2060,6 +2062,8 @@
}
}
+#############################################################################
+
package CFPlus::UI::Entry;
our @ISA = CFPlus::UI::EntryBase::;
@@ -2111,6 +2115,45 @@
#############################################################################
+package CFPlus::UI::TextEdit;
+
+our @ISA = CFPlus::UI::EntryBase::;
+
+use CFPlus::OpenGL;
+
+sub move_cursor_ver {
+ my ($self, $dy) = @_;
+
+ my ($y, $x) = $self->{layout}->index_to_line_x ($self->{cursor});
+
+ do {
+ if (defined (my $index = $self->{layout}->line_x_to_index ($y + $dy, $x))) {
+ $self->{cursor} = $index;
+ delete $self->{cur_h};
+ $self->update;
+ return;
+ }
+ } while --$x >= 0;
+}
+
+sub invoke_key_down {
+ my ($self, $ev) = @_;
+
+ my $sym = $ev->{sym};
+
+ if ($sym == CFPlus::SDLK_UP) {
+ $self->move_cursor_ver (-1);
+ } elsif ($sym == CFPlus::SDLK_DOWN) {
+ $self->move_cursor_ver (+1);
+ } else {
+ return $self->SUPER::invoke_key_down ($ev)
+ }
+
+ 1
+}
+
+#############################################################################
+
package CFPlus::UI::Button;
our @ISA = CFPlus::UI::Label::;
@@ -2961,12 +3004,9 @@
glClearColor 0, 0, 0, 0;
glClear GL_COLOR_BUFFER_BIT;
- {
- package CFPlus::UI::Base;
-
- local ($draw_x, $draw_y, $draw_w, $draw_h) =
- (0, 0, $self->{w}, $self->{h});
- }
+ package CFPlus::UI::Base;
+ local ($draw_x, $draw_y, $draw_w, $draw_h) =
+ (0, 0, $self->{w}, $self->{h});
my $top = int $self->{children}[1]{range}[0];
@@ -3293,7 +3333,7 @@
our @ISA = CFPlus::UI::HBox::;
-# TODO: should actualyl wrap buttons and other goodies.
+# TODO: should actually wrap buttons and other goodies.
#############################################################################
@@ -3832,10 +3872,11 @@
} elsif ($ev->{button} == 2) {
$::CONN->user_send ("invoke $spell->{name}");
} elsif ($ev->{button} == 3) {
+ my $shortname = CFPlus::shorten $spell->{name}, 14;
(new CFPlus::UI::Menu
items => [
- ["bind cast $spell->{name} to a key" => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }],
- ["bind invoke $spell->{name} to a key" => sub { $::BIND_EDITOR->do_quick_binding (["invoke $spell->{name}"]) }],
+ ["bind cast $shortname to a key" => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }],
+ ["bind invoke $shortname to a key" => sub { $::BIND_EDITOR->do_quick_binding (["invoke $spell->{name}"]) }],
],
)->popup ($ev);
} else {
@@ -4135,9 +4176,9 @@
local ($draw_x, $draw_y, $draw_w, $draw_h) =
(0, 0, $self->{w}, $self->{h});
- }
- $self->_draw;
+ $self->_draw;
+ }
}
#############################################################################