… | |
… | |
209 | } |
209 | } |
210 | } |
210 | } |
211 | |
211 | |
212 | sub size_allocate { |
212 | sub size_allocate { |
213 | # nothing to be done |
213 | # nothing to be done |
|
|
214 | } |
|
|
215 | |
|
|
216 | sub 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; |
214 | } |
221 | } |
215 | |
222 | |
216 | # return top left coordinates |
223 | # return top left coordinates |
217 | sub _topleft { |
224 | sub _topleft { |
218 | my ($self, $x, $y) = @_; |
225 | my ($self, $x, $y) = @_; |
… | |
… | |
1099 | sub new { |
1106 | sub new { |
1100 | my ($class, %arg) = @_; |
1107 | my ($class, %arg) = @_; |
1101 | |
1108 | |
1102 | my $self = $class->SUPER::new ( |
1109 | my $self = $class->SUPER::new ( |
1103 | fg => [1, 1, 1], |
1110 | fg => [1, 1, 1], |
|
|
1111 | #font => default_font |
1104 | fontsize => 1, |
1112 | fontsize => 1, |
1105 | text => "", |
1113 | text => "", |
1106 | align => -1, |
1114 | align => -1, |
1107 | valign => -1, |
1115 | valign => -1, |
1108 | padding => 2, |
1116 | padding => 2, |
… | |
… | |
1154 | } |
1162 | } |
1155 | |
1163 | |
1156 | sub size_request { |
1164 | sub size_request { |
1157 | my ($self) = @_; |
1165 | my ($self) = @_; |
1158 | |
1166 | |
1159 | $self->{layout}->set_width; |
1167 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
|
|
1168 | $self->{layout}->set_width ($self->{max_w} || -1); |
1160 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1169 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1161 | |
1170 | |
1162 | my ($w, $h) = $self->{layout}->size; |
1171 | my ($w, $h) = $self->{layout}->size; |
1163 | |
1172 | |
1164 | if (exists $self->{template}) { |
1173 | if (exists $self->{template}) { |
|
|
1174 | $self->{template}->set_font ($self->{font}) if $self->{font}; |
1165 | $self->{template}->set_height ($self->{fontsize} * $::FONTSIZE); |
1175 | $self->{template}->set_height ($self->{fontsize} * $::FONTSIZE); |
1166 | |
1176 | |
1167 | my ($w2, $h2) = $self->{template}->size; |
1177 | my ($w2, $h2) = $self->{template}->size; |
1168 | |
1178 | |
1169 | $w = List::Util::max $w, $w2; |
1179 | $w = List::Util::max $w, $w2; |
… | |
… | |
1193 | |
1203 | |
1194 | sub _draw { |
1204 | sub _draw { |
1195 | my ($self) = @_; |
1205 | my ($self) = @_; |
1196 | |
1206 | |
1197 | my $tex = $self->{texture} ||= do { |
1207 | my $tex = $self->{texture} ||= do { |
|
|
1208 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
1198 | $self->{layout}->set_width ($self->{w}); |
1209 | $self->{layout}->set_width ($self->{w}); |
1199 | $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); |
1200 | new_from_layout CFClient::Texture $self->{layout} |
1211 | new_from_layout CFClient::Texture $self->{layout} |
1201 | }; |
1212 | }; |
1202 | |
1213 | |
… | |
… | |
1907 | sub new { |
1918 | sub new { |
1908 | my $class = shift; |
1919 | my $class = shift; |
1909 | |
1920 | |
1910 | my $self = $class->SUPER::new ( |
1921 | my $self = $class->SUPER::new ( |
1911 | fontsize => 1, |
1922 | fontsize => 1, |
|
|
1923 | #font => default_font |
1912 | @_, |
1924 | @_, |
1913 | |
1925 | |
1914 | layout => (new CFClient::Layout), |
1926 | layout => (new CFClient::Layout), |
1915 | par => [], |
1927 | par => [], |
1916 | height => 0, |
1928 | height => 0, |
… | |
… | |
1956 | sub size_allocate { |
1968 | sub size_allocate { |
1957 | my ($self, $w, $h) = @_; |
1969 | my ($self, $w, $h) = @_; |
1958 | |
1970 | |
1959 | $self->SUPER::size_allocate ($w, $h); |
1971 | $self->SUPER::size_allocate ($w, $h); |
1960 | |
1972 | |
|
|
1973 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
1961 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1974 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1962 | $self->{layout}->set_width ($self->{children}[0]{w}); |
1975 | $self->{layout}->set_width ($self->{children}[0]{w}); |
1963 | |
1976 | |
1964 | $self->reflow; |
1977 | $self->reflow; |
1965 | } |
1978 | } |
… | |
… | |
2017 | my $y1 = $top + $self->{h}; |
2030 | my $y1 = $top + $self->{h}; |
2018 | |
2031 | |
2019 | my $y = 0; |
2032 | my $y = 0; |
2020 | |
2033 | |
2021 | my $layout = $self->{layout}; |
2034 | my $layout = $self->{layout}; |
|
|
2035 | |
|
|
2036 | $layout->set_font ($self->{font}) if $self->{font}; |
2022 | |
2037 | |
2023 | for my $par (@{$self->{par}}) { |
2038 | for my $par (@{$self->{par}}) { |
2024 | my $h = $par->[0]; |
2039 | my $h = $par->[0]; |
2025 | |
2040 | |
2026 | if ($y0 < $y + $h && $y < $y1) { |
2041 | if ($y0 < $y + $h && $y < $y1) { |
… | |
… | |
2162 | } |
2177 | } |
2163 | |
2178 | |
2164 | sub size_request { |
2179 | sub size_request { |
2165 | my ($self) = @_; |
2180 | my ($self) = @_; |
2166 | |
2181 | |
|
|
2182 | $self->child->set_max_size ($::WIDTH * 0.2); |
|
|
2183 | |
2167 | my ($w, $h) = @{$self->child}{qw(req_w req_h)}; |
2184 | my ($w, $h) = @{$self->child}{qw(req_w req_h)}; |
2168 | |
|
|
2169 | $w = List::Util::min $::WIDTH * 0.2, $w; |
|
|
2170 | $h = List::Util::max $::HEIGHT * 0.2, $h; |
|
|
2171 | |
2185 | |
2172 | ($w + 4, $h + 4) |
2186 | ($w + 4, $h + 4) |
2173 | } |
2187 | } |
2174 | |
2188 | |
2175 | sub _draw { |
2189 | sub _draw { |