浏览代码

some fixes.

/main
kg 6 年前
当前提交
08783d15
共有 7 个文件被更改,包括 76 次插入29 次删除
  1. 3
      Runtime/rendering/box.cs
  2. 13
      Runtime/rendering/object.cs
  3. 53
      Runtime/rendering/proxy_box.cs
  4. 30
      Runtime/ui/painting/painting.cs
  5. 2
      Samples/UIWidgetSample/Resources/VideoSampleRT.renderTexture
  6. 2
      Samples/UIWidgetSample/ToDoAppSample.cs
  7. 2
      Samples/UIWidgetsGallery/gallery/options.cs

3
Runtime/rendering/box.cs


});
}
public virtual bool hitTest(HitTestResult result, Offset position) {
public virtual bool hitTest(HitTestResult result, Offset position = null) {
D.assert(position != null);
D.assert(() => {
if (!this.hasSize) {
if (this.debugNeedsLayout) {

13
Runtime/rendering/object.cs


}
}
public void pushClipPath(bool needsCompositing, Offset offset, Rect bounds, Path clipPath,
PaintingContextCallback painter, Clip clipBehavior = Clip.antiAlias) {
Rect offsetBounds = bounds.shift(offset);
Path offsetClipPath = clipPath.shift(offset);
if (needsCompositing) {
this.pushLayer(new ClipPathLayer(clipPath: offsetClipPath, clipBehavior: clipBehavior), painter, offset,
childPaintBounds: offsetBounds);
}
else {
this.clipPathAndPaint(offsetClipPath, clipBehavior, offsetBounds, () => painter(this, offset));
}
}
public void pushTransform(bool needsCompositing, Offset offset, Matrix3 transform,
PaintingContextCallback painter) {
var effectiveTransform = Matrix3.makeTrans(offset.dx, offset.dy);

53
Runtime/rendering/proxy_box.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Gradient = Unity.UIWidgets.ui.Gradient;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.rendering {
public class RenderProxyBox : RenderProxyBoxMixinRenderObjectWithChildMixinRenderBox<RenderBox> {

protected override void debugPaintSize(PaintingContext context, Offset offset) {
D.assert(() => {
// if (this._debugPaint == null) {
// this._debugPaint = new Paint();
// this._debugPaint.shader = Gradient.linear(
// new Offset(0.0, 0.0),
// new Offset(10.0, 10.0),
// new Color(0x00000000),
// new Color(0xFFFF00FF),
// TileMode.repeated);
// this._debugPaint.strokeWidth = 2.0;
// this._debugPaint.style = PaintingStyle.stroke;
// }
// if (this._debugText == null) {
// this._debugText = new TextPainter(
// text: new TextSpan(
// text: "x",
// style: new TextStyle(
// color: new Color(0xFFFF00FF),
// fontSize: 14.0)
// ));
// this._debugText.layout();
// }
if (this._debugPaint == null) {
this._debugPaint = new Paint();
this._debugPaint.shader = Gradient.linear(
new Offset(0.0f, 0.0f),
new Offset(10.0f, 10.0f),
new List<Color> {
new Color(0x00000000),
new Color(0xFFFF00FF),
}, null, TileMode.repeated);
this._debugPaint.strokeWidth = 2.0f;
this._debugPaint.style = PaintingStyle.stroke;
}
if (this._debugText == null) {
this._debugText = new TextPainter(
text: new TextSpan(
text: "x",
style: new TextStyle(
color: new Color(0xFFFF00FF),
fontSize: 14.0f)
));
this._debugText.layout();
}
public class RenderClipRect : _RenderCustomClip<Rect> {
public RenderClipRect(

}
public override bool hitTest(HitTestResult result, Offset position = null) {
D.assert(position != null);
if (this._clipper != null) {
this._updateClip();
D.assert(this._clip != null);

public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
this._updateClip();
//todo:xingwei.zhu pushClipPath()
// context.pushClipPath(this.needsCompositing, offset, Offset.zero & this.size,
// this._clip, base.paint, clipBehavior: this.clipBehavior);
context.pushClipPath(this.needsCompositing, offset, Offset.zero & this.size,
this._clip, base.paint, clipBehavior: this.clipBehavior);
base.paint(context, offset);
}
}

30
Runtime/ui/painting/painting.cs


}
}
public abstract class ImageFilter {
public static ImageFilter blur(float sigmaX = 0.0f, float sigmaY = 0.0f) {
return new _BlurImageFilter(sigmaX, sigmaY);
}
public static ImageFilter matrix(Matrix3 transform, FilterMode filterMode = FilterMode.Point) {
return new _MatrixImageFilter(transform, filterMode);
}
}
class _BlurImageFilter : ImageFilter {
public _BlurImageFilter(float sigmaX, float sigmaY) {
this.sigmaX = sigmaX;
this.sigmaY = sigmaY;
}
public readonly float sigmaX;
public readonly float sigmaY;
}
class _MatrixImageFilter : ImageFilter {
public _MatrixImageFilter(Matrix3 transform, FilterMode filterMode) {
D.assert(transform != null);
this.transform = transform;
this.filterMode = filterMode;
}
public readonly Matrix3 transform;
public readonly FilterMode filterMode;
}
public class Paint {
static readonly Color _kColorDefault = new Color(0xFFFFFFFF);

2
Samples/UIWidgetSample/Resources/VideoSampleRT.renderTexture


m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_Width: 480
m_Height: 480
m_Height: 270
m_AntiAliasing: 1
m_DepthFormat: 2
m_ColorFormat: 0

2
Samples/UIWidgetSample/ToDoAppSample.cs


var texture = Resources.Load<RenderTexture>("VideoSampleRT");
return new Center(
child: new Container(
width: 480, height: 270,
width: 240, height: 135,
child: new Texture(texture: texture)
)
);

2
Samples/UIWidgetsGallery/gallery/options.cs


class _TextScaleFactorItem : StatelessWidget {
public _TextScaleFactorItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged) {
this.options = options;
this.onOptionsChanged = this.onOptionsChanged;
this.onOptionsChanged = onOptionsChanged;
}
public readonly GalleryOptions options;

正在加载...
取消
保存