GitHub
5 年前
当前提交
d828a18f
共有 56 个文件被更改,包括 1915 次插入 和 621 次删除
-
2Runtime/gestures/binding.cs
-
160Runtime/gestures/long_press.cs
-
7Runtime/material/app.cs
-
68Runtime/material/text_field.cs
-
2Runtime/material/text_form_field.cs
-
7Runtime/painting/box_border.cs
-
26Runtime/painting/decoration_image.cs
-
98Runtime/painting/gradient.cs
-
26Runtime/painting/image_stream.cs
-
20Runtime/painting/notched_shapes.cs
-
90Runtime/painting/text_painter.cs
-
192Runtime/painting/text_style.cs
-
1Runtime/rendering/binding.cs
-
4Runtime/rendering/box.cs
-
129Runtime/rendering/editable.cs
-
2Runtime/rendering/error.cs
-
5Runtime/rendering/flex.cs
-
164Runtime/rendering/layer.cs
-
9Runtime/rendering/object.cs
-
45Runtime/rendering/paragraph.cs
-
104Runtime/rendering/proxy_box.cs
-
3Runtime/rendering/sliver.cs
-
3Runtime/rendering/sliver_grid.cs
-
2Runtime/rendering/sliver_list.cs
-
240Runtime/ui/painting/path.cs
-
23Runtime/ui/painting/txt/font_manager.cs
-
6Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shader.cs
-
18Runtime/ui/text.cs
-
6Runtime/ui/txt/paragraph.cs
-
7Runtime/ui/window.cs
-
16Runtime/widgets/basic.cs
-
2Runtime/widgets/dismissible.cs
-
77Runtime/widgets/editable_text.cs
-
10Runtime/widgets/fade_in_image.cs
-
4Runtime/widgets/form.cs
-
53Runtime/widgets/gesture_detector.cs
-
79Runtime/widgets/heroes.cs
-
2Runtime/widgets/icon.cs
-
4Runtime/widgets/nested_scroll_view.cs
-
83Runtime/widgets/overlay.cs
-
7Runtime/widgets/page_view.cs
-
6Runtime/widgets/routes.cs
-
26Runtime/widgets/scroll_view.cs
-
39Runtime/widgets/scrollable.cs
-
2Runtime/widgets/single_child_scroll_view.cs
-
13Runtime/widgets/text.cs
-
179Runtime/widgets/text_selection.cs
-
6Samples/UIWidgetSample/LongPressSample.cs
-
36Samples/UIWidgetSample/TextInputSample.cs
-
5Tests/Editor/Paragraph.cs
-
160Runtime/painting/continuous_rectangle_border.cs
-
11Runtime/painting/continuous_rectangle_border.cs.meta
-
220Runtime/painting/strut_style.cs
-
11Runtime/painting/strut_style.cs.meta
-
5Runtime/rendering/debug.cs
-
11Runtime/rendering/debug.cs.meta
|
|||
using System.Runtime.CompilerServices; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
using UnityEngine; |
|||
using Canvas = Unity.UIWidgets.ui.Canvas; |
|||
using Rect = Unity.UIWidgets.ui.Rect; |
|||
|
|||
namespace Unity.UIWidgets.painting { |
|||
public class ContinuousRectangleBorder : ShapeBorder { |
|||
|
|||
public ContinuousRectangleBorder( |
|||
BorderSide side = null, |
|||
BorderRadius borderRadius = null) { |
|||
this.side = side ?? BorderSide.none; |
|||
this.borderRadius = borderRadius ?? BorderRadius.zero; |
|||
} |
|||
|
|||
public readonly BorderRadius borderRadius; |
|||
|
|||
public readonly BorderSide side; |
|||
|
|||
public override EdgeInsets dimensions { |
|||
get { |
|||
return EdgeInsets.all(this.side.width); |
|||
} |
|||
} |
|||
|
|||
public override ShapeBorder scale(float t) { |
|||
return new ContinuousRectangleBorder( |
|||
side: this.side.scale(t), |
|||
borderRadius: this.borderRadius * t |
|||
); |
|||
} |
|||
|
|||
public override ShapeBorder lerpFrom(ShapeBorder a, float t) { |
|||
D.assert(t != null); |
|||
if (a is ContinuousRectangleBorder) { |
|||
return new ContinuousRectangleBorder( |
|||
side: BorderSide.lerp((a as ContinuousRectangleBorder).side, this.side, t), |
|||
borderRadius: BorderRadius.lerp((a as ContinuousRectangleBorder).borderRadius, |
|||
this.borderRadius, t) |
|||
); |
|||
} |
|||
return base.lerpFrom(a, t); |
|||
} |
|||
|
|||
public override ShapeBorder lerpTo(ShapeBorder b, float t) { |
|||
D.assert(t != null); |
|||
if (b is ContinuousRectangleBorder) { |
|||
return new ContinuousRectangleBorder( |
|||
side: BorderSide.lerp(this.side, (b as ContinuousRectangleBorder).side, t), |
|||
borderRadius: BorderRadius.lerp(this.borderRadius, |
|||
(b as ContinuousRectangleBorder).borderRadius, t) |
|||
); |
|||
} |
|||
return base.lerpTo(b, t); |
|||
} |
|||
|
|||
float _clampToShortest(RRect rrect, float value) { |
|||
return value > rrect.shortestSide ? rrect.shortestSide : value; |
|||
} |
|||
|
|||
Path _getPath(RRect rrect) { |
|||
float left = rrect.left; |
|||
float right = rrect.right; |
|||
float top = rrect.top; |
|||
float bottom = rrect.bottom; |
|||
|
|||
float tlRadiusX = Mathf.Max(0.0f, this._clampToShortest(rrect, rrect.tlRadiusX)); |
|||
float tlRadiusY = Mathf.Max(0.0f, this._clampToShortest(rrect, rrect.tlRadiusY)); |
|||
float trRadiusX = Mathf.Max(0.0f, this._clampToShortest(rrect, rrect.trRadiusX)); |
|||
float trRadiusY = Mathf.Max(0.0f, this._clampToShortest(rrect, rrect.trRadiusY)); |
|||
float blRadiusX = Mathf.Max(0.0f, this._clampToShortest(rrect, rrect.blRadiusX)); |
|||
float blRadiusY = Mathf.Max(0.0f, this._clampToShortest(rrect, rrect.blRadiusY)); |
|||
float brRadiusX = Mathf.Max(0.0f, this._clampToShortest(rrect, rrect.brRadiusX)); |
|||
float brRadiusY = Mathf.Max(0.0f, this._clampToShortest(rrect, rrect.brRadiusY)); |
|||
|
|||
Path path = new Path(); |
|||
path.moveTo(left, top + tlRadiusX); |
|||
path.cubicTo(left, top, left, top, left + tlRadiusY, top); |
|||
path.lineTo(right - trRadiusX, top); |
|||
path.cubicTo(right, top, right, top, right, top + trRadiusY); |
|||
path.lineTo(right, bottom - blRadiusX); |
|||
path.cubicTo(right, bottom, right, bottom, right - blRadiusY, bottom); |
|||
path.lineTo(left + brRadiusX, bottom); |
|||
path.cubicTo(left, bottom, left, bottom, left, bottom - brRadiusY); |
|||
path.close(); |
|||
return path; |
|||
} |
|||
|
|||
public override Path getInnerPath(Rect rect) { |
|||
return this._getPath(this.borderRadius.toRRect(rect).deflate(this.side.width)); |
|||
} |
|||
|
|||
public override Path getOuterPath(Rect rect) { |
|||
return this._getPath(this.borderRadius.toRRect(rect)); |
|||
} |
|||
|
|||
public override void paint(Canvas canvas, Rect rect) { |
|||
if (rect.isEmpty) { |
|||
return; |
|||
} |
|||
|
|||
switch (this.side.style) { |
|||
case BorderStyle.none: |
|||
break; |
|||
case BorderStyle.solid: |
|||
Path path = this.getOuterPath(rect); |
|||
Paint paint = this.side.toPaint(); |
|||
canvas.drawPath(path, paint); |
|||
break; |
|||
} |
|||
} |
|||
public bool Equals(ContinuousRectangleBorder other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return this.side == other.side && this.borderRadius == other.borderRadius; |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
if (ReferenceEquals(null, obj)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, obj)) { |
|||
return true; |
|||
} |
|||
|
|||
if (obj.GetType() != this.GetType()) { |
|||
return false; |
|||
} |
|||
|
|||
return this.Equals((ContinuousRectangleBorder) obj); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
var hashCode = (this.side != null ? this.side.GetHashCode() : 0); |
|||
hashCode = (hashCode * 397) ^ (this.borderRadius != null ? this.borderRadius.GetHashCode() : 0); |
|||
return hashCode; |
|||
} |
|||
|
|||
public static bool operator ==(ContinuousRectangleBorder left, ContinuousRectangleBorder right) { |
|||
return Equals(left, right); |
|||
} |
|||
|
|||
public static bool operator !=(ContinuousRectangleBorder left, ContinuousRectangleBorder right) { |
|||
return !Equals(left, right); |
|||
} |
|||
|
|||
public override string ToString() { |
|||
return $"{this.GetType()}({this.side}, {this.borderRadius})"; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 85a3d3f3c01b8482e898b19fe9779021 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.painting { |
|||
public class StrutStyle : Diagnosticable { |
|||
public StrutStyle( |
|||
string fontFamily = null, |
|||
List<string> fontFamilyFallback = null, |
|||
float? fontSize = null, |
|||
float? height = null, |
|||
float? leading = null, |
|||
FontWeight fontWeight = null, |
|||
FontStyle? fontStyle = null, |
|||
bool forceStrutHeight = false, |
|||
string debugLabel = null |
|||
) { |
|||
D.assert(fontSize == null || fontSize > 0); |
|||
D.assert(leading == null || leading >= 0); |
|||
this.fontFamily = fontFamily; |
|||
this._fontFamilyFallback = fontFamilyFallback; |
|||
this.fontSize = fontSize; |
|||
this.height = height; |
|||
this.fontWeight = fontWeight; |
|||
this.fontStyle = fontStyle; |
|||
this.leading = leading; |
|||
this.forceStrutHeight = forceStrutHeight; |
|||
this.debugLabel = debugLabel; |
|||
} |
|||
|
|||
public static StrutStyle fromTextStyle( |
|||
TextStyle textStyle, |
|||
string fontFamily = null, |
|||
List<string> fontFamilyFallback = null, |
|||
float? fontSize = null, |
|||
float? height = null, |
|||
float? leading = null, |
|||
FontWeight fontWeight = null, |
|||
FontStyle? fontStyle = null, |
|||
bool forceStrutHeight = false, |
|||
string debugLabel = null |
|||
) { |
|||
D.assert(textStyle != null); |
|||
D.assert(fontSize == null || fontSize > 0); |
|||
D.assert(leading == null || leading >= 0); |
|||
return new StrutStyle( |
|||
fontFamily: fontFamily ?? textStyle.fontFamily, |
|||
fontFamilyFallback: fontFamilyFallback ?? textStyle.fontFamilyFallback, |
|||
height: height ?? textStyle.height, |
|||
fontSize: fontSize ?? textStyle.fontSize, |
|||
fontWeight: fontWeight ?? textStyle.fontWeight, |
|||
fontStyle: fontStyle ?? textStyle.fontStyle, |
|||
debugLabel: debugLabel ?? textStyle.debugLabel |
|||
); |
|||
} |
|||
|
|||
public static readonly StrutStyle disabled = new StrutStyle( |
|||
height: 0.0f, |
|||
leading: 0.0f |
|||
); |
|||
|
|||
public readonly string fontFamily; |
|||
|
|||
public List<string> fontFamilyFallback { |
|||
get { return this._fontFamilyFallback; } |
|||
} |
|||
|
|||
readonly List<string> _fontFamilyFallback; |
|||
|
|||
public readonly float? fontSize; |
|||
public readonly float? height; |
|||
public readonly FontWeight fontWeight; |
|||
public readonly FontStyle? fontStyle; |
|||
public readonly float? leading; |
|||
public readonly bool forceStrutHeight; |
|||
public readonly string debugLabel; |
|||
|
|||
public RenderComparison compareTo(StrutStyle other) { |
|||
if (ReferenceEquals(this, other)) { |
|||
return RenderComparison.identical; |
|||
} |
|||
|
|||
if (other == null) { |
|||
return RenderComparison.layout; |
|||
} |
|||
|
|||
if (this.fontFamily != other.fontFamily || |
|||
this.fontSize != other.fontSize || |
|||
this.fontWeight != other.fontWeight || |
|||
this.fontStyle != other.fontStyle || |
|||
this.height != other.height || |
|||
this.leading != other.leading || |
|||
this.forceStrutHeight != other.forceStrutHeight || |
|||
!CollectionUtils.equalsList(this.fontFamilyFallback, other.fontFamilyFallback)) { |
|||
return RenderComparison.layout; |
|||
} |
|||
|
|||
return RenderComparison.identical; |
|||
} |
|||
|
|||
public StrutStyle inheritFromTextStyle(TextStyle other) { |
|||
if (other == null) { |
|||
return this; |
|||
} |
|||
|
|||
return new StrutStyle( |
|||
fontFamily: this.fontFamily ?? other.fontFamily, |
|||
fontFamilyFallback: this.fontFamilyFallback ?? other.fontFamilyFallback, |
|||
height: this.height ?? other.height, |
|||
leading: this.leading, |
|||
fontSize: this.fontSize ?? other.fontSize, |
|||
fontWeight: this.fontWeight ?? other.fontWeight, |
|||
fontStyle: this.fontStyle ?? other.fontStyle, |
|||
forceStrutHeight: this.forceStrutHeight, |
|||
debugLabel: this.debugLabel ?? other.debugLabel |
|||
); |
|||
} |
|||
|
|||
public bool Equals(StrutStyle other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return this.fontFamily == other.fontFamily && |
|||
this.fontSize == other.fontSize && |
|||
this.fontWeight == other.fontWeight && |
|||
this.fontStyle == other.fontStyle && |
|||
this.height == other.height && |
|||
this.leading == other.leading && |
|||
this.forceStrutHeight == other.forceStrutHeight; |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
if (ReferenceEquals(null, obj)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, obj)) { |
|||
return true; |
|||
} |
|||
|
|||
if (obj.GetType() != this.GetType()) { |
|||
return false; |
|||
} |
|||
|
|||
return this.Equals((StrutStyle) obj); |
|||
} |
|||
|
|||
public static bool operator ==(StrutStyle left, StrutStyle right) { |
|||
return Equals(left, right); |
|||
} |
|||
|
|||
public static bool operator !=(StrutStyle left, StrutStyle right) { |
|||
return !Equals(left, right); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
unchecked { |
|||
var hashCode = this.fontFamily?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ (this.fontSize?.GetHashCode() ?? 0); |
|||
hashCode = (hashCode * 397) ^ (this.fontWeight?.GetHashCode() ?? 0); |
|||
hashCode = (hashCode * 397) ^ (this.fontStyle?.GetHashCode() ?? 0); |
|||
hashCode = (hashCode * 397) ^ (this.height?.GetHashCode() ?? 0); |
|||
hashCode = (hashCode * 397) ^ (this.leading?.GetHashCode() ?? 0); |
|||
hashCode = (hashCode * 397) ^ this.forceStrutHeight.GetHashCode(); |
|||
return hashCode; |
|||
} |
|||
} |
|||
|
|||
public override string toStringShort() { |
|||
return $"{this.GetType()}"; |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
if (this.debugLabel != null) { |
|||
properties.add(new MessageProperty("debugLabel", this.debugLabel)); |
|||
} |
|||
|
|||
List<DiagnosticsNode> styles = new List<DiagnosticsNode>(); |
|||
styles.Add(new StringProperty("family", this.fontFamily, defaultValue: Diagnostics.kNullDefaultValue, |
|||
quoted: false)); |
|||
styles.Add(new EnumerableProperty<string>("familyFallback", this.fontFamilyFallback)); |
|||
styles.Add(new DiagnosticsProperty<float?>("size", this.fontSize, |
|||
defaultValue: Diagnostics.kNullDefaultValue)); |
|||
string weightDescription = ""; |
|||
if (this.fontWeight != null) { |
|||
weightDescription = this.fontWeight.weightValue.ToString(); |
|||
} |
|||
|
|||
styles.Add(new DiagnosticsProperty<FontWeight>( |
|||
"weight", this.fontWeight, |
|||
description: weightDescription, |
|||
defaultValue: Diagnostics.kNullDefaultValue |
|||
)); |
|||
styles.Add(new EnumProperty<FontStyle?>("style", this.fontStyle, |
|||
defaultValue: Diagnostics.kNullDefaultValue)); |
|||
styles.Add(new DiagnosticsProperty<float?>("height", this.height, |
|||
defaultValue: Diagnostics.kNullDefaultValue)); |
|||
styles.Add(new FlagProperty("forceStrutHeight", value: this.forceStrutHeight, |
|||
defaultValue: Diagnostics.kNullDefaultValue)); |
|||
|
|||
bool styleSpecified = styles.Any((DiagnosticsNode n) => !n.isFiltered(DiagnosticLevel.info)); |
|||
foreach (var style in styles) { |
|||
properties.add(style); |
|||
} |
|||
|
|||
if (!styleSpecified) { |
|||
properties.add(new FlagProperty("forceStrutHeight", value: this.forceStrutHeight, |
|||
ifTrue: "<strut height forced>", |
|||
ifFalse: "<strut height normal>")); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5ec5d77d67faf40bfaef77f14968228c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace Unity.UIWidgets.rendering { |
|||
public static class RenderingDebugUtils { |
|||
public static bool debugCheckElevationsEnabled = false; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: bb8359f97867cd54592d13cfe1b1d39a |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue