浏览代码

rename interface

/main
gewentao 6 年前
当前提交
2a9c59e9
共有 9 个文件被更改,包括 91 次插入82 次删除
  1. 4
      Runtime/material/material.cs
  2. 22
      Runtime/material/scrollbar.cs
  3. 4
      Runtime/material/text_selection.cs
  4. 4
      Runtime/material/utils.cs
  5. 80
      Runtime/rendering/custom_paint.cs
  6. 8
      Runtime/widgets/basic.cs
  7. 42
      Runtime/widgets/scrollbar.cs
  8. 4
      Samples/UIWidgetSample/CustomPaintCanvas.cs
  9. 5
      Samples/UIWidgetSample/ScrollbarCanvas.cs

4
Runtime/material/material.cs


}
}
class _ShapeBorderPainter : CustomPainter {
class _ShapeBorderPainter : AbstractCustomPainter {
public _ShapeBorderPainter(ShapeBorder border = null) : base(null) {
this.border = border;
}

this.border.paint(canvas, Offset.zero & size);
}
public override bool shouldRepaint(ICustomPainter oldDelegate) {
public override bool shouldRepaint(CustomPainter oldDelegate) {
_ShapeBorderPainter _oldDelegate = (_ShapeBorderPainter) oldDelegate;
return _oldDelegate.border != this.border;
}

22
Runtime/material/scrollbar.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.material {
public class Scrollbar : StatefulWidget {

public override void didChangeDependencies() {
base.didChangeDependencies();
ThemeData theme = Theme.of(context);
ThemeData theme = Theme.of(this.context);
this._textDirection = Directionality.of(context);
this._textDirection = Directionality.of(this.context);
this._materialPainter = this._BuildMaterialScrollbarPainter();
}

if (this._fadeoutAnimationController.status != AnimationStatus.forward) {
this._fadeoutAnimationController.forward();
}
_fadeoutAnimationController.reverse();
_fadeoutTimer = null;
this._fadeoutAnimationController.reverse();
this._fadeoutTimer = null;
return false;
}

child: new CustomPaint(
foregroundPainter: this._materialPainter,
child: new RepaintBoundary(
child: widget.child
child: this.widget.child
)
)
)

}
}

4
Runtime/material/text_selection.cs


}
}
class _TextSelectionHandlePainter : CustomPainter {
class _TextSelectionHandlePainter : AbstractCustomPainter {
internal _TextSelectionHandlePainter(Color color) {
this.color = color;
}

}
public override bool shouldRepaint(ICustomPainter oldPainter) {
public override bool shouldRepaint(CustomPainter oldPainter) {
return this.color != ((_TextSelectionHandlePainter) oldPainter).color;
}
}

4
Runtime/material/utils.cs


public static class ScrollbarUtils {
public static readonly TimeSpan _kScrollbarFadeDuration = TimeSpan.FromMilliseconds(300);
public const double _kScrollbarThickness = 6.0;
}
}

80
Runtime/rendering/custom_paint.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
public interface ICustomPainter : Listenable {
public interface CustomPainter : Listenable {
bool shouldRepaint(ICustomPainter oldDelegate);
bool shouldRepaint(CustomPainter oldDelegate);
public abstract class CustomPainter : ICustomPainter {
public CustomPainter(Listenable repaint = null) {
public abstract class AbstractCustomPainter : CustomPainter {
public AbstractCustomPainter(Listenable repaint = null) {
this._repaint = repaint;
}

public abstract void paint(Canvas canvas, Size size);
public abstract bool shouldRepaint(ICustomPainter oldDelegate);
public abstract bool shouldRepaint(CustomPainter oldDelegate);
public virtual bool hitTest(Offset position) {
return true;

}
public class RenderCustomPaint : RenderProxyBox {
ICustomPainter painter = null,
ICustomPainter foregroundPainter = null,
CustomPainter painter = null,
CustomPainter foregroundPainter = null,
): base(child) {
) : base(child) {
preferredSize = preferredSize ?? Size.zero;
this.preferredSize = preferredSize;
this._painter = painter;

}
ICustomPainter _painter;
CustomPainter _painter;
public ICustomPainter painter {
get => this._painter;
public CustomPainter painter {
get { return this._painter; }
if (this._painter == value)
if (this._painter == value) {
ICustomPainter oldPainter = this._painter;
}
CustomPainter oldPainter = this._painter;
ICustomPainter _foregroundPainter;
CustomPainter _foregroundPainter;
public ICustomPainter foregroundPainter {
get => this._foregroundPainter;
public CustomPainter foregroundPainter {
get { return this._foregroundPainter; }
if (this._foregroundPainter == value)
if (this._foregroundPainter == value) {
ICustomPainter oldPainter = this._foregroundPainter;
}
CustomPainter oldPainter = this._foregroundPainter;
void _didUpdatePainter(ICustomPainter newPainter, ICustomPainter oldPainter) {
void _didUpdatePainter(CustomPainter newPainter, CustomPainter oldPainter) {
if (newPainter == null) {
D.assert(oldPainter != null);
this.markNeedsPaint();

Size _preferredSize;
public Size preferredSize {
get => this._preferredSize;
get { return this._preferredSize; }
if (this.preferredSize == value)
if (this.preferredSize == value) {
}
this._preferredSize = value;
this.markNeedsLayout();
}

}
protected override bool hitTestChildren(HitTestResult result, Offset position) {
if (this._foregroundPainter != null && (this._foregroundPainter.hitTest(position)))
if (this._foregroundPainter != null && (this._foregroundPainter.hitTest(position))) {
}
return base.hitTestChildren(result, position: position);
}

this.size = this.constraints.constrain(this.preferredSize);
}
void _paintWithPainter(Canvas canvas, Offset offset, ICustomPainter painter) {
void _paintWithPainter(Canvas canvas, Offset offset, CustomPainter painter) {
int debugPreviousCanvasSaveCount = 0;
canvas.save();
D.assert(() => {

if (offset != Offset.zero)
if (offset != Offset.zero) {
}
if (debugNewCanvasSaveCount > debugPreviousCanvasSaveCount)
if (debugNewCanvasSaveCount > debugPreviousCanvasSaveCount) {
throw new UIWidgetsError(
$"{debugNewCanvasSaveCount - debugPreviousCanvasSaveCount} more " +
$"time{((debugNewCanvasSaveCount - debugPreviousCanvasSaveCount == 1) ? "" : "s")} " +

);
if (debugNewCanvasSaveCount < debugPreviousCanvasSaveCount)
}
if (debugNewCanvasSaveCount < debugPreviousCanvasSaveCount) {
throw new UIWidgetsError(
$"The {painter} custom painter called canvas.restore() " +
$"{debugPreviousCanvasSaveCount - debugNewCanvasSaveCount} more " +

"You should only call restore() if you first called save() or saveLayer()."
);
}
return debugNewCanvasSaveCount == debugPreviousCanvasSaveCount;
});
canvas.restore();

}
void _setRasterCacheHints(PaintingContext context) {
if (this.isComplex)
if (this.isComplex) {
if (this.willChange)
}
if (this.willChange) {
}
}
}
}

8
Runtime/widgets/basic.cs


public class CustomPaint : SingleChildRenderObjectWidget {
public CustomPaint(
Key key = null,
ICustomPainter painter = null,
ICustomPainter foregroundPainter = null,
CustomPainter painter = null,
CustomPainter foregroundPainter = null,
Size size = null,
bool isComplex = false,
bool willChange = false,

this.willChange = willChange;
}
public readonly ICustomPainter painter;
public readonly ICustomPainter foregroundPainter;
public readonly CustomPainter painter;
public readonly CustomPainter foregroundPainter;
public readonly Size size;
public readonly bool isComplex;
public readonly bool willChange;

42
Runtime/widgets/scrollbar.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {
public class ScrollbarPainter : ChangeNotifier, ICustomPainter {
public class ScrollbarPainter : ChangeNotifier, CustomPainter {
public ScrollbarPainter(
Color color,
TextDirection textDirection,

this.minOverscrollLength = minOverscrollLength;
fadeoutOpacityAnimation.addListener(this.notifyListeners);
}
const double _kMinThumbExtent = 18.0;
public Color color;

public double minLength;
public double minOverscrollLength;
private ScrollMetrics _lastMetrics;
private AxisDirection? _lastAxisDirection;
ScrollMetrics _lastMetrics;
AxisDirection? _lastAxisDirection;
public void update(ScrollMetrics metrics, AxisDirection axisDirection) {
this._lastMetrics = metrics;

private Paint _paint {
Paint _paint {
get {
var paint = new Paint();
paint.color = this.color.withOpacity(this.color.opacity * this.fadeoutOpacityAnimation.value);

private double _getThumbX(Size size) {
double _getThumbX(Size size) {
switch (textDirection) {
switch (this.textDirection) {
case TextDirection.rtl:
return this.crossAxisMargin;
case TextDirection.ltr:

return 0;
}
private void _paintVerticalThumb(Canvas canvas, Size size, double thumbOffset, double thumbExtent) {
Offset thumbOrigin = new Offset(_getThumbX(size), thumbOffset);
void _paintVerticalThumb(Canvas canvas, Size size, double thumbOffset, double thumbExtent) {
Offset thumbOrigin = new Offset(this._getThumbX(size), thumbOffset);
canvas.drawRect(thumbRect, _paint);
canvas.drawRect(thumbRect, this._paint);
canvas.drawRRect(RRect.fromRectAndRadius(thumbRect, this.radius), _paint);
canvas.drawRRect(RRect.fromRectAndRadius(thumbRect, this.radius), this._paint);
private void _paintHorizontalThumb(Canvas canvas, Size size, double thumbOffset, double thumbExtent) {
void _paintHorizontalThumb(Canvas canvas, Size size, double thumbOffset, double thumbExtent) {
canvas.drawRect(thumbRect, _paint);
canvas.drawRect(thumbRect, this._paint);
canvas.drawRRect(RRect.fromRectAndRadius(thumbRect, this.radius), _paint);
canvas.drawRRect(RRect.fromRectAndRadius(thumbRect, this.radius), this._paint);
private void _paintThumb(
void _paintThumb(
double before,
double inside,
double after,

return;
}
switch (_lastAxisDirection) {
switch (this._lastAxisDirection) {
_paintThumb(this._lastMetrics.extentBefore(), this._lastMetrics.extentInside(),
this._paintThumb(this._lastMetrics.extentBefore(), this._lastMetrics.extentInside(),
_paintThumb(this._lastMetrics.extentAfter(), this._lastMetrics.extentInside(),
this._paintThumb(this._lastMetrics.extentAfter(), this._lastMetrics.extentInside(),
_paintThumb(this._lastMetrics.extentBefore(), this._lastMetrics.extentInside(),
this._paintThumb(this._lastMetrics.extentBefore(), this._lastMetrics.extentInside(),
_paintThumb(this._lastMetrics.extentAfter(), this._lastMetrics.extentInside(),
this._paintThumb(this._lastMetrics.extentAfter(), this._lastMetrics.extentInside(),
this._lastMetrics.extentBefore(), size.width, canvas, size, this._paintHorizontalThumb);
break;
}

return false;
}
public bool shouldRepaint(ICustomPainter oldRaw) {
public bool shouldRepaint(CustomPainter oldRaw) {
if (oldRaw is ScrollbarPainter old) {
return this.color != old.color
|| this.textDirection != old.textDirection

4
Samples/UIWidgetSample/CustomPaintCanvas.cs


}
}
public class GridPainter : CustomPainter {
public class GridPainter : AbstractCustomPainter {
public GridPainter(Listenable repaint) : base(repaint) {
}

canvas.restore();
}
public override bool shouldRepaint(ICustomPainter oldDelegate) {
public override bool shouldRepaint(CustomPainter oldDelegate) {
return false;
}
}

5
Samples/UIWidgetSample/ScrollbarCanvas.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;

protected override Widget getWidget() {
return new Container(
decoration: new BoxDecoration(

);
}
}
}
}
正在加载...
取消
保存