1: <?php
2: /**
3: * ManiaLib - Lightweight PHP framework for Manialinks
4: *
5: * @see http://code.google.com/p/manialib/
6: * @copyright Copyright (c) 2009-2011 NADEO (http://www.nadeo.com)
7: * @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
8: * @version $Revision: 590 $:
9: * @author $Author: maximeraoust $:
10: * @date $Date: 2011-12-27 19:40:38 +0100 (mar., 27 déc. 2011) $:
11: */
12:
13: namespace ManiaLib\Gui\Layouts;
14:
15: /**
16: * Column-like, items fill vertically the current column then the next one on the right etc.
17: */
18: class VerticalFlow extends AbstractLayout
19: {
20:
21: protected $maxWidth = 0;
22: protected $currentColumnElementCount = 0;
23:
24: function preFilter(\ManiaLib\Gui\Component $item)
25: {
26: // add minimal number to avoid floating error
27: $availableHeight = $this->sizeY + $this->yIndex - $this->borderHeight + 0.1;
28:
29: // If end of the line is reached
30: if($availableHeight < $item->getRealSizeY() & $this->currentColumnElementCount > 0)
31: {
32: $this->xIndex += $this->maxWidth + $this->marginWidth;
33: $this->yIndex = $this->borderHeight;
34: $this->currentColumnElementCount = 0;
35: $this->maxWidth = 0;
36: }
37: }
38:
39: function postFilter(\ManiaLib\Gui\Component $item)
40: {
41: $this->yIndex -= $item->getRealSizeY() + $this->marginHeight;
42: if(!$this->maxWidth || $item->getRealSizeX() > $this->maxWidth)
43: {
44: $this->maxWidth = $item->getRealSizeX();
45: }
46: $this->currentColumnElementCount++;
47: }
48:
49: }
50:
51: ?>