|
|
|
|
|
|
using Unity.UIWidgets.gestures; |
|
|
|
using Unity.UIWidgets.painting; |
|
|
|
using Unity.UIWidgets.ui; |
|
|
|
using UnityEditor.Rendering; |
|
|
|
|
|
|
|
namespace Unity.UIWidgets.rendering { |
|
|
|
public class RenderProxyBox : RenderProxyBoxMixinRenderObjectWithChildMixinRenderBox<RenderBox> { |
|
|
|
|
|
|
}; |
|
|
|
context.canvas.drawRect(offset & this.size, paint); |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
if (value == this._stepWidth) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this._stepWidth = value; |
|
|
|
this.markNeedsLayout(); |
|
|
|
} |
|
|
|
|
|
|
if (value == this._stepHeight) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this._stepHeight = value; |
|
|
|
this.markNeedsLayout(); |
|
|
|
} |
|
|
|
|
|
|
if (step == null) { |
|
|
|
return input; |
|
|
|
} |
|
|
|
|
|
|
|
return (input / step.Value).ceil() * step.Value; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
if (this.child == null) { |
|
|
|
return 0.0f; |
|
|
|
} |
|
|
|
|
|
|
|
float width = this.child.getMaxIntrinsicWidth(height); |
|
|
|
return _applyStep(width, this._stepWidth); |
|
|
|
} |
|
|
|
|
|
|
return 0.0f; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
D.assert(width.isFinite()); |
|
|
|
float height = this.child.getMinIntrinsicHeight(width); |
|
|
|
return _applyStep(height, this._stepHeight); |
|
|
|
|
|
|
if (this.child == null) { |
|
|
|
return 0.0f; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
D.assert(width.isFinite()); |
|
|
|
float height = this.child.getMaxIntrinsicHeight(width); |
|
|
|
return _applyStep(height, this._stepHeight); |
|
|
|
|
|
|
D.assert(width.isFinite()); |
|
|
|
childConstraints = childConstraints.tighten(width: _applyStep(width, this._stepWidth)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} |
|
|
|
else { |
|
|
|
this.performResize(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
if (this.child == null) { |
|
|
|
return 0.0f; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
D.assert(height.isFinite()); |
|
|
|
return this.child.getMinIntrinsicWidth(height); |
|
|
|
} |
|
|
|
|
|
|
return 0.0f; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
D.assert(height.isFinite()); |
|
|
|
return this.child.getMaxIntrinsicWidth(height); |
|
|
|
} |
|
|
|
|
|
|
D.assert(height.isFinite()); |
|
|
|
childConstraints = childConstraints.tighten(height: height); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
} |
|
|
|
else { |
|
|
|
this.performResize(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
return base.hitTest(result, position: position); |
|
|
|
} |
|
|
|
|
|
|
|
//todo:xingwei.zhu: implementation shadow + compositeLayer (issue: no color when composite)
|
|
|
|
//todo:xingwei.zhu: implementation shadow
|
|
|
|
public override void paint(PaintingContext context, Offset offset) { |
|
|
|
if (this.child != null) { |
|
|
|
this._updateClip(); |
|
|
|
|
|
|
offsetRRectAsPath.addRRect(offsetRRect); |
|
|
|
|
|
|
|
Canvas canvas = context.canvas; |
|
|
|
if (this.elevation != 0.0) { |
|
|
|
//draw Shadow
|
|
|
|
/*canvas.drawRect( |
|
|
|
offsetBounds.inflate(20.0), |
|
|
|
_RenderPhysicalModelBase<RRect>._transparentPaint |
|
|
|
); |
|
|
|
canvas.drawShadow( |
|
|
|
offsetRRectAsPath, |
|
|
|
this.shadowColor, |
|
|
|
this.elevation, |
|
|
|
this.color.alpha != 0xFF |
|
|
|
);*/ |
|
|
|
} |
|
|
|
|
|
|
|
if (this.needsCompositing) { |
|
|
|
PhysicalModelLayer physicalModel = new PhysicalModelLayer( |
|
|
|
clipPath: offsetRRectAsPath, |
|
|
|
|
|
|
shadowColor: this.shadowColor); |
|
|
|
context.pushLayer(physicalModel, base.paint, offset, childPaintBounds: offsetBounds); |
|
|
|
return; |
|
|
|
else { |
|
|
|
Canvas canvas = context.canvas; |
|
|
|
if (this.elevation != 0.0) { |
|
|
|
//draw Shadow
|
|
|
|
/*canvas.drawRect( |
|
|
|
offsetBounds.inflate(20.0), |
|
|
|
_RenderPhysicalModelBase<RRect>._transparentPaint |
|
|
|
); |
|
|
|
canvas.drawShadow( |
|
|
|
offsetRRectAsPath, |
|
|
|
this.shadowColor, |
|
|
|
this.elevation, |
|
|
|
this.color.alpha != 0xFF |
|
|
|
);*/ |
|
|
|
} |
|
|
|
Paint paint = new Paint {color = this.color}; |
|
|
|
canvas.drawRRect(offsetRRect, paint); |
|
|
|
context.clipRRectAndPaint(offsetRRect, this.clipBehavior, offsetBounds, |
|
|
|
() => base.paint(context, offset)); |
|
|
|
D.assert(context.canvas == canvas, "canvas changed even though needsCompositing was false"); |
|
|
|
Paint paint = new Paint {color = this.color}; |
|
|
|
canvas.drawRRect(offsetRRect, paint); |
|
|
|
context.clipRRectAndPaint(offsetRRect, this.clipBehavior, offsetBounds, |
|
|
|
() => base.paint(context, offset)); |
|
|
|
D.assert(context.canvas == canvas, "canvas changed even though needsCompositing was false"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
return base.hitTest(result, position: position); |
|
|
|
} |
|
|
|
|
|
|
|
//todo:xingwei.zhu: implementation shadow + compositeLayer (issue: no color when composite)
|
|
|
|
//todo:xingwei.zhu: implementation shadow
|
|
|
|
public override void paint(PaintingContext context, Offset offset) { |
|
|
|
if (this.child != null) { |
|
|
|
this._updateClip(); |
|
|
|
|
|
|
|
|
|
|
Canvas canvas = context.canvas; |
|
|
|
if (this.needsCompositing) { |
|
|
|
PhysicalModelLayer physicalModel = new PhysicalModelLayer( |
|
|
|
clipPath: offsetPath, |
|
|
|
clipBehavior: this.clipBehavior, |
|
|
|
elevation: this.elevation, |
|
|
|
color: this.color, |
|
|
|
shadowColor: this.shadowColor); |
|
|
|
context.pushLayer(physicalModel, base.paint, offset, childPaintBounds: offsetBounds); |
|
|
|
} |
|
|
|
else { |
|
|
|
Canvas canvas = context.canvas; |
|
|
|
// if (this.elevation != 0.0 && paintShadows) {
|
|
|
|
// canvas.drawRect(
|
|
|
|
// offsetBounds.inflate(20.0),
|
|
|
|
|
|
|
// this.color.alpha != 0xFF,
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (this.needsCompositing) { |
|
|
|
PhysicalModelLayer physicalModel = new PhysicalModelLayer( |
|
|
|
clipPath: offsetPath, |
|
|
|
clipBehavior: this.clipBehavior, |
|
|
|
elevation: this.elevation, |
|
|
|
color: this.color, |
|
|
|
shadowColor: this.shadowColor); |
|
|
|
context.pushLayer(physicalModel, base.paint, offset, childPaintBounds: offsetBounds); |
|
|
|
return; |
|
|
|
Paint paint = new Paint {color = this.color, style = PaintingStyle.fill}; |
|
|
|
canvas.drawPath(offsetPath, paint); |
|
|
|
context.clipPathAndPaint(offsetPath, this.clipBehavior, |
|
|
|
offsetBounds, () => base.paint(context, offset)); |
|
|
|
D.assert(context.canvas == canvas, "canvas changed even though needsCompositing was false"); |
|
|
|
|
|
|
|
Paint paint = new Paint {color = this.color, style = PaintingStyle.fill}; |
|
|
|
canvas.drawPath(offsetPath, paint); |
|
|
|
context.clipPathAndPaint(offsetPath, this.clipBehavior, |
|
|
|
offsetBounds, () => base.paint(context, offset)); |
|
|
|
D.assert(context.canvas == canvas, "canvas changed even though needsCompositing was false"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public class RenderAnnotatedRegion<T> : RenderProxyBox |
|
|
|
where T : class { |
|
|
|
public class RenderAnnotatedRegion<T> : RenderProxyBox |
|
|
|
where T : class { |
|
|
|
public RenderAnnotatedRegion( |
|
|
|
T value = null, |
|
|
|
bool? sized = null, |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public override void paint(PaintingContext context, Offset offset) { |
|
|
|
AnnotatedRegionLayer<T> layer = new AnnotatedRegionLayer<T>(this.value, size: this.sized ? this.size : null); |
|
|
|
AnnotatedRegionLayer<T> layer = |
|
|
|
new AnnotatedRegionLayer<T>(value: this.value, size: this.sized ? this.size : null); |
|
|
|
context.pushLayer(layer, base.paint, offset); |
|
|
|
} |
|
|
|
} |