| 252 | } |
| 253 | |
| 254 | void WrapPanel::floatArrange() |
| 255 | { |
| 256 | size_t count = getChildCount(); |
| 257 | |
| 258 | if (count == 0) |
| 259 | return; |
| 260 | |
| 261 | Widget* firstChild = getChildAt(0); |
| 262 | IntSize firstSize = Panel::getDesiredSize(firstChild); |
| 263 | if (mSnapFloat.isRight()) |
| 264 | Panel::updateArrange( |
| 265 | firstChild, |
| 266 | IntCoord(getWidth() - firstSize.width, 0, firstSize.width, firstSize.height)); |
| 267 | else |
| 268 | Panel::updateArrange(firstChild, IntCoord(0, 0, firstSize.width, firstSize.height)); |
| 269 | |
| 270 | if (count == 1) |
| 271 | return; |
| 272 | |
| 273 | IntCoord coordAvailable(0, 0, getWidth(), getHeight()); |
| 274 | IntPoint currentPosition; |
| 275 | |
| 276 | int maxLineHeight = 0; |
| 277 | bool hasAnyWidget = false; |
| 278 | size_t startLineIndex = 1; |
| 279 | |
| 280 | for (size_t index = 1; index < count; ++index) |
| 281 | { |
| 282 | bool floatBehaivoir = ((firstSize.height + mSpacer.height) > currentPosition.top); |
| 283 | |
| 284 | if (floatBehaivoir) |
| 285 | { |
| 286 | if (mSnapFloat.isRight()) |
| 287 | coordAvailable.left = 0; |
| 288 | else |
| 289 | coordAvailable.left = firstSize.width + mSpacer.width; |
| 290 | coordAvailable.width = getWidth() - (firstSize.width + mSpacer.width); |
| 291 | } |
| 292 | else |
| 293 | { |
| 294 | coordAvailable.left = 0; |
| 295 | coordAvailable.width = getWidth(); |
| 296 | } |
| 297 | |
| 298 | Widget* child = getChildAt(index); |
| 299 | IntSize size = Panel::getDesiredSize(child); |
| 300 | |
| 301 | if ((currentPosition.left + size.width) > coordAvailable.width) |
| 302 | { |
| 303 | if (hasAnyWidget || floatBehaivoir) |
| 304 | { |
| 305 | alignChildLine( |
| 306 | startLineIndex, |
| 307 | index, |
| 308 | IntCoord(coordAvailable.left, currentPosition.top, coordAvailable.width, maxLineHeight), |
| 309 | currentPosition.left - mSpacer.width); |
| 310 | |
| 311 | currentPosition.left = 0; |