浏览代码

scaffold test sample

/main
xingwei.zhu 6 年前
当前提交
374b5ae2
共有 7 个文件被更改,包括 262 次插入16 次删除
  1. 8
      Runtime/material/button_theme.cs
  2. 100
      Runtime/rendering/layer.cs
  3. 19
      Runtime/rendering/proxy_box.cs
  4. 11
      Runtime/ui/compositing.cs
  5. 25
      Samples/UIWidgetSample/MaterialSample.cs
  6. 104
      Runtime/flow/physical_shape_layer.cs
  7. 11
      Runtime/flow/physical_shape_layer.cs.meta

8
Runtime/material/button_theme.cs


hashCode = (hashCode * 397) ^ this.padding.GetHashCode();
hashCode = (hashCode * 397) ^ this.shape.GetHashCode();
hashCode = (hashCode * 397) ^ this.alignedDropdown.GetHashCode();
hashCode = (hashCode * 397) ^ this._buttonColor.GetHashCode();
hashCode = (hashCode * 397) ^ this._disabledColor.GetHashCode();
hashCode = (hashCode * 397) ^ this._highlightColor.GetHashCode();
hashCode = (hashCode * 397) ^ this._splashColor.GetHashCode();
hashCode = (hashCode * 397) ^ this._buttonColor?.GetHashCode() ?? 1;
hashCode = (hashCode * 397) ^ this._disabledColor?.GetHashCode() ?? 1;
hashCode = (hashCode * 397) ^ this._highlightColor?.GetHashCode() ?? 1;
hashCode = (hashCode * 397) ^ this._splashColor?.GetHashCode() ?? 1;
hashCode = (hashCode * 397) ^ this.colorScheme.GetHashCode();
hashCode = (hashCode * 397) ^ this._materialTapTargetSize.GetHashCode();
return hashCode;

100
Runtime/rendering/layer.cs


properties.add(new DiagnosticsProperty<Size>("size", this.size, defaultValue: null));
}
}
public class PhysicalModelLayer : ContainerLayer {
public PhysicalModelLayer(
Path clipPath = null,
Clip clipBehavior = Clip.none,
float? elevation = null,
Color color = null,
Color shadowColor = null) {
D.assert(clipPath != null);
D.assert(elevation != null);
D.assert(color != null);
D.assert(shadowColor != null);
this._clipPath = clipPath;
this._clipBehavior = clipBehavior;
this._elevation = elevation.Value;
this._color = color;
this.shadowColor = shadowColor;
}
public Path clipPath {
get { return this._clipPath; }
set {
if (value != this._clipPath) {
this._clipPath = value;
this.markNeedsAddToScene();
}
}
}
Path _clipPath;
public Clip clipBehavior {
get { return this._clipBehavior; }
set {
if (value != this._clipBehavior) {
this._clipBehavior = value;
this.markNeedsAddToScene();
}
}
}
Clip _clipBehavior;
public float elevation {
get { return this._elevation; }
set {
if (value != this._elevation) {
this._elevation = value;
this.markNeedsAddToScene();
}
}
}
float _elevation;
public Color color {
get { return this._color; }
set {
if (value != this._color) {
this._color = value;
this.markNeedsAddToScene();
}
}
}
Color _color;
public Color shadowColor {
get { return this._shadowColor; }
set {
if (value != this._shadowColor) {
this._shadowColor = value;
this.markNeedsAddToScene();
}
}
}
Color _shadowColor;
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {
layerOffset = layerOffset ?? Offset.zero;
builder.pushPhysicalShape(
path: this.clipPath.shift(layerOffset),
elevation: this.elevation,
color: this.color,
shadowColor: this.shadowColor,
clipBehavior: this.clipBehavior);
this.addChildrenToScene(builder, layerOffset);
builder.pop();
return null;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FloatProperty("elevation", this.elevation));
properties.add(new DiagnosticsProperty<Color>("color", this.color));
}
}
}

