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)); }
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) ) ) ) ) )); }