public override void EndLayout(LayoutRequest request, CGPoint origin, CGSize allocation) { if (ownsView) { View.Frame = new CGRect(origin, allocation); base.EndLayout(request, CGPoint.Empty, allocation); } else { base.EndLayout(request, origin, allocation); } }
public override void EndLayout(LayoutRequest request, PointF origin, SizeF allocation) { if (ownsView) { View.Frame = new RectangleF(origin, allocation); base.EndLayout(request, PointF.Empty, allocation); } else { base.EndLayout(request, origin, allocation); } }
public virtual void EndLayout(LayoutRequest request, CGPoint origin, CGSize allocation) { var frame = new CGRect(origin.X + PadLeft, origin.Y + PadBottom, allocation.Width - PadLeft - PadRight, allocation.Height - PadTop - PadBottom); if (allocation.Height > request.Size.Height) { if (YAlign != LayoutAlign.Fill) { frame.Height = request.Size.Height - PadTop - PadBottom; if (YAlign == LayoutAlign.Center) { frame.Y += (allocation.Height - request.Size.Height) / 2; } else if (YAlign == LayoutAlign.End) { frame.Y += (allocation.Height - request.Size.Height); } } } if (allocation.Width > request.Size.Width) { if (XAlign != LayoutAlign.Fill) { frame.Width = request.Size.Width - PadLeft - PadRight; if (XAlign == LayoutAlign.Center) { frame.X += (allocation.Width - request.Size.Width) / 2; } else if (XAlign == LayoutAlign.End) { frame.X += (allocation.Width - request.Size.Width); } } } OnLayoutEnded(frame); }
public virtual void EndLayout(LayoutRequest request, CGPoint origin, CGSize allocation) { var childRequests = ((ContainerLayoutRequest)request).ChildRequests; allocation = new CGSize(allocation.Width - PadLeft - PadRight, allocation.Height - PadBottom - PadTop); origin = new CGPoint(origin.X + PadLeft, origin.Y + PadBottom); var size = request.Size; size.Height -= (PadTop + PadBottom); size.Width -= (PadLeft + PadRight); int wExpandCount = 0; int hExpandCount = 0; int visibleCount = 0; foreach (var childRequest in childRequests) { if (childRequest.Visible) { visibleCount++; } else { continue; } if (childRequest.ExpandWidth) { wExpandCount++; } if (childRequest.ExpandHeight) { hExpandCount++; } } nfloat wExpand = 0; if (allocation.Width > size.Width) { wExpand = allocation.Width - size.Width; if (wExpandCount > 0) { wExpand /= wExpandCount; } } nfloat hExpand = 0; if (allocation.Height > size.Height) { hExpand = allocation.Height - size.Height; if (hExpandCount > 0) { hExpand /= hExpandCount; } } if (Direction == LayoutDirection.Horizontal) { nfloat pos = PadLeft; if (wExpandCount == 0) { if (Align == LayoutAlign.End) { pos += wExpand; } else if (Align == LayoutAlign.Center) { pos += wExpand / 2; } } for (int i = 0; i < childRequests.Count; i++) { var child = children[i]; var childReq = childRequests[i]; if (!childReq.Visible) { continue; } var childSize = new CGSize(childReq.Size.Width, allocation.Height); if (childReq.ExpandWidth) { childSize.Width += wExpand; } else if (hExpandCount == 0 && Align == LayoutAlign.Fill) { childSize.Width += wExpand / visibleCount; } child.EndLayout(childReq, new CGPoint(pos, origin.Y), childSize); pos += childSize.Width + Spacing; } } else { nfloat pos = PadBottom; if (hExpandCount == 0) { if (Align == LayoutAlign.End) { pos += hExpand; } else if (Align == LayoutAlign.Center) { pos += hExpand / 2; } } for (int i = 0; i < childRequests.Count; i++) { var child = children[i]; var childReq = childRequests[i]; if (!childReq.Visible) { continue; } var childSize = new CGSize(allocation.Width, childReq.Size.Height); if (childReq.ExpandHeight) { childSize.Height += hExpand; } else if (hExpandCount == 0 && Align == LayoutAlign.Fill) { childSize.Height += hExpand / visibleCount; } child.EndLayout(childReq, new CGPoint(origin.X, pos), childSize); pos += childSize.Height + Spacing; } } }