--- deliantra/Deliantra-Client/DC/UI.pm 2006/05/15 18:23:33 1.207
+++ deliantra/Deliantra-Client/DC/UI.pm 2006/05/17 10:14:52 1.210
@@ -284,6 +284,17 @@
delete $self->{max_h}; $self->{max_h} = $h if $h;
}
+sub set_tooltip {
+ my ($self, $tooltip) = @_;
+
+ $self->{tooltip} = $tooltip;
+
+ if ($CFClient::UI::TOOLTIP->{owner} == $self) {
+ delete $CFClient::UI::TOOLTIP->{owner};
+ CFClient::UI::check_tooltip;
+ }
+}
+
# translate global coordinates to local coordinate system
sub coord2local {
my ($self, $x, $y) = @_;
@@ -457,8 +468,8 @@
# range [value, low, high, page]
$class->SUPER::new (
- bg => [0, 0, 0, 0.2],
- active_bg => [1, 1, 1, 0.5],
+ #bg => [0, 0, 0, 0.2],
+ #active_bg => [1, 1, 1, 0.5],
@_
)
}
@@ -466,20 +477,26 @@
sub _draw {
my ($self) = @_;
- my ($w, $h) = @$self{qw(w h)};
+ my $color = $FOCUS == $self && $self->{active_bg}
+ ? $self->{active_bg}
+ : $self->{bg};
- glEnable GL_BLEND;
- glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
- glColor @{ $FOCUS == $self ? $self->{active_bg} : $self->{bg} };
+ if ($color && (@$color < 4 || $color->[3])) {
+ my ($w, $h) = @$self{qw(w h)};
- glBegin GL_QUADS;
- glVertex 0 , 0;
- glVertex 0 , $h;
- glVertex $w, $h;
- glVertex $w, 0;
- glEnd;
+ glEnable GL_BLEND;
+ glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
+ glColor @$color;
- glDisable GL_BLEND;
+ glBegin GL_QUADS;
+ glVertex 0 , 0;
+ glVertex 0 , $h;
+ glVertex $w, $h;
+ glVertex $w, 0;
+ glEnd;
+
+ glDisable GL_BLEND;
+ }
}
#############################################################################
@@ -897,7 +914,7 @@
$h -= List::Util::max 0, $self->border * 2;
$w -= List::Util::max 0, $self->border * 2;
- $self->{title}->configure ($self->border, $self->border - $::FONTSIZE * 2, $w, $::FONTSIZE * 2)
+ $self->{title}->configure ($self->border, int $self->border - $::FONTSIZE * 2, $w, int $::FONTSIZE * 2)
if $self->{title};
$self->child->configure ($self->border, $self->border, $w, $h);
@@ -1268,7 +1285,7 @@
package CFClient::UI::Label;
-our @ISA = CFClient::UI::Base::;
+our @ISA = CFClient::UI::DrawBG::;
use CFClient::OpenGL;
@@ -1277,6 +1294,8 @@
my $self = $class->SUPER::new (
fg => [1, 1, 1],
+ #bg => none
+ #active_bg => none
#font => default_font
#text => initial text
#markup => initial narkup
@@ -1304,14 +1323,14 @@
$self
}
-sub escape {
- local $_ = $_[1];
+sub escape($) {
+ local $_ = $_[0];
s/&/&/g;
s/>/>/g;
s/</g;
- $_[1]
+ $_
}
sub update {
@@ -1393,6 +1412,8 @@
sub _draw {
my ($self) = @_;
+ $self->SUPER::_draw; # draw background, if applicable
+
my $tex = $self->{texture} ||= do {
$self->{layout}->set_foreground (@{$self->{fg}});
$self->{layout}->set_font ($self->{font}) if $self->{font};
@@ -1401,13 +1422,13 @@
my $tex = new_from_layout CFClient::Texture $self->{layout};
- $self->{ox} = int $self->{align} < 0 ? $self->{padding}
- : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding}
- : ($self->{w} - $tex->{w}) * 0.5;
-
- $self->{oy} = int $self->{valign} < 0 ? $self->{padding}
- : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding}
- : ($self->{h} - $tex->{h}) * 0.5;
+ $self->{ox} = int ($self->{align} < 0 ? $self->{padding}
+ : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding}
+ : ($self->{w} - $tex->{w}) * 0.5);
+
+ $self->{oy} = int ($self->{valign} < 0 ? $self->{padding}
+ : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding}
+ : ($self->{h} - $tex->{h}) * 0.5);
$tex
};
@@ -1472,8 +1493,8 @@
$self->{cursor} = length $text;
$self->_set_text ($text);
- $self->check_size;
$self->update;
+ $self->check_size;
}
sub get_text {
@@ -1523,6 +1544,7 @@
$self->_set_text ($text);
$self->update;
+ $self->check_size;
}
sub focus_in {
@@ -1661,7 +1683,6 @@
$class->SUPER::new (
padding => 4,
fg => [1, 1, 1],
- bg => [1, 1, 1, 0.2],
active_fg => [0, 0, 1],
can_hover => 1,
align => 0,
@@ -1719,6 +1740,8 @@
padding => 2,
fg => [1, 1, 1],
active_fg => [1, 1, 0],
+ bg => [0, 0, 0, 0.2],
+ active_bg => [1, 1, 1, 0.5],
state => 0,
can_hover => 1,
@_
@@ -2020,6 +2043,8 @@
my $self = $class->SUPER::new (
fg => [1, 1, 1],
active_fg => [0, 0, 0],
+ bg => [0, 0, 0, 0.2],
+ active_bg => [1, 1, 1, 0.5],
range => [0, 0, 100, 10],
req_w => $::WIDTH / 80,
req_h => $::WIDTH / 80,
@@ -2524,7 +2549,7 @@
my $self = $class->SUPER::new (
can_hover => 1,
can_events => 1,
- tooltip => (CFClient::UI::Label->escape ($desc)
+ tooltip => ((CFClient::UI::Label::escape $desc)
. "\nleftclick - pick up\nmiddle click - apply\nrightclick - menu"),
connect_button_down => sub {
my ($self, $ev, $x, $y) = @_;
@@ -2695,6 +2720,15 @@
our @ISA = CFClient::UI::VBox::;
+sub new {
+ my $class = shift;
+
+ $class->SUPER::new (
+ fontsize => 0.8,
+ @_,
+ )
+}
+
sub reorder {
my ($self) = @_;
my $NOW = time;
@@ -2720,10 +2754,12 @@
? "$item->{count} × $item->{text}"
: $item->{text};
+ my $fontsize = $item->{fontsize} || $self->{fontsize};
+
for ($short) {
s/^\s+//;
s/\s+/ /g;
- my $len = int 40 / $item->{fontsize};
+ my $len = int 40 / $fontsize;
substr $_, $len, length, "…" if $len < length;
}
@@ -2732,7 +2768,7 @@
tooltip => $item->{tooltip},
tooltip_font => $::FONT_PROP,
tooltip_width => 0.67,
- fontsize => $item->{fontsize},
+ fontsize => $fontsize,
fg => $item->{fg},
can_events => 1,
can_hover => 1
@@ -2769,7 +2805,6 @@
text => $text,
timeout => $timeout,
tooltip => $text,
- fontsize => 0.8,
fg => [0.8, 0.8, 0.8, 0.8],
pri => 0,
count => 1,