@@ -488,26 +488,16 @@ root openInNewSpace.
488488
489489### Flow layout - BlFlowLayout
490490
491- Children need to specify their size. If they use constraint, the last one will hide
492- previous one. They will fit available space + move to next line if necessary .
493- Flow will fill all available space in its parent, and parent can be resized to
494- match the space needed to display all its children .
491+ A flow layout is used when you need to display a multiple children elements next to each others.
492+ A flow layout can diplay the children elements horizontaly or verticaly .
493+ If a flow layout does not have enought place to display the next child element, it will create a new row or column to display the next children.
494+ It works like a text editor, a word is added to the next line when the space is not enought to fit it .
495495
496- #### Parent definition
497-
498- - horizontal
499- - vertical
496+ There is special display constraint for the children elements: the value is either ` inline ` or ` float ` .
497+ By default, all children are ` inline ` .
498+ In the case of a horizontal flow layout, the height of a line is equal to the maximum height of all inline elements of this line.
499+ If a child element has a display equals to ` flow ` , the other elements will be placed around it.
500500
501- #### Child constraints
502-
503- - horizontal
504- - alignCenter
505- - alignLeft
506- - alignRight
507- - vertical
508- - alignBottom
509- - alignCenter
510- - alignTop
511501
512502#### Example
513503
@@ -516,22 +506,34 @@ root := BlElement new
516506 border: (BlBorder paint: Color red width: 1);
517507 background: (Color red alpha: 0.2);
518508 layout: BlFlowLayout horizontal;
519- constraintsDo: [ :c |
520- c horizontal matchParent .
521- c vertical fitContent ].
509+ constraintsDo: [ :c |
510+ c horizontal matchParent.
511+ c vertical matchParent ];
512+ yourself.
513+
514+ 1 to: 100 do: [ :index | | child |
515+ child := BlElement new
516+ border: (BlBorder paint: Color blue width: 1);
517+ background: (Color blue alpha: 0.2);
518+ margin: (BlInsets all: 5);
519+ addChild: (BlTextElement text: index printString asRopedText);
520+ constraintsDo: [ :c |
521+ c horizontal exact: 20.
522+ c vertical exact: 20. ];
523+ yourself.
524+ index = 22 ifTrue: [
525+ child background: Color blue;
526+ size: 50 @ 60;
527+ constraintsDo: [ :c | c flow float ] ].
528+ index = 60 ifTrue: [
529+ child background: Color green;
530+ size: 50 @ 60 ].
531+ root addChild: child
532+ ].
522533
523- 50 timesRepeat: [
524- | elt |
525- elt := BlElement new
526- size: 40 @ 80;
527- border: (BlBorder paint: Color blue width: 1);
528- background: (Color blue alpha: 0.2);
529- margin: (BlInsets all: 5).
530- root addChild: elt ].
534+ root openInNewSpace.
531535```
532536
533- ![ Flow layout.] (figures/flowlayout.png width=70)
534-
535537### Grid layout - BlGridLayout
536538
537539Elements are disposed in a grid. An element can span over multiple rows or columns.
0 commit comments