19
Runtime/rendering/proxy_box.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using UnityEditor.Rendering;
namespace Unity.UIWidgets.rendering {
public class RenderProxyBox : RenderProxyBoxMixinRenderObjectWithChildMixinRenderBox<RenderBox> {

}
if (this.needsCompositing) {
ContainerLayer container = new ContainerLayer();
context.pushLayer(container, base.paint, offset, childPaintBounds: offsetBounds);
PhysicalModelLayer physicalModel = new PhysicalModelLayer(
clipPath: offsetRRectAsPath,
clipBehavior: this.clipBehavior,
elevation: this.elevation,
color: this.color,
shadowColor: this.shadowColor);
context.pushLayer(physicalModel, base.paint, offset, childPaintBounds: offsetBounds);
return;
}

// }
if (this.needsCompositing) {
ContainerLayer container = new ContainerLayer();
context.pushLayer(container, base.paint, offset, childPaintBounds: offsetBounds);
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;
}

11
Runtime/ui/compositing.cs


);
this._currentLayer.add(layer);
}
public Layer pushPhysicalShape(Path path, float elevation, Color color, Color shadowColor, Clip clipBehavior) {
var layer = new PhysicalShapeLayer(clipBehavior);
layer.set_path(path);
layer.set_elevation(elevation);
layer.set_color(color);
layer.set_shadow_color(shadowColor);
layer.set_device_pixel_ratio(Window.instance.devicePixelRatio);
this._pushLayer(layer);
return layer;
}
}
public class Scene : IDisposable {

25
Samples/UIWidgetSample/MaterialSample.cs


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.ui;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsSample {
public class MaterialSample : UIWidgetsSamplePanel {

};
protected override Widget createWidget() {
return new MaterialApp(
home: this.testCases[this.testCaseId]);
return new WidgetsApp(
home: this.testCases[this.testCaseId],
pageRouteBuilder: this.pageRouteBuilder);
}
protected override void OnEnable() {
base.OnEnable();
FontManager.instance.addFont(Resources.Load<Font>(path: "MaterialIcons-Regular"));
}
}

}
public override Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
return new Scaffold(
backgroundColor : Colors.blue,
//color: Colors.blue,
onPressed: () => {
this._select((Choice.choices[0]));
}

//color: Colors.blue,
onPressed: () => {
this._select((Choice.choices[1]));
}

padding: EdgeInsets.all(16.0f),
child: new ChoiceCard(choice: this._selectedChoice)
)
)
);
}
}

class MaterialInkWidgetState : State<MaterialInkWellWidget> {
public override Widget build(BuildContext context) {
return new Material(
//color: Colors.blue,
width: 30,
height: 30,
width: 200,
height: 200,
child: new InkWell(
borderRadius: BorderRadius.circular(2.0f),
highlightColor: new Color(0xAAFF0000),

104
Runtime/flow/physical_shape_layer.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.flow {
public class PhysicalShapeLayer : ContainerLayer {
public PhysicalShapeLayer(
Clip clipBehavior) {
this.isRect_ = false;
this.clip_behavior_ = clipBehavior;
}
float elevation_;
Color color_;
Color shadow_color_;
float device_pixel_ratio_;
Path path_;
bool isRect_;
Rect frameRRect_;
Clip clip_behavior_;
public void set_path(Path path) {
this.path_ = path;
this.isRect_ = false;
this.frameRRect_ = path.getBounds();
}
public void set_elevation(float elevation) {
this.elevation_ = elevation;
}
public void set_color(Color color) {
this.color_ = color;
}
public void set_shadow_color(Color shadowColor) {
this.shadow_color_ = shadowColor;
}
public void set_device_pixel_ratio(float dpr) {
this.device_pixel_ratio_ = dpr;
}
public override void preroll(PrerollContext context, Matrix3 matrix) {
Rect child_paint_bounds = Rect.zero;
this.prerollChildren(context, matrix, ref child_paint_bounds);
if (this.elevation_ == 0) {
this.paintBounds = this.path_.getBounds();
}
else {
Rect bounds = this.path_.getBounds();
//todo xingwei.zhu: draw & clip shadow
//bounds.outset(20.0f, 20.0f);
this.paintBounds = bounds;
}
}
public override void paint(PaintContext context) {
if (this.elevation_ != 0) {
this.drawShadow(context.canvas, this.path_, this.shadow_color_, this.elevation_,
this.color_.alpha != 255, this.device_pixel_ratio_);
}
Paint paint = new Paint {color = this.color_};
if (this.clip_behavior_ != Clip.antiAliasWithSaveLayer) {
context.canvas.drawPath(this.path_, paint);
}
context.canvas.save();
int saveCount = 1;
switch (this.clip_behavior_) {
case Clip.hardEdge:
context.canvas.clipPath(this.path_);
break;
case Clip.antiAlias:
context.canvas.clipPath(this.path_);
break;
case Clip.antiAliasWithSaveLayer:
context.canvas.clipPath(this.path_);
context.canvas.saveLayer(this.paintBounds, null);
saveCount++;
break;
case Clip.none:
break;
}
if (this.clip_behavior_ == Clip.antiAliasWithSaveLayer) {
//todo xingwei.zhu: drawPaint
context.canvas.drawPath(this.path_, paint);
}
this.paintChildren(context);
for (int i = 0; i < saveCount; i++) {
context.canvas.restore();
}
}
void drawShadow(Canvas canvas, Path path, Color color, float elevation, bool transparentOccluder, float dpr) {
}
}
}

11
Runtime/flow/physical_shape_layer.cs.meta


fileFormatVersion: 2
guid: e4609617e4ba5483b811e8cc9d60ce15
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存