API Reference 0.7.1rikulo_layoutAnchorRelation

AnchorRelation class

The anchor relationship.

class AnchorRelation {
 /** A list of independent views. An independent view is a view whose
  * position doesn't depend on others.
  */
 final List<View> indeps;
 /** A map of an anchor view and a list of views that depends on the anchor.
  */
 final Map<View, List<View>> anchored;
 /** the parent of this relation.
  */
 final View parent;

 /** Contructors of the anchor relation of all children of the given view.
  */
 AnchorRelation(View view) : indeps = new List(), anchored = new HashMap(), parent = view {
   for (final View child in view.children) {
     final View av = child.profile.anchorView;
     if (av == null) {
       indeps.add(child);
     } else {
       if (!identical(av.parent, view) && !identical(av, view))
         throw new UIError("Anchor can be parent or sibling, not $av");

       final deps = anchored[av];
       if (deps != null)
         deps.add(child);
       else
         anchored[av] = [child];
     }
   }
 }

 /** Handles the layout of the anchored views.
  */
 void layoutAnchored(MeasureContext mctx) {
   _layoutAnchored(mctx, parent);

   for (final View view in indeps)
     _layoutAnchored(mctx, view);
 }
 void _layoutAnchored(MeasureContext mctx, View anchor, [View thisOnly]) {
   final List<View> views = anchored[anchor];
   if (views != null && !views.isEmpty) {
     for (final View view in views) {
       if (thisOnly == null || view == thisOnly) {
         //0) preLayout callback
         mctx.preLayout(view);

         //1) size
         mctx.setWidthByProfile(view, () => _anchorWidth(anchor, view));
         mctx.setHeightByProfile(view, () => _anchorHeight(anchor, view));

         //2) position
         locateToView(mctx, view, view.profile.location, anchor);

         if (thisOnly != null)
           return; //done
       }
     }

     for (final View view in views)
       _layoutAnchored(mctx, view, thisOnly); //recursive
   }
 }
}

Constructors

new AnchorRelation(View view) #

Contructors of the anchor relation of all children of the given view.

AnchorRelation(View view) : indeps = new List(), anchored = new HashMap(), parent = view {
 for (final View child in view.children) {
   final View av = child.profile.anchorView;
   if (av == null) {
     indeps.add(child);
   } else {
     if (!identical(av.parent, view) && !identical(av, view))
       throw new UIError("Anchor can be parent or sibling, not $av");

     final deps = anchored[av];
     if (deps != null)
       deps.add(child);
     else
       anchored[av] = [child];
   }
 }
}

Properties

final Map<View, List<View>> anchored #

A map of an anchor view and a list of views that depends on the anchor.

final Map<View, List<View>> anchored

final List<View> indeps #

A list of independent views. An independent view is a view whose position doesn't depend on others.

final List<View> indeps

final View parent #

the parent of this relation.

final View parent

Methods

void layoutAnchored(MeasureContext mctx) #

Handles the layout of the anchored views.

void layoutAnchored(MeasureContext mctx) {
 _layoutAnchored(mctx, parent);

 for (final View view in indeps)
   _layoutAnchored(mctx, view);
}