public override Offset getPositionForChild(Size size, Size childSize) { _MenuLimits menuLimits = route.getMenuLimits(buttonRect, size.height, route.selectedIndex ?? 0); D.assert(() => { Rect container = Offset.zero & size; if (container.intersect(buttonRect) == buttonRect) { D.assert(menuLimits.top >= 0.0f); D.assert(menuLimits.top + menuLimits.height <= size.height); } return(true); }); D.assert(textDirection != null); float left = 0; switch (textDirection) { case TextDirection.rtl: left = (buttonRect.right.clamp(0.0f, size.width)) - childSize.width; break; case TextDirection.ltr: left = buttonRect.left.clamp(0.0f, size.width - childSize.width); break; } return(new Offset(left, menuLimits.top ?? 0)); }
public override Path getOuterPath(Rect host, Rect guest) { if (guest == null || !host.overlaps(guest)) { Path path = new Path(); path.addRect(host); return(path); } D.assert(guest.width > 0.0f); Rect intersection = guest.intersect(host); float notchToCenter = intersection.height * (guest.height / 2.0f) / (guest.width / 2.0f); Path ret = new Path(); ret.moveTo(host.left, host.top); ret.lineTo(guest.center.dx - notchToCenter, host.top); ret.lineTo(guest.left + guest.width / 2.0f, guest.bottom); ret.lineTo(guest.center.dx + notchToCenter, host.top); ret.lineTo(host.right, host.top); ret.lineTo(host.right, host.bottom); ret.lineTo(host.left, host.bottom); ret.close(); return(ret); }
public ReducedClip(ClipStack stack, Rect layerBounds, Rect queryBounds) { Rect stackBounds; bool iior; stack.getBounds(out stackBounds, out iior); if (stackBounds == null) { this.scissor = layerBounds; return; } stackBounds = layerBounds.intersect(stackBounds); if (iior) { this.scissor = stackBounds; return; } queryBounds = stackBounds.intersect(queryBounds); if (queryBounds.isEmpty) { this.scissor = Rect.zero; return; } this.scissor = queryBounds; this._walkStack(stack, this.scissor); }
public override Offset getPositionForChild(Size size, Size childSize) { D.assert(() => { Rect container = Offset.zero & size; if (container.intersect(this.buttonRect) == this.buttonRect) { D.assert(this.menuTop >= 0.0f); D.assert(this.menuTop + this.menuHeight <= size.height); } return(true); }); float left = this.buttonRect.right.clamp(0.0f, size.width) - childSize.width; return(new Offset(left, this.menuTop)); }
void _addPaintBounds(Rect paintBounds) { var state = this._getState(); if (state.scissor != null) { paintBounds = paintBounds.intersect(state.scissor); } if (state.paintBounds.isEmpty) { state.paintBounds = paintBounds; } else { state.paintBounds = state.paintBounds.expandToInclude(paintBounds); } }
public override Path getOuterPath(Rect host, Rect guest) { //there is a bug in flutter when guest == null, we fix it here if (guest == null || !host.overlaps(guest)) { var path = new Path(); path.addRect(host); return(path); } D.assert(guest.width > 0.0f); var intersection = guest.intersect(host); // We are computing a "V" shaped notch, as in this diagram: // -----\**** /----- // \ / // \ / // \ / // // "-" marks the top edge of the bottom app bar. // "\" and "/" marks the notch outline // // notchToCenter is the horizontal distance between the guest's center and // the host's top edge where the notch starts (marked with "*"). // We compute notchToCenter by similar triangles: var notchToCenter = intersection.height * (guest.height / 2.0f) / (guest.width / 2.0f); var retPath = new Path(); retPath.moveTo(host.left, host.top); retPath.lineTo(guest.center.dx - notchToCenter, host.top); retPath.lineTo(guest.left + guest.width / 2.0f, guest.bottom); retPath.lineTo(guest.center.dx + notchToCenter, host.top); retPath.lineTo(host.right, host.top); retPath.lineTo(host.right, host.bottom); retPath.lineTo(host.left, host.bottom); retPath.close(); return(retPath); }