FreeLayout class
The free layout (default).
class FreeLayout extends AbstractLayout { int measureWidth(MeasureContext mctx, View view) { int wd = mctx.getWidthByApp(view); if (wd == null) { wd = view.clientWidth; for (final View child in view.children) { if (view.shallLayout_(child) && child.profile.anchorView == null) { int subsz = child.measureWidth_(mctx); subsz = child.left + (subsz != null ? subsz: 0); if (wd == null || subsz > wd) wd = subsz; } } if (wd != null) wd += mctx.getBorderWidth(view); } return wd; } int measureHeight(MeasureContext mctx, View view) { int hgh = mctx.getHeightByApp(view); if (hgh == null) { hgh = view.clientHeight; for (final View child in view.children) { if (view.shallLayout_(child) && child.profile.anchorView == null) { int subsz = child.measureHeight_(mctx); subsz = child.top + (subsz != null ? subsz: 0); if (hgh == null || subsz > hgh) hgh = subsz; } } if (hgh != null) hgh += mctx.getBorderHeight(view); } return hgh; } bool get isProfileInherited => false; void doLayout_(MeasureContext mctx, View view, List<View> children) { final AsInt clientWidth = () => view.clientWidth, clientHeight = () => view.clientHeight; //future: introduce cache for (final View child in children) { mctx.setWidthByProfile(child, clientWidth); mctx.setHeightByProfile(child, clientHeight); } } }
Extends
Layout > AbstractLayout > FreeLayout
Properties
final bool isProfileInherited #
Default: true.
docs inherited from AbstractLayout
bool get isProfileInherited => false;
Methods
void doLayout(MeasureContext mctx, View view) #
inherited from AbstractLayout
Handles the layout of the given view.
docs inherited from Layout
void doLayout(MeasureContext mctx, View view) { if (view.firstChild != null) { final AnchorRelation ar = new AnchorRelation(view); for (final View child in ar.indeps) { mctx.preLayout(child); //unlike View.onLayout_, the layout shall invoke mctx.preLayout } //1) layout independents doLayout_(mctx, view, ar.indeps); //2) do anchored ar.layoutAnchored(mctx); //3) pass control to children for (final View child in view.children) { if (child.visible) child.doLayout_(mctx); //no matter shallLayout_(child) } } }
void doLayout_(MeasureContext mctx, View view, List<View> children) #
Arranges the layout of non-anchored views. Instead of overriding doLayout, it is simpler to override this method.
docs inherited from AbstractLayout
void doLayout_(MeasureContext mctx, View view, List<View> children) { final AsInt clientWidth = () => view.clientWidth, clientHeight = () => view.clientHeight; //future: introduce cache for (final View child in children) { mctx.setWidthByProfile(child, clientWidth); mctx.setHeightByProfile(child, clientHeight); } }
int measureHeight(MeasureContext mctx, View view) #
Measure the height of the given view.
docs inherited from Layout
int measureHeight(MeasureContext mctx, View view) { int hgh = mctx.getHeightByApp(view); if (hgh == null) { hgh = view.clientHeight; for (final View child in view.children) { if (view.shallLayout_(child) && child.profile.anchorView == null) { int subsz = child.measureHeight_(mctx); subsz = child.top + (subsz != null ? subsz: 0); if (hgh == null || subsz > hgh) hgh = subsz; } } if (hgh != null) hgh += mctx.getBorderHeight(view); } return hgh; }
int measureWidth(MeasureContext mctx, View view) #
Measure the width of the given view.
docs inherited from Layout
int measureWidth(MeasureContext mctx, View view) { int wd = mctx.getWidthByApp(view); if (wd == null) { wd = view.clientWidth; for (final View child in view.children) { if (view.shallLayout_(child) && child.profile.anchorView == null) { int subsz = child.measureWidth_(mctx); subsz = child.left + (subsz != null ? subsz: 0); if (wd == null || subsz > wd) wd = subsz; } } if (wd != null) wd += mctx.getBorderWidth(view); } return wd; }