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.154 by root, Sun Apr 23 02:20:57 2006 UTC vs.
Revision 1.157 by root, Sun Apr 23 21:47:32 2006 UTC

18 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { 18 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) {
19 if (exists $widget->{tooltip}) { 19 if (exists $widget->{tooltip}) {
20 20
21 if ($TOOLTIP->{owner} != $widget) { 21 if ($TOOLTIP->{owner} != $widget) {
22 $TOOLTIP->{owner} = $widget; 22 $TOOLTIP->{owner} = $widget;
23
24 my $tip = $widget->{tooltip};
25
26 $tip = $tip->($widget) if CODE:: eq ref $tip;
27
23 $TOOLTIP->set_text ($widget->{tooltip}); 28 $TOOLTIP->set_text ($widget->{tooltip});
24 $TOOLTIP->move ($widget->coord2global ($widget->{w}, 0)); 29 $TOOLTIP->move ($widget->coord2global ($widget->{w}, 0));
25 $TOOLTIP->show; 30 $TOOLTIP->show;
26 } 31 }
27 32
204 } 209 }
205} 210}
206 211
207sub size_allocate { 212sub size_allocate {
208 # nothing to be done 213 # nothing to be done
214}
215
216sub set_max_size {
217 my ($self, $w, $h) = @_;
218
219 delete $self->{max_w}; $self->{max_w} = $w if $w;
220 delete $self->{max_h}; $self->{max_h} = $h if $h;
209} 221}
210 222
211# return top left coordinates 223# return top left coordinates
212sub _topleft { 224sub _topleft {
213 my ($self, $x, $y) = @_; 225 my ($self, $x, $y) = @_;
1094sub new { 1106sub new {
1095 my ($class, %arg) = @_; 1107 my ($class, %arg) = @_;
1096 1108
1097 my $self = $class->SUPER::new ( 1109 my $self = $class->SUPER::new (
1098 fg => [1, 1, 1], 1110 fg => [1, 1, 1],
1111 #font => default_font
1099 fontsize => 1, 1112 fontsize => 1,
1100 text => "", 1113 text => "",
1101 align => -1, 1114 align => -1,
1102 valign => -1, 1115 valign => -1,
1103 padding => 2, 1116 padding => 2,
1149} 1162}
1150 1163
1151sub size_request { 1164sub size_request {
1152 my ($self) = @_; 1165 my ($self) = @_;
1153 1166
1154 $self->{layout}->set_width; 1167 $self->{layout}->set_font ($self->{font}) if $self->{font};
1168 $self->{layout}->set_width ($self->{max_w} || -1);
1155 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); 1169 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE);
1156 1170
1157 my ($w, $h) = $self->{layout}->size; 1171 my ($w, $h) = $self->{layout}->size;
1158 1172
1159 if (exists $self->{template}) { 1173 if (exists $self->{template}) {
1174 $self->{template}->set_font ($self->{font}) if $self->{font};
1160 $self->{template}->set_height ($self->{fontsize} * $::FONTSIZE); 1175 $self->{template}->set_height ($self->{fontsize} * $::FONTSIZE);
1161 1176
1162 my ($w2, $h2) = $self->{template}->size; 1177 my ($w2, $h2) = $self->{template}->size;
1163 1178
1164 $w = List::Util::max $w, $w2; 1179 $w = List::Util::max $w, $w2;
1188 1203
1189sub _draw { 1204sub _draw {
1190 my ($self) = @_; 1205 my ($self) = @_;
1191 1206
1192 my $tex = $self->{texture} ||= do { 1207 my $tex = $self->{texture} ||= do {
1208 $self->{layout}->set_font ($self->{font}) if $self->{font};
1193 $self->{layout}->set_width ($self->{w}); 1209 $self->{layout}->set_width ($self->{w});
1194 $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize} * $::FONTSIZE); 1210 $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize} * $::FONTSIZE);
1195 new_from_layout CFClient::Texture $self->{layout} 1211 new_from_layout CFClient::Texture $self->{layout}
1196 }; 1212 };
1197 1213
1723 my $self = $class->SUPER::new ( 1739 my $self = $class->SUPER::new (
1724 tooltip => $arg{type}, 1740 tooltip => $arg{type},
1725 %arg, 1741 %arg,
1726 ); 1742 );
1727 1743
1728 $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999"); 1744 $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999", can_events => 1, can_hover => 1);
1729 $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1); 1745 $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, can_events => 1, can_hover => 1);
1730 $self->add ($self->{max} = new CFClient::UI::Label valign => -1, align => 0, template => "999"); 1746 $self->add ($self->{max} = new CFClient::UI::Label valign => -1, align => 0, template => "999", can_events => 1, can_hover => 1);
1731 1747
1732 $self 1748 $self
1733} 1749}
1734 1750
1735sub set_fontsize { 1751sub set_fontsize {
1902sub new { 1918sub new {
1903 my $class = shift; 1919 my $class = shift;
1904 1920
1905 my $self = $class->SUPER::new ( 1921 my $self = $class->SUPER::new (
1906 fontsize => 1, 1922 fontsize => 1,
1923 #font => default_font
1907 @_, 1924 @_,
1908 1925
1909 layout => (new CFClient::Layout), 1926 layout => (new CFClient::Layout),
1910 par => [], 1927 par => [],
1911 height => 0, 1928 height => 0,
1951sub size_allocate { 1968sub size_allocate {
1952 my ($self, $w, $h) = @_; 1969 my ($self, $w, $h) = @_;
1953 1970
1954 $self->SUPER::size_allocate ($w, $h); 1971 $self->SUPER::size_allocate ($w, $h);
1955 1972
1973 $self->{layout}->set_font ($self->{font}) if $self->{font};
1956 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); 1974 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE);
1957 $self->{layout}->set_width ($self->{children}[0]{w}); 1975 $self->{layout}->set_width ($self->{children}[0]{w});
1958 1976
1959 $self->reflow; 1977 $self->reflow;
1960} 1978}
2012 my $y1 = $top + $self->{h}; 2030 my $y1 = $top + $self->{h};
2013 2031
2014 my $y = 0; 2032 my $y = 0;
2015 2033
2016 my $layout = $self->{layout}; 2034 my $layout = $self->{layout};
2035
2036 $layout->set_font ($self->{font}) if $self->{font};
2017 2037
2018 for my $par (@{$self->{par}}) { 2038 for my $par (@{$self->{par}}) {
2019 my $h = $par->[0]; 2039 my $h = $par->[0];
2020 2040
2021 if ($y0 < $y + $h && $y < $y1) { 2041 if ($y0 < $y + $h && $y < $y1) {
2157} 2177}
2158 2178
2159sub size_request { 2179sub size_request {
2160 my ($self) = @_; 2180 my ($self) = @_;
2161 2181
2182 $self->child->set_max_size ($::WIDTH * 0.2);
2183
2162 my ($w, $h) = @{$self->child}{qw(req_w req_h)}; 2184 my ($w, $h) = @{$self->child}{qw(req_w req_h)};
2163
2164 $w = List::Util::min $::WIDTH * 0.2, $w;
2165 $h = List::Util::max $::HEIGHT * 0.2, $h;
2166 2185
2167 ($w + 4, $h + 4) 2186 ($w + 4, $h + 4)
2168} 2187}
2169 2188
2170sub _draw { 2189sub _draw {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines