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.340 by root, Sun Jul 30 13:16:44 2006 UTC vs.
Revision 1.344 by root, Sun Aug 13 16:29:36 2006 UTC

6use Scalar::Util (); 6use Scalar::Util ();
7use List::Util (); 7use List::Util ();
8use Event; 8use Event;
9 9
10use CFPlus; 10use CFPlus;
11use CFPlus::Pod;
11use CFPlus::Texture; 12use CFPlus::Texture;
12 13
13our ($FOCUS, $HOVER, $GRAB); # various widgets 14our ($FOCUS, $HOVER, $GRAB); # various widgets
14 15
15our $LAYOUT; 16our $LAYOUT;
908} 909}
909 910
910sub _draw { 911sub _draw {
911 my ($self) = @_; 912 my ($self) = @_;
912 913
913 my ($w, $h) = @$self{qw(w h)};
914
915 my $tex = $self->{texture} 914 my $tex = $self->{texture}
916 or return; 915 or return;
917 916
918 glEnable GL_TEXTURE_2D; 917 glEnable GL_TEXTURE_2D;
919 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 918 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
920 glColor 0, 0, 0, 1; 919 glColor 0, 0, 0, 1;
921 920
922 $tex->draw_quad_alpha_premultiplied (0, 0, $w, $h); 921 $tex->draw_quad_alpha_premultiplied (0, 0);
923 922
924 glDisable GL_TEXTURE_2D; 923 glDisable GL_TEXTURE_2D;
925} 924}
926 925
927############################################################################# 926#############################################################################
1617 #active_bg => none 1616 #active_bg => none
1618 #font => default_font 1617 #font => default_font
1619 #text => initial text 1618 #text => initial text
1620 #markup => initial narkup 1619 #markup => initial narkup
1621 #max_w => maximum pixel width 1620 #max_w => maximum pixel width
1621 #style => 0, # render flags
1622 ellipsise => 3, # end 1622 ellipsise => 3, # end
1623 layout => (new CFPlus::Layout), 1623 layout => (new CFPlus::Layout),
1624 fontsize => 1, 1624 fontsize => 1,
1625 align => -1, 1625 align => -1,
1626 valign => -1, 1626 valign => -1,
1777 }; 1777 };
1778 1778
1779 my $w = List::Util::min $self->{w} + 4, $size->[0]; 1779 my $w = List::Util::min $self->{w} + 4, $size->[0];
1780 my $h = List::Util::min $self->{h} + 2, $size->[1]; 1780 my $h = List::Util::min $self->{h} + 2, $size->[1];
1781 1781
1782 $self->{layout}->render ($self->{ox}, $self->{oy}); 1782 $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style});
1783} 1783}
1784 1784
1785############################################################################# 1785#############################################################################
1786 1786
1787package CFPlus::UI::EntryBase; 1787package CFPlus::UI::EntryBase;
1948 utf8::encode $text; 1948 utf8::encode $text;
1949 1949
1950 @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text) 1950 @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text)
1951 } 1951 }
1952 1952
1953 glColor @{$self->{fg}};
1954 glBegin GL_LINES; 1953 glBegin GL_LINES;
1955 glVertex $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy}; 1954 glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy};
1956 glVertex $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy} + $self->{cur_h}; 1955 glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy} + $self->{cur_h};
1957 glEnd; 1956 glEnd;
1958 } 1957 }
1959} 1958}
1960 1959
1961package CFPlus::UI::Entry; 1960package CFPlus::UI::Entry;
2977} 2976}
2978 2977
2979sub set_tooltip_from { 2978sub set_tooltip_from {
2980 my ($self, $widget) = @_; 2979 my ($self, $widget) = @_;
2981 2980
2981 $widget->{tooltip} = CFPlus::Pod::section_label tooltip => $1
2982 if $widget->{tooltip} =~ /^#(.*)$/;
2983
2982 my $tooltip = $widget->{tooltip}; 2984 my $tooltip = $widget->{tooltip};
2983 2985
2984 if ($ENV{CFPLUS_DEBUG} & 2) { 2986 if ($ENV{CFPLUS_DEBUG} & 2) {
2985 $tooltip .= "\n\n" . (ref $widget) . "\n" 2987 $tooltip .= "\n\n" . (ref $widget) . "\n"
2986 . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n" 2988 . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n"
2993 2995
2994 $self->add (new CFPlus::UI::Label 2996 $self->add (new CFPlus::UI::Label
2995 markup => $tooltip, 2997 markup => $tooltip,
2996 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, 2998 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH,
2997 fontsize => 0.8, 2999 fontsize => 0.8,
2998 fg => [0, 0, 0, 1], 3000 style => 1, # FLAG_INVERSE
2999 ellipsise => 0, 3001 ellipsise => 0,
3000 font => ($widget->{tooltip_font} || $::FONT_PROP), 3002 font => ($widget->{tooltip_font} || $::FONT_PROP),
3001 ); 3003 );
3002} 3004}
3003 3005

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines