xingwei.zhu
6 年前
当前提交
374b5ae2
共有 7 个文件被更改,包括 262 次插入 和 16 次删除
-
8Runtime/material/button_theme.cs
-
100Runtime/rendering/layer.cs
-
19Runtime/rendering/proxy_box.cs
-
11Runtime/ui/compositing.cs
-
25Samples/UIWidgetSample/MaterialSample.cs
-
104Runtime/flow/physical_shape_layer.cs
-
11Runtime/flow/physical_shape_layer.cs.meta
|
|||
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) { |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e4609617e4ba5483b811e8cc9d60ce15 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue