public override Path getInnerPath(Rect rect, TextDirection?textDirection = null) { var path = new Path(); path.addOval(Rect.fromCircle( center: rect.center, radius: Mathf.Max(0.0f, rect.shortestSide / 2.0f - side.width) )); return(path); }
public override Path getOuterPath(Rect rect, TextDirection?textDirection = null) { var path = new Path(); path.addOval(Rect.fromCircle( center: rect.center, radius: rect.shortestSide / 2.0f )); return(path); }
public override void paint(Canvas canvas, Size size) { Paint paint = new Paint(); paint.color = color; float radius = size.width / 2.0f; Rect circle = Rect.fromCircle(center: new Offset(radius, radius), radius: radius); Rect point = Rect.fromLTWH(0.0f, 0.0f, radius, radius); Path path = new Path(); path.addOval(circle); path.addRect(point); canvas.drawPath(path, paint); }
public override void paint(PaintingContext context, Offset offset) { float visualPosition = 0.0f; Color leftColor = null; Color rightColor = null; switch (textDirection) { case TextDirection.rtl: visualPosition = 1.0f - _position.value; leftColor = _activeColor; rightColor = trackColor; break; case TextDirection.ltr: visualPosition = _position.value; leftColor = trackColor; rightColor = _activeColor; break; } float trackCenter = offset.dy + size.height / 2.0f; float trackLeft = offset.dx + _trackLeft; float trackTop = trackCenter - 1.0f; float trackBottom = trackCenter + 1.0f; float trackRight = offset.dx + _trackRight; float trackActive = offset.dx + _thumbCenter; Canvas canvas = context.canvas; if (visualPosition > 0.0f) { Paint paint = new Paint(); paint.color = rightColor; canvas.drawRRect(RRect.fromLTRBXY(trackLeft, trackTop, trackActive, trackBottom, 1.0f, 1.0f), paint); } if (visualPosition < 1.0f) { Paint paint = new Paint(); paint.color = leftColor; canvas.drawRRect(RRect.fromLTRBXY(trackActive, trackTop, trackRight, trackBottom, 1.0f, 1.0f), paint); } Offset thumbCenter = new Offset(trackActive, trackCenter); new CupertinoThumbPainter(color: thumbColor).paint(canvas, Rect.fromCircle(center: thumbCenter, radius: CupertinoThumbPainter.radius)); }
public bool hitTestInteractive(Offset position) { if (_thumbRect == null) { return(false); } if (fadeoutOpacityAnimation.value == 0.0f) { return(false); } Rect interactiveThumbRect = _thumbRect.expandToInclude( Rect.fromCircle(center: _thumbRect.center, radius: ScrollbarPainterUtils._kMinInteractiveSize / 2) ); return(interactiveThumbRect.contains(position)); }
void paint(PaintingContext context, Offset offset) { float visualPosition; Color leftColor; Color rightColor; visualPosition = this._position.value; leftColor = SliderUtils._kTrackColor; rightColor = this._activeColor; float trackCenter = offset.dy + this.size.height / 2.0f; float trackLeft = offset.dx + this._trackLeft; float trackTop = trackCenter - 1.0f; float trackBottom = trackCenter + 1.0f; float trackRight = offset.dx + this._trackRight; float trackActive = offset.dx + this._thumbCenter; Canvas canvas = context.canvas; if (visualPosition > 0.0f) { Paint paint = new Paint(); paint.color = rightColor; canvas.drawRRect(RRect.fromLTRBXY(trackLeft, trackTop, trackActive, trackBottom, 1.0f, 1.0f), paint); } if (visualPosition < 1.0f) { Paint paint = new Paint(); paint.color = leftColor; canvas.drawRRect(RRect.fromLTRBXY(trackActive, trackTop, trackRight, trackBottom, 1.0f, 1.0f), paint); } Offset thumbCenter = new Offset(trackActive, trackCenter); this._thumbPainter.paint(canvas, Rect.fromCircle(center: thumbCenter, radius: CupertinoThumbPainter.radius)); }
public override void paint(Canvas canvas, Size size) { float halfStrokeWidth = 1.0f; Paint paint = new Paint(); paint.color = color; Rect circle = Rect.fromCircle( center: new Offset(CupertinoTextSelectionUtils._kSelectionHandleRadius, CupertinoTextSelectionUtils._kSelectionHandleRadius), radius: CupertinoTextSelectionUtils._kSelectionHandleRadius ); Rect line = Rect.fromPoints( new Offset( CupertinoTextSelectionUtils._kSelectionHandleRadius - halfStrokeWidth, 2 * CupertinoTextSelectionUtils._kSelectionHandleRadius - CupertinoTextSelectionUtils._kSelectionHandleOverlap ), new Offset(CupertinoTextSelectionUtils._kSelectionHandleRadius + halfStrokeWidth, size.height) ); Path path = new Path(); path.addOval(circle); // Draw line so it slightly overlaps the circle. path.addRect(line); canvas.drawPath(path, paint); }
public override Widget build(BuildContext context) { LayerLink layerLink = null; TextSelectionHandleType type = TextSelectionHandleType.left; switch (widget.position) { case _TextSelectionHandlePosition.start: layerLink = widget.startHandleLayerLink; type = _chooseType( widget.renderObject.textDirection, TextSelectionHandleType.left, TextSelectionHandleType.right ); break; case _TextSelectionHandlePosition.end: D.assert(!widget.selection.isCollapsed); layerLink = widget.endHandleLayerLink; type = _chooseType( widget.renderObject.textDirection, TextSelectionHandleType.right, TextSelectionHandleType.left ); break; } Offset handleAnchor = widget.selectionControls.getHandleAnchor( type, widget.renderObject.preferredLineHeight ); Size handleSize = widget.selectionControls.getHandleSize( widget.renderObject.preferredLineHeight ); Rect handleRect = Rect.fromLTWH( -handleAnchor.dx, -handleAnchor.dy, handleSize.width, handleSize.height ); Rect interactiveRect = handleRect.expandToInclude( Rect.fromCircle(center: handleRect.center, radius: kMinInteractiveDimension / 2) ); RelativeRect padding = RelativeRect.fromLTRB( Mathf.Max((interactiveRect.width - handleRect.width) / 2, 0), Mathf.Max((interactiveRect.height - handleRect.height) / 2, 0), Mathf.Max((interactiveRect.width - handleRect.width) / 2, 0), Mathf.Max((interactiveRect.height - handleRect.height) / 2, 0) ); return(new CompositedTransformFollower( link: layerLink, offset: interactiveRect.topLeft, showWhenUnlinked: false, child: new FadeTransition( opacity: _opacity, child: new Container( alignment: Alignment.topLeft, width: interactiveRect.width, height: interactiveRect.height, child: new GestureDetector( behavior: HitTestBehavior.translucent, dragStartBehavior: widget.dragStartBehavior, onPanStart: _handleDragStart, onPanUpdate: _handleDragUpdate, onTap: _handleTap, child: new Padding( padding: EdgeInsets.only( left: padding.left, top: padding.top, right: padding.right, bottom: padding.bottom ), child: widget.selectionControls.buildHandle(context, type, widget.renderObject.preferredLineHeight) ) ) ) ) )); }
static void _addArc(Path path, Offset center, float radius, float startAngle, float endAngle) { Rect arcRect = Rect.fromCircle(center: center, radius: radius); path.arcTo(arcRect, startAngle, endAngle - startAngle, false); }