API Reference 0.7.1rikulo_layout

rikulo_layout library

Properties

LayoutManager layoutManager #

The layout manager.

You can assign your own implementation if you'd like.

LayoutManager layoutManager = new LayoutManager()

Functions

void locateToView(MeasureContext mctx, View view, String location, [View anchor, int x = 0, int y = 0]) #

Places the given view at the given offset relative to an optional anchor.

x and y are used only if anchor (the reference view) is null. Please refer to View's locateTo for more information.

mctx is ignored if null.

void locateToView(MeasureContext mctx, View view, String location,
[View anchor, int x=0, int y=0]) {
 final mi = new SideInfo(view.profile.margin, 0);
 final locators = _getLocators(location);
 if (anchor != null) {
   final offset =
     view.style.position == "fixed" ? anchor.page:
     identical(anchor, view.parent) ? new Point(0, 0): //parent
     identical(anchor.parent, view.parent) ?
       new Point(anchor.left, anchor.top): //sibling (the same coordiante system)
       anchor.page - view.page + new Point(view.left, view.top); //neither parent nor sibling

   _anchorXLocators[locators[0]](offset.x + mi.left, anchor, view);
   _anchorYLocators[locators[1]](offset.y + mi.top, anchor, view);
 } else {
   _anchorXLocators[locators[0]](x + mi.left, _anchorOfPoint, view);
   _anchorYLocators[locators[1]](y + mi.top, _anchorOfPoint, view);
 }

 int diff = mi.left + mi.right;
 if (diff != 0 && (mctx == null || mctx.getWidthByApp(view) == null))
   view.width -= diff;
 diff = mi.top + mi.bottom;
 if (diff != 0 && (mctx == null || mctx.getHeightByApp(view) == null))
   view.height -= diff;
}

void rootLayout(MeasureContext mctx, View root) #

The function used to handle the layout of the root views.

void rootLayout(MeasureContext mctx, View root) {
 final node = root.node;
 final dlgInfo = dialogInfos[root];
 Element cave = dlgInfo != null ? dlgInfo.cave.parent: node.parent;
 if (cave == document.body)
   cave = null;
 final size = cave == null ? DomUtil.windowSize: DomUtil.clientSize(cave);

 final anchor = root.profile.anchorView;
 mctx.setWidthByProfile(root,
   () => anchor != null ? _anchorWidth(anchor, root): size.width);
 mctx.setHeightByProfile(root,
   () => anchor != null ? _anchorHeight(anchor, root): size.height);

 final loc = root.profile.location,
 	leftByApp = loc.isEmpty && mctx.getLeftByApp(root) != null,
   topByApp = loc.isEmpty && mctx.getTopByApp(root) != null;
   //if !loc.isEmpty, the layout is still required (since it is related to cave)
 if (!leftByApp || !topByApp) {
   final ref = anchor != null ? anchor:
     cave != null ? new _AnchorOfNode(cave): _anchorOfRoot;
   final ofs = anchor != null ?
     cave != anchor.parent ?
       anchor.page - root.page + new Point(root.left, root.top):
       new Point(anchor.left, anchor.top):
     cave != null && node.offsetParent != node.parent ? //if parent is relative/absolute/fixed
         DomUtil.position(cave): new Point(0,0);

   final locators = _getLocators(loc);
   final mi = new SideInfo(root.profile.margin, 0);
   if (!leftByApp)
     _anchorXLocators[locators[0]](ofs.x + mi.left, ref, root);
   if (!topByApp)
     _anchorYLocators[locators[1]](ofs.y + mi.top, ref, root);

   int diff = mi.left + mi.right;
   if (diff != 0 && mctx.getWidthByApp(root) == null)
     root.width -= diff;
   diff = mi.top + mi.bottom;
   if (diff != 0 && mctx.getHeightByApp(root) == null)
     root.height -= diff;
 }
}

Abstract Classes

Classes