public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight) { Widget handle = new Padding( padding: EdgeInsets.only(right: 26.0f, bottom: 26.0f), child: new SizedBox( width: MaterialUtils._kHandleSize, height: MaterialUtils._kHandleSize, child: new CustomPaint( painter: new _TextSelectionHandlePainter( color: Theme.of(context).textSelectionHandleColor ) ) ) ); switch (type) { case TextSelectionHandleType.left: // points up-right return(new Transform( transform: Matrix3.makeRotate(Mathf.PI / 2), child: handle )); case TextSelectionHandleType.right: // points up-left return(handle); case TextSelectionHandleType.collapsed: // points up return(new Transform( transform: Matrix3.makeRotate(Mathf.PI / 4), child: handle )); } return(null); }
public override Offset getHandleAnchor(TextSelectionHandleType type, float textLineHeight) { Size handleSize = getHandleSize(textLineHeight); switch (type) { case TextSelectionHandleType.left: return(new Offset( handleSize.width / 2, handleSize.height )); case TextSelectionHandleType.right: return(new Offset( handleSize.width / 2, handleSize.height - 2 * CupertinoTextSelectionUtils._kSelectionHandleRadius + CupertinoTextSelectionUtils._kSelectionHandleOverlap )); default: return(new Offset( handleSize.width / 2, textLineHeight + (handleSize.height - textLineHeight) / 2 )); } }
public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight) { Size desiredSize = getHandleSize(textLineHeight); Widget handle = SizedBox.fromSize( size: desiredSize, child: new CustomPaint( painter: new _TextSelectionHandlePainter(CupertinoTheme.of(context).primaryColor) ) ); var result = Matrix4.identity(); result.translate(desiredSize.width / 2, desiredSize.height / 2); result.rotateZ(Mathf.PI); result.translate(-desiredSize.width / 2, -desiredSize.height / 2); switch (type) { case TextSelectionHandleType.left: return(handle); case TextSelectionHandleType.right: return(new Transform( transform: result, child: handle )); case TextSelectionHandleType.collapsed: return(new SizedBox()); } D.assert(type != null); return(null); }
public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, double textLineHeight) { Widget handle = new Padding( padding: EdgeInsets.only(right: 26.0, bottom: 26.0), child: new SizedBox( width: 20, height: 20, child: new CustomPaint( painter: new _TextSelectionHandlePainter( color: new Color(0xFFFF0000) ) ) ) ); switch (type) { case TextSelectionHandleType.left: // points up-right return(new Transform( transform: Matrix3.makeRotate(Mathf.PI / 2), child: handle )); case TextSelectionHandleType.right: // points up-left return(handle); case TextSelectionHandleType.collapsed: // points up return(new Transform( transform: Matrix3.makeRotate(Mathf.PI / 4), child: handle )); } return(null); }
public override Widget build(BuildContext context) { List <TextSelectionPoint> endpoints = this.widget.renderObject.getEndpointsForSelection(this.widget.selection); Offset point = null; TextSelectionHandleType type = TextSelectionHandleType.left; switch (this.widget.position) { case _TextSelectionHandlePosition.start: point = endpoints[0].point; type = this._chooseType(endpoints[0], TextSelectionHandleType.left, TextSelectionHandleType.right); break; case _TextSelectionHandlePosition.end: D.assert(endpoints.Count == 2); point = endpoints[1].point; type = this._chooseType(endpoints[1], TextSelectionHandleType.right, TextSelectionHandleType.left); break; } Size viewport = this.widget.renderObject.size; point = new Offset( point.dx.clamp(0.0f, viewport.width), point.dy.clamp(0.0f, viewport.height) ); return(new CompositedTransformFollower( link: this.widget.layerLink, showWhenUnlinked: false, child: new FadeTransition( opacity: this._opacity, child: new GestureDetector( dragStartBehavior: this.widget.dragStartBehavior, onPanStart: this._handleDragStart, onPanUpdate: this._handleDragUpdate, onTap: this._handleTap, child: new Stack( overflow: Overflow.visible, children: new List <Widget>() { new Positioned( left: point.dx, top: point.dy, child: this.widget.selectionControls.buildHandle(context, type, this.widget.renderObject.preferredLineHeight) ) } ) ) ) )); }
public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight) { Size desiredSize = new Size( 2.0f * CustomTextSelectionControlsUtils._kHandlesPadding, textLineHeight + 2.0f * CustomTextSelectionControlsUtils._kHandlesPadding ); Widget handle = SizedBox.fromSize( size: desiredSize, child: new CustomPaint( painter: new _TextSelectionHandlePainter( new Offset( CustomTextSelectionControlsUtils._kHandlesPadding, textLineHeight + CustomTextSelectionControlsUtils._kHandlesPadding ) ) ) ); switch (type) { case TextSelectionHandleType.left: { Matrix3 matrix3 = Matrix3.makeRotate(Mathf.PI); matrix3.preConcat( Matrix3.makeTrans( -CustomTextSelectionControlsUtils._kHandlesPadding, -CustomTextSelectionControlsUtils._kHandlesPadding ) ); return(new Transform( transform: matrix3, child: handle )); } case TextSelectionHandleType.right: { return(new Transform( transform: Matrix3.makeTrans( -CustomTextSelectionControlsUtils._kHandlesPadding, -(textLineHeight + CustomTextSelectionControlsUtils._kHandlesPadding) ), child: handle )); } case TextSelectionHandleType.collapsed: return(new Container()); default: return(null); } }
public override Offset getHandleAnchor(TextSelectionHandleType type, float textLineHeight) { switch (type) { case TextSelectionHandleType.left: return(new Offset(MaterialUtils._kHandleSize, 0)); case TextSelectionHandleType.right: return(Offset.zero); default: return(new Offset(MaterialUtils._kHandleSize / 2, -4)); } }
public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight) { Size desiredSize = new Size( 2.0f * CupertinoTextSelectionUtils._kHandlesPadding, textLineHeight + 2.0f * CupertinoTextSelectionUtils._kHandlesPadding ); Widget handle = SizedBox.fromSize( size: desiredSize, child: new CustomPaint( painter: new _TextSelectionHandlePainter( origin: new Offset(CupertinoTextSelectionUtils._kHandlesPadding, textLineHeight + CupertinoTextSelectionUtils._kHandlesPadding) ) ) ); switch (type) { case TextSelectionHandleType.left: Matrix4 matrix = new Matrix4().rotationZ(Mathf.PI); matrix.translate(-CupertinoTextSelectionUtils._kHandlesPadding, -CupertinoTextSelectionUtils._kHandlesPadding); return(new Transform( transform: matrix, child: handle )); case TextSelectionHandleType.right: return(new Transform( transform: new Matrix4().translationValues( -CupertinoTextSelectionUtils._kHandlesPadding, -(textLineHeight + CupertinoTextSelectionUtils._kHandlesPadding), 0 ), child: handle )); case TextSelectionHandleType.collapsed: return(new Container()); } return(null); }
TextSelectionHandleType _chooseType( TextSelectionPoint endpoint, TextSelectionHandleType ltrType, TextSelectionHandleType rtlType ) { if (this.widget.selection.isCollapsed) { return(TextSelectionHandleType.collapsed); } D.assert(endpoint.direction != null); switch (endpoint.direction) { case TextDirection.ltr: return(ltrType); case TextDirection.rtl: return(rtlType); } D.assert(() => throw new UIWidgetsError($"invalid endpoint.direction {endpoint.direction}")); return(ltrType); }
public abstract Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight);
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) ) ) ) ) )); }
public abstract Offset getHandleAnchor(TextSelectionHandleType type, float textLineHeight);
public override Offset getHandleAnchor(TextSelectionHandleType type, float textLineHeight) { return(Offset.zero); }