using System ;
using System.Collections.Generic ;
using Unity.UIWidgets.animation ;
using Unity.UIWidgets.async2 ;
using Unity.UIWidgets.foundation ;
using Unity.UIWidgets.gestures ;
using Unity.UIWidgets.painting ;
BlendMode blendMode = BlendMode . modulate
) : base ( child ) {
D . assert ( shaderCallback ! = null ) ;
D . assert ( blendMode ! = null ) ;
_shaderCallback = shaderCallback ;
_blendMode = blendMode ;
}
public BlendMode blendMode {
get { return _blendMode ; }
set {
D . assert ( value ! = null ) ;
if ( _blendMode = = value )
return ;
_blendMode = value ;
get ;
}
bool _currentlyNeedsCompositing { get ; set ; }
Animation < float > opacity {
get ;
set ;
}
Animation < float > _opacity { get ; set ; }
bool alwaysIncludeSemantics {
Animation < float > _opacity {
bool _alwaysIncludeSemantics { get ; set ; }
void attach ( PipelineOwner owner ) ;
void detach ( ) ;
}
protected override void performLayout ( ) {
BoxConstraints constraints = this . constraints ;
if ( child ! = null ) {
child . layout ( _additionalConstraints . enforce ( constraints ) , parentUsesSize : true ) ;
size = child . size ;
protected override void performLayout ( ) {
if ( child ! = null ) {
BoxConstraints constraints = this . constraints ;
child . layout ( _limitConstraints ( constraints ) , parentUsesSize : true ) ;
size = constraints . constrain ( child . size ) ;
}
float width = constraints . maxWidth ;
float height = width / _aspectRatio ;
if ( width . isFinite ( ) ) {
height = width / _aspectRatio ;
} else {
height = constraints . maxHeight ;
width = height * _aspectRatio ;
}
if ( width > constraints . maxWidth ) {
width = constraints . maxWidth ;
height = width / _aspectRatio ;
public override void paint ( PaintingContext context , Offset offset ) {
if ( child ! = null ) {
if ( _alpha = = 0 ) {
layer = null ;
layer = null ;
context . pushOpacity ( offset , _alpha , base . paint ) ;
layer = context . pushOpacity ( offset , _alpha , base . paint , oldLayer : layer as OpacityLayer ) ;
}
public override void debugFillProperties ( DiagnosticPropertiesBuilder properties ) {
public override void paint ( PaintingContext context , Offset offset ) {
if ( child ! = null ) {
D . assert ( needsCompositing ) ;
context . pushLayer ( new BackdropFilterLayer ( filter ) , base . paint , offset ) ;
layer = layer ? ? new BackdropFilterLayer ( _filter ) ;
context . pushLayer ( layer , base . paint , offset ) ;
} else {
layer = null ;
}
}
}
}
_clipBehavior = value ;
markNeedsPaint ( ) ;
}
}
new List < Color > {
new Color ( 0 x00000000 ) ,
new Color ( 0 xFFFF00FF ) ,
} , null , TileMode . repeated ) ;
new Color ( 0 xFFFF00FF ) ,
new Color ( 0 x00000000 )
} ,
new List < float > { 0.25f , 0.25f , 0.75f , 0.75f } ,
TileMode . repeated ) ;
_debugPaint . strokeWidth = 2.0f ;
_debugPaint . style = PaintingStyle . stroke ;
}
text : new TextSpan (
text : "x" ,
text : "✂" ,
) ) ;
) ,
textDirection : TextDirection . rtl
) ;
_debugText . layout ( ) ;
}
child : child ,
clipper : clipper ,
clipBehavior : clipBehavior ) {
D . assert ( clipBehavior ! = Clip . none ) ;
}
protected override Rect _defaultClip {
public override void paint ( PaintingContext context , Offset offset ) {
if ( child ! = null ) {
_updateClip ( ) ;
context . pushClipRect ( needsCompositing , offset , _clip ,
base . paint , clipBehavior : clipBehavior ) ;
layer = context . pushClipRect (
needsCompositing ,
offset ,
_clip ,
base . paint ,
clipBehavior : clipBehavior ,
oldLayer : layer as ClipRectLayer
) ;
} else {
layer = null ;
}
}
public override void paint ( PaintingContext context , Offset offset ) {
if ( child ! = null ) {
_updateClip ( ) ;
context . pushClipRRect ( needsCompositing , offset , _clip . outerRect , _clip ,
base . paint , clipBehavior : clipBehavior ) ;
layer = context . pushClipRRect (
needsCompositing ,
offset ,
_clip . outerRect ,
_clip ,
base . paint ,
clipBehavior : clipBehavior ,
oldLayer : layer as ClipRRectLayer
) ;
} else {
layer = null ;
}
}
get { return Offset . zero & size ; }
}
public override bool hitTest ( BoxHitTestResult result ,
Offset position = null
) {
public override bool hitTest ( BoxHitTestResult result , Offset position = null ) {
_updateClip ( ) ;
D . assert ( _clip ! = null ) ;
Offset center = _clip . center ;
public override void paint ( PaintingContext context , Offset offset ) {
if ( child ! = null ) {
_updateClip ( ) ;
context . pushClipPath ( needsCompositing , offset , _clip , _getClipPath ( _clip ) ,
base . paint , clipBehavior : clipBehavior ) ;
layer = context . pushClipPath (
needsCompositing ,
offset ,
_clip ,
_getClipPath ( _clip ) ,
base . paint ,
clipBehavior : clipBehavior ,
oldLayer : layer as ClipPathLayer
) ;
} else {
layer = null ;
}
}
public override void paint ( PaintingContext context , Offset offset ) {
if ( child ! = null ) {
_updateClip ( ) ;
context . pushClipPath ( needsCompositing , offset , Offset . zero & size ,
_clip , base . paint , clipBehavior : clipBehavior ) ;
layer = context . pushClipPath (
needsCompositing ,
offset ,
Offset . zero & size ,
_clip ,
base . paint ,
clipBehavior : clipBehavior ,
oldLayer : layer as ClipPathLayer
) ;
} else {
layer = null ;
}
}
_shape = shape ;
_borderRadius = borderRadius ;
}
public PhysicalModelLayer layer { // [!!!] override
get {
return base . layer as PhysicalModelLayer ;
}
set {
if ( layer = = value ) {
return ;
}
base . layer = value ;
}
}
public BoxShape shape {
get { return _shape ; }
Rect offsetBounds = offsetRRect . outerRect ;
Path offsetRRectAsPath = new Path ( ) ;
offsetRRectAsPath . addRRect ( offsetRRect ) ;
PhysicalModelLayer physicalModel = new PhysicalModelLayer (
clipPath : offsetRRectAsPath ,
clipBehavior : clipBehavior ,
elevation : elevation ,
color : color ,
shadowColor : shadowColor ) ;
bool paintShadows = true ;
D . assert ( ( ) = > {
if ( RenderingDebugUtils . debugDisableShadows ) {
if ( elevation > 0.0 ) {
Paint paint = new Paint ( ) ;
paint . color = shadowColor ;
paint . style = PaintingStyle . stroke ;
paint . strokeWidth = elevation * 2.0f ;
context . canvas . drawRRect (
offsetRRect ,
paint
) ;
}
paintShadows = false ;
}
return true ;
} ) ;
layer = layer ? ? new PhysicalModelLayer ( ) ;
layer . clipPath = offsetRRectAsPath ;
layer . clipBehavior = clipBehavior ;
layer . elevation = paintShadows ? elevation : 0.0f ;
layer . color = color ;
layer . shadowColor = shadowColor ;
context . pushLayer ( layer , base . paint , offset , childPaintBounds : offsetBounds ) ;
physicalModel . debugCreator = debugCreator ;
layer . debugCreator = debugCreator ;
context . pushLayer ( physicalModel , base . paint , offset , childPaintBounds : offsetBounds ) ;
} else {
layer = null ;
}
}
clipBehavior : clipBehavior ) {
D . assert ( clipper ! = null ) ;
D . assert ( color ! = null ) ;
D . assert ( elevation > = 0.0 ) ;
}
public PhysicalModelLayer layer { // [!!!] override
get {
return base . layer as PhysicalModelLayer ;
}
set {
if ( layer = = value ) {
return ;
}
base . layer = value ;
}
}
protected override Path _defaultClip {
_updateClip ( ) ;
Rect offsetBounds = offset & size ;
Path offsetPath = _clip . shift ( offset ) ;
PhysicalModelLayer physicalModel = new PhysicalModelLayer (
clipPath : offsetPath ,
clipBehavior : clipBehavior ,
elevation : elevation ,
color : color ,
shadowColor : shadowColor ) ;
context . pushLayer ( physicalModel , base . paint , offset , childPaintBounds : offsetBounds ) ;
bool paintShadows = true ;
D . assert ( ( ) = > {
if ( RenderingDebugUtils . debugDisableShadows ) {
if ( elevation > 0.0 ) {
Paint paint = new Paint ( ) ;
paint . color = shadowColor ;
paint . style = PaintingStyle . stroke ;
paint . strokeWidth = elevation * 2.0f ;
context . canvas . drawPath (
offsetPath ,
paint
) ;
}
paintShadows = false ;
}
return true ;
} ) ;
layer = layer ? ? new PhysicalModelLayer ( ) ;
layer . clipPath = offsetPath ;
layer . clipBehavior = clipBehavior ;
layer . elevation = paintShadows ? elevation : 0.0f ;
layer . color = color ;
layer . shadowColor = shadowColor ;
context . pushLayer ( layer , base . paint , offset , childPaintBounds : offsetBounds ) ;
D . assert ( ( ) = > {
layer . debugCreator = debugCreator ;
return true ;
} ) ;
} else {
layer = null ;
}
}
protected override bool hitTestSelf ( Offset position ) {
return _decoration . hitTest ( size , position ) ;
// [!!!] hitTest no textDirection
// return _decoration.hitTest(size, position, textDirection: configuration.textDirection);
}
public override void paint ( PaintingContext context , Offset offset ) {
D . assert ( ( ) = > {
if ( debugSaveCount ! = context . canvas . getSaveCount ( ) ) {
throw new UIWidgetsError (
_decoration . GetType ( ) + " painter had mismatching save and restore calls.\n" +
"Before painting the decoration, the canvas save count was $debugSaveCount. " +
"After painting it, the canvas save count was " + context . canvas . getSaveCount ( ) + " . " +
"Every call to save() or saveLayer() must be matched by a call to restore().\n " +
"The decoration was:\n" +
" " + decoration + "\n" +
"The painter was:\n" +
" " + _painter
) ;
throw new UIWidgetsError ( new List < DiagnosticsNode > {
new ErrorSummary ( $"{_decoration.GetType()} painter had mismatching save and restore calls." ) ,
new ErrorDescription (
"Before painting the decoration, the canvas save count was $debugSaveCount . " +
"After painting it, the canvas save count was ${context.canvas.getSaveCount()}. " +
"Every call to save() or saveLayer() must be matched by a call to restore()."
) ,
new DiagnosticsProperty < Decoration > ( "The decoration was" , decoration , style : DiagnosticsTreeStyle . errorProperty ) ,
new DiagnosticsProperty < BoxPainter > ( "The painter was" , _painter , style : DiagnosticsTreeStyle . errorProperty ) ,
} ) ;
}
return true ;
bool transformHitTests = true ,
RenderBox child = null
) : base ( child ) {
D . assert ( transform ! = null ) ;
this . transform = transform ;
this . origin = origin ;
this . alignment = alignment ;
}
_transform = value ;
//_transform = Matrix4.copy(value);
markNeedsPaint ( ) ;
}
}
public void setIdentity ( ) {
_transform . setIdentity ( ) ;
_transform = Matrix4 . identity ( ) ;
markNeedsPaint ( ) ;
}
Offset childOffset = transform . getAsTranslation ( ) ;
if ( childOffset = = null ) {
context . pushTransform ( needsCompositing , offset , transform , base . paint ) ;
}
else {
layer = context . pushTransform (
needsCompositing ,
offset ,
transform ,
base . paint ,
oldLayer : layer as TransformLayer
) ;
} else {
layer = null ;
}
}
}
Rect sourceRect = _resolvedAlignment . inscribe ( sizes . source , Offset . zero & childSize ) ;
Rect destinationRect = _resolvedAlignment . inscribe ( sizes . destination , Offset . zero & size ) ;
_hasVisualOverflow = sourceRect . width < childSize . width | | sourceRect . height < childSize . height ;
D . assert ( scaleX . isFinite ( ) & & scaleY . isFinite ( ) ) ;
bool result = true ;
foreach ( var value in _transform . storage ) {
if ( ! value . isFinite ( ) ) {
result = false ;
}
}
D . assert ( result ) ;
context . pushTransform ( needsCompositing , offset , _transform , base . paint ) ;
context . pushTransform ( needsCompositing , offset , _transform , base . paint ,
oldLayer : layer is TransformLayer ? layer as TransformLayer : null ) ;
/ * TransformLayer _paintChildWithTransform ( PaintingContext context , Offset offset ) {
Offset childOffset = _transform . getAsTranslation ( ) ;
if ( childOffset = = null ) {
return context . pushTransform ( needsCompositing , offset , _transform , base . paint ,
oldLayer : layer is TransformLayer ? layer as TransformLayer : null ) ;
}
else {
base . paint ( context , offset + childOffset ) ;
return null ;
}
} * /
//[!!!]
if ( size . isEmpty ) {
if ( size . isEmpty | | child . size . isEmpty ) {
return ;
}
context . pushClipRect ( needsCompositing , offset , Offset . zero & size ,
_paintChildWithTransform ) ;
painter : _paintChildWithTransform ,
oldLayer : layer is ClipRectLayer ? layer as ClipRectLayer : null ) ;
else {
else {
_paintChildWithTransform ( context , offset ) ;
}
}
}
public override void applyPaintTransform ( RenderObject child , Matrix4 transform ) {
if ( size . isEmpty ) {
if ( size . isEmpty | | ( ( RenderBox ) child ) . size . isEmpty ) {
transform . setZero ( ) ;
}
else {
Offset _translation ;
public override bool hitTest ( BoxHitTestResult result , Offset position ) {
public override bool hitTest ( BoxHitTestResult result , Offset position = null ) {
protected override bool hitTestChildren ( BoxHitTestResult result , Offset position ) {
protected override bool hitTestChildren ( BoxHitTestResult result , Offset position = null ) {
D . assert ( ! debugNeedsLayout ) ;
return result . addWithPaintOffset (
offset : transformHitTests
{ "cancel" , onPointerCancel } ,
{ "signal" , onPointerSignal }
} ,
ifEmpty : "<none>" ) ) ;
ifEmpty : "<none>"
) ) ;
}
}
bool opaque = true ,
RenderBox child = null
) : base ( child ) {
D . assert ( opaque ! = null ) ;
_onEnter = onEnter ;
_onHover = onHover ;
_onExit = onExit ;
}
}
PointerEnterEventListener _onEnter ;
public void _handleEnter ( PointerEnterEvent E vent) {
public void _handleEnter ( PointerEnterEvent _e vent) {
_onEnter ( E vent) ;
_onEnter ( _e vent) ;
}
public PointerHoverEventListener onHover {
}
PointerHoverEventListener _onHover ;
void _handleHover ( PointerHoverEvent E vent) {
void _handleHover ( PointerHoverEvent _e vent) {
_onHover ( E vent) ;
_onHover ( _e vent) ;
}
public PointerExitEventListener onExit {
}
PointerExitEventListener _onExit ;
void _handleExit ( PointerExitEvent E vent) {
void _handleExit ( PointerExitEvent _e vent) {
_onExit ( E vent) ;
_onExit ( _e vent) ;
}
MouseTrackerAnnotation _hoverAnnotation ;
owner = ( PipelineOwner ) owner ;
base . attach ( owner ) ;
// todo
//RendererBinding.instance.mouseTracker.addListener(_handleUpdatedMouseIsConnected);
RendererBinding . instance . mouseTracker . addListener ( _handleUpdatedMouseIsConnected ) ;
// RendererBinding.instance.mouseTracker.removeListener(_handleUpdatedMouseIsConnected);
RendererBinding . instance . mouseTracker . removeListener ( _handleUpdatedMouseIsConnected ) ;
base . detach ( ) ;
}
public bool _annotationIsActive ;
AnnotatedRegionLayer < MouseTrackerAnnotation > layer = new AnnotatedRegionLayer < MouseTrackerAnnotation > (
_hoverAnnotation ,
size : size ,
offset : offset
//opaque: opaque // todo
offset : offset ,
opaque : opaque // TODO
) ;
context . pushLayer ( layer , base . paint , offset ) ;
} else {
public override void debugFillProperties ( DiagnosticPropertiesBuilder properties ) {
base . debugFillProperties ( properties ) ;
// todo
/ * properties . add ( FlagsSummary < Function > (
properties . add ( new FlagsSummary < Delegate > (
< string , Function > {
"enter" : onEnter ,
"hover" : onHover ,
"exit" : onExit ,
}
ifEmpty : "<none>" ,
) ) ; * /
new Dictionary < string , Delegate > {
{ "enter" , onEnter } ,
{ "hover" , onHover } ,
{ "exit" , onExit } ,
} ,
ifEmpty : "<none>"
) ) ;
properties . add ( new DiagnosticsProperty < bool > ( "opaque" , opaque , defaultValue : true ) ) ;
}
}
public override bool isRepaintBoundary {
get { return true ; }
}
Future < ui . Image > toImage ( float pixelRatio = 1.0f ) {
D . assert ( ! debugNeedsPaint ) ;
OffsetLayer offsetLayer = layer as OffsetLayer ;
return offsetLayer . toImage ( Offset . zero & size , pixelRatio : pixelRatio ) ;
}
public int debugSymmetricPaintCount {
get { return _debugSymmetricPaintCount ; }
bool _ignoring ;
public override bool hitTest ( BoxHitTestResult result , Offset position = null ) {
return ignoring ? false : base . hitTest ( result , position : position ) ;
return ! ignoring & & base . hitTest ( result , position : position ) ;
}
public override void debugFillProperties ( DiagnosticPropertiesBuilder properties ) {
}
public class RenderOffstage : RenderProxyBox {
public RenderOffstage ( bool offstage = true ,
RenderBox child = null ) : base ( child ) {
public RenderOffstage ( bool offstage = true , RenderBox child = null ) : base ( child ) {
_offstage = offstage ;
}
}
}
public override bool hitTest ( BoxHitTestResult result , Offset position ) {
public override bool hitTest ( BoxHitTestResult result , Offset position = null ) {
return ! offstage & & base . hitTest ( result , position : position ) ;
}
public bool absorbing {
get { return _absorbing ; }
set { _absorbing = value ; }
set {
if ( _absorbing = = value )
return ;
_absorbing = value ;
}
public override bool hitTest ( BoxHitTestResult result , Offset position ) {
public override bool hitTest ( BoxHitTestResult result , Offset position = null ) {
return absorbing
? size . contains ( position )
: base . hitTest ( result , position : position ) ;
}
public override void paint ( PaintingContext context , Offset offset ) {
context . pushLayer ( new LeaderLayer ( link : link , offset : offset ) , base . paint , Offset . zero ) ;
if ( layer = = null ) {
layer = new LeaderLayer ( link : link , offset : offset ) ;
} else {
LeaderLayer leaderLayer = ( LeaderLayer ) layer ;
leaderLayer . link = link ;
leaderLayer . offset = offset ;
}
context . pushLayer ( layer , base . paint , Offset . zero ) ;
D . assert ( layer ! = null ) ;
}
public override void debugFillProperties ( DiagnosticPropertiesBuilder properties ) {
Offset offset = null ,
RenderBox child = null
) : base ( child ) {
D . assert ( link ! = null ) ;
this . offset = offset ;
this . offset = offset ? ? Offset . zero ;
}
public LayerLink link {
Offset _offset ;
public override void detach ( ) {
_ layer = null ;
layer = null ;
base . detach ( ) ;
}
new FollowerLayer _layer ;
public FollowerLayer layer { // [!!!] override
get {
return base . layer as FollowerLayer ;
}
set {
if ( layer = = value )
return ;
layer = value ;
}
}
return _layer ? . getLastTransform ( ) ? ? Matrix4 . identity ( ) ;
return layer ? . getLastTransform ( ) ? ? Matrix4 . identity ( ) ;
public override bool hitTest ( BoxHitTestResult result , Offset position ) {
public override bool hitTest ( BoxHitTestResult result , Offset position = null ) {
protected override bool hitTestChildren ( BoxHitTestResult result , Offset position ) {
protected override bool hitTestChildren ( BoxHitTestResult result , Offset position = null ) {
return result . addWithPaintTransform (
transform : getCurrentTransform ( ) ,
position : position ,
}
public override void paint ( PaintingContext context , Offset offset ) {
_layer = new FollowerLayer (
link : link ,
showWhenUnlinked : showWhenUnlinked ,
linkedOffset : this . offset ,
unlinkedOffset : offset
) ;
context . pushLayer ( _layer ,
if ( layer = = null ) {
layer = new FollowerLayer (
link : link ,
showWhenUnlinked : showWhenUnlinked ,
linkedOffset : this . offset ,
unlinkedOffset : offset
) ;
}
else {
layer . link = link ;
layer . showWhenUnlinked = showWhenUnlinked ;
layer . linkedOffset = this . offset ;
layer . unlinkedOffset = offset ;
}
context . pushLayer (
layer ,
base . paint ,
Offset . zero ,
childPaintBounds : Rect . fromLTRB (