Shiyun Wen
4 年前
当前提交
e7cbeabb
共有 67 个文件被更改,包括 3913 次插入 和 538 次删除
-
142Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs
-
84com.unity.uiwidgets/Runtime/foundation/assertions.cs
-
71com.unity.uiwidgets/Runtime/foundation/diagnostics.cs
-
7com.unity.uiwidgets/Runtime/gestures/mouse_tracking.cs
-
35com.unity.uiwidgets/Runtime/painting/binding.cs
-
2com.unity.uiwidgets/Runtime/painting/border_radius.cs
-
9com.unity.uiwidgets/Runtime/painting/box_border.cs
-
40com.unity.uiwidgets/Runtime/painting/box_decoration.cs
-
2com.unity.uiwidgets/Runtime/painting/decoration.cs
-
16com.unity.uiwidgets/Runtime/painting/edge_insets.cs
-
25com.unity.uiwidgets/Runtime/painting/gradient.cs
-
215com.unity.uiwidgets/Runtime/painting/image_provider.cs
-
20com.unity.uiwidgets/Runtime/painting/inline_span.cs
-
4com.unity.uiwidgets/Runtime/painting/shape_decoration.cs
-
74com.unity.uiwidgets/Runtime/painting/text_painter.cs
-
145com.unity.uiwidgets/Runtime/painting/text_span.cs
-
42com.unity.uiwidgets/Runtime/painting/text_style.cs
-
24com.unity.uiwidgets/Runtime/rendering/binding.cs
-
2com.unity.uiwidgets/Runtime/rendering/box.cs
-
96com.unity.uiwidgets/Runtime/rendering/error.cs
-
19com.unity.uiwidgets/Runtime/rendering/layer.cs
-
2com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs
-
4com.unity.uiwidgets/Runtime/rendering/object.cs
-
16com.unity.uiwidgets/Runtime/rendering/proxy_box.cs
-
2com.unity.uiwidgets/Runtime/rendering/rotated_box.cs
-
2com.unity.uiwidgets/Runtime/rendering/sliver.cs
-
17com.unity.uiwidgets/Runtime/rendering/view.cs
-
2com.unity.uiwidgets/Runtime/rendering/viewport.cs
-
886com.unity.uiwidgets/Runtime/ui2/Matrix4.cs
-
2com.unity.uiwidgets/Runtime/ui2/isolate.cs
-
99com.unity.uiwidgets/Runtime/ui2/painting.cs
-
10com.unity.uiwidgets/Runtime/widgets/basic.cs
-
35com.unity.uiwidgets/Runtime/widgets/binding.cs
-
1com.unity.uiwidgets/Runtime/widgets/dismissible.cs
-
2com.unity.uiwidgets/Runtime/widgets/editable_text.cs
-
708com.unity.uiwidgets/Runtime/widgets/framework.cs
-
2com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs
-
2com.unity.uiwidgets/Runtime/widgets/layout_builder.cs
-
2com.unity.uiwidgets/Runtime/widgets/list_wheel_scroll_view.cs
-
2com.unity.uiwidgets/Runtime/widgets/selectable_text.cs
-
2com.unity.uiwidgets/Runtime/widgets/sliver.cs
-
2com.unity.uiwidgets/Runtime/widgets/sliver_persistent_header.cs
-
2com.unity.uiwidgets/Runtime/widgets/table.cs
-
2com.unity.uiwidgets/Runtime/widgets/text.cs
-
4com.unity.uiwidgets/Runtime/widgets/transitions.cs
-
6com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs
-
2engine/Build.bee.cs
-
1engine/README.md
-
6engine/src/lib/ui/painting/path.h
-
52engine/src/lib/ui/painting/path_measure.cc
-
3engine/src/lib/ui/painting/path_measure.h
-
8engine/src/shell/platform/unity/unity_surface_manager.cc
-
7Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/confetti.json.meta
-
1001Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/test.gif
-
7Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/test.gif.meta
-
1Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/wine.json
-
7Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/wine.json.meta
-
44com.unity.uiwidgets/Runtime/painting/placeholder_span.cs
-
3com.unity.uiwidgets/Runtime/painting/placeholder_span.cs.meta
-
132com.unity.uiwidgets/Runtime/rendering/lottie.cs
-
3com.unity.uiwidgets/Runtime/rendering/lottie.cs.meta
-
104com.unity.uiwidgets/Runtime/widgets/LottiePainter.cs
-
3com.unity.uiwidgets/Runtime/widgets/LottiePainter.cs.meta
-
109com.unity.uiwidgets/Runtime/widgets/widget_span.cs
-
3com.unity.uiwidgets/Runtime/widgets/widget_span.cs.meta
-
41engine/src/lib/ui/painting/skottie.cc
-
26engine/src/lib/ui/painting/skottie.h
886
com.unity.uiwidgets/Runtime/ui2/Matrix4.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
708
com.unity.uiwidgets/Runtime/widgets/framework.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: ac26747b511ae1e42b7ee598ca4fc76d |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/test.gif
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: d0c98e9a4446a81498786934f0bb4268 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1
Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/wine.json
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: e6c5720c879142e49a96f1d129c9a492 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.painting { |
|||
abstract class PlaceholderSpan : InlineSpan { |
|||
public PlaceholderSpan( |
|||
TextBaseline baseline, |
|||
TextStyle style, |
|||
PlaceholderAlignment alignment = PlaceholderAlignment.bottom, |
|||
HoverRecognizer hoverRecognizer = null |
|||
) : base(style: style, hoverRecognizer: hoverRecognizer) { |
|||
this.baseline = baseline; |
|||
this.alignment = alignment; |
|||
} |
|||
|
|||
public PlaceholderAlignment alignment; |
|||
|
|||
public TextBaseline baseline; |
|||
|
|||
public override void computeToPlainText( |
|||
StringBuilder buffer, |
|||
bool includeSemanticsLabels = true, |
|||
bool includePlaceholders = true |
|||
) { |
|||
if (includePlaceholders) { |
|||
buffer.Append('\uFFFC'); |
|||
} |
|||
} |
|||
|
|||
public override void computeSemanticsInformation(List<InlineSpanSemanticsInformation> collector) { |
|||
collector.Add(InlineSpanSemanticsInformation.placeholder); |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
|
|||
properties.add(new EnumProperty<PlaceholderAlignment>("alignment", alignment, defaultValue: null)); |
|||
properties.add(new EnumProperty<TextBaseline>("baseline", baseline, defaultValue: null)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c1dc25aeb48f4abbb683062b2a1d4582 |
|||
timeCreated: 1606291325 |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.rendering { |
|||
public class RenderLottie : RenderBox { |
|||
public RenderLottie( |
|||
Skottie skottie, |
|||
float? width = null, |
|||
float? height = null, |
|||
float scale = 1.0f, |
|||
float frame = 0 |
|||
) { |
|||
_width = width; |
|||
_height = height; |
|||
_scale = scale; |
|||
_skottie = skottie; |
|||
_frame = frame; |
|||
_duration = skottie.duration(); |
|||
} |
|||
|
|||
Skottie _skottie; |
|||
float _frame = 0; |
|||
float _duration = 0; |
|||
|
|||
public float frame { |
|||
get { return _frame; } |
|||
set { |
|||
while (value > _duration) { |
|||
value -= _duration; |
|||
} |
|||
if (value == _frame) { |
|||
return; |
|||
} |
|||
|
|||
_frame = value; |
|||
markNeedsLayout(); |
|||
} |
|||
} |
|||
|
|||
float? _width; |
|||
|
|||
public float? width { |
|||
get { return _width; } |
|||
set { |
|||
if (value == _width) { |
|||
return; |
|||
} |
|||
|
|||
_width = value; |
|||
markNeedsLayout(); |
|||
} |
|||
} |
|||
|
|||
float? _height; |
|||
|
|||
public float? height { |
|||
get { return _height; } |
|||
set { |
|||
if (value == _height) { |
|||
return; |
|||
} |
|||
|
|||
_height = value; |
|||
markNeedsLayout(); |
|||
} |
|||
} |
|||
|
|||
|
|||
float _scale; |
|||
|
|||
public float scale { |
|||
get { return _scale; } |
|||
set { |
|||
if (value == _scale) { |
|||
return; |
|||
} |
|||
|
|||
_scale = value; |
|||
markNeedsLayout(); |
|||
} |
|||
} |
|||
|
|||
Size _sizeForConstraints(BoxConstraints constraints) { |
|||
constraints = BoxConstraints.tightFor( |
|||
_width, |
|||
_height |
|||
).enforce(constraints); |
|||
|
|||
return constraints.smallest; |
|||
} |
|||
|
|||
protected override float computeMinIntrinsicWidth(float height) { |
|||
D.assert(height >= 0.0); |
|||
if (_width == null && _height == null) { |
|||
return 0.0f; |
|||
} |
|||
|
|||
return _sizeForConstraints(BoxConstraints.tightForFinite(height: height)).width; |
|||
} |
|||
|
|||
protected override float computeMaxIntrinsicWidth(float height) { |
|||
D.assert(height >= 0.0); |
|||
return _sizeForConstraints(BoxConstraints.tightForFinite(height: height)).width; |
|||
} |
|||
|
|||
protected override float computeMinIntrinsicHeight(float width) { |
|||
D.assert(width >= 0.0); |
|||
if (_width == null && _height == null) { |
|||
return 0.0f; |
|||
} |
|||
|
|||
return _sizeForConstraints(BoxConstraints.tightForFinite(width: width)).height; |
|||
} |
|||
|
|||
protected internal override float computeMaxIntrinsicHeight(float width) { |
|||
D.assert(width >= 0.0); |
|||
return _sizeForConstraints(BoxConstraints.tightForFinite(width: width)).height; |
|||
} |
|||
|
|||
protected override bool hitTestSelf(Offset position) { |
|||
return true; |
|||
} |
|||
|
|||
protected override void performLayout() { |
|||
size = _sizeForConstraints(constraints); |
|||
} |
|||
|
|||
public override void paint(PaintingContext context, Offset offset) { |
|||
_skottie.paint(context.canvas, offset, _width ?? 0, _height ?? 0, _frame); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d638e264913843d89da562fca3c33484 |
|||
timeCreated: 1605844378 |
|
|||
using System; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.async2; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using UnityEngine; |
|||
using Path = System.IO.Path; |
|||
|
|||
namespace Unity.UIWidgets.widgets { |
|||
public class Lottie : StatefulWidget { |
|||
public Skottie _skottie = null; |
|||
public float _frame = 0; |
|||
|
|||
public Lottie(string path, float frame) { |
|||
D.assert(path != null); |
|||
_skottie = new Skottie(Path.Combine(Application.streamingAssetsPath, path)); |
|||
_frame = frame; |
|||
} |
|||
|
|||
public override State createState() { |
|||
return new LottieState(); |
|||
} |
|||
} |
|||
|
|||
public class LottieState : State<Lottie> { |
|||
public override Widget build(BuildContext context) { |
|||
return new LottieRenderObjectWidget(widget._skottie, widget._frame); |
|||
} |
|||
} |
|||
|
|||
public class LottieRenderObjectWidget : LeafRenderObjectWidget { |
|||
Skottie _anime; |
|||
float _frame; |
|||
float _duration; |
|||
|
|||
public override void updateRenderObject(BuildContext context, RenderObject renderObject) { |
|||
base.updateRenderObject(context, renderObject); |
|||
var a = (RenderLottie) renderObject; |
|||
a.frame = _frame*_duration; |
|||
} |
|||
|
|||
public LottieRenderObjectWidget(Skottie anime, float frame) { |
|||
_anime = anime; |
|||
_frame = frame; |
|||
_duration = anime.duration(); |
|||
} |
|||
|
|||
public override RenderObject createRenderObject(BuildContext context) { |
|||
return new RenderLottie(_anime, 100, 100, frame: _frame); |
|||
} |
|||
} |
|||
|
|||
public class AnimatedLottie : ImplicitlyAnimatedWidget { |
|||
public Skottie _skottie = null; |
|||
public float _frame = 0; |
|||
|
|||
public AnimatedLottie( |
|||
string path, |
|||
Key key = null, |
|||
Curve curve = null, |
|||
TimeSpan? duration = null, |
|||
float frame = 0 |
|||
) :base(key: key, curve: curve, duration: duration){ |
|||
_skottie = new Skottie(Path.Combine(Application.streamingAssetsPath, path)); |
|||
_frame = frame; |
|||
} |
|||
|
|||
AnimatedLottie( |
|||
Skottie skottie, |
|||
Key key = null, |
|||
Curve curve = null, |
|||
TimeSpan? duration = null, |
|||
float frame = 0 |
|||
) :base(key: key, curve: curve, duration: duration){ |
|||
_skottie = skottie; |
|||
_frame = frame; |
|||
} |
|||
|
|||
public static AnimatedLottie file(string path, Key key = null, Curve curve = null, TimeSpan? duration = null, |
|||
float frame = 0) { |
|||
var skottie = new Skottie(Path.Combine(Application.streamingAssetsPath, path)); |
|||
duration = duration ?? TimeSpan.FromSeconds(skottie.duration()); |
|||
return new AnimatedLottie(skottie, key, curve, duration, frame); |
|||
} |
|||
|
|||
public override State createState() { |
|||
return new _AnimatedLottieState(); |
|||
} |
|||
} |
|||
|
|||
class _AnimatedLottieState : AnimatedWidgetBaseState<AnimatedLottie> { |
|||
FloatTween frame; |
|||
|
|||
protected override void forEachTween(TweenVisitor visitor) { |
|||
frame = (FloatTween) visitor.visit(this, frame, widget._frame, |
|||
(value) => new FloatTween(begin: value, value)); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new LottieRenderObjectWidget(widget._skottie, frame.lerp(animation.value)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 719affe0aa514bbca2666a67eedd57a0 |
|||
timeCreated: 1605658320 |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.widgets { |
|||
class WidgetSpan : PlaceholderSpan { |
|||
public WidgetSpan( |
|||
Widget child, |
|||
TextBaseline baseline, |
|||
TextStyle style, |
|||
PlaceholderAlignment alignment = PlaceholderAlignment.bottom |
|||
) : base( |
|||
alignment: alignment, |
|||
baseline: baseline, |
|||
style: style |
|||
) { |
|||
D.assert(child != null); |
|||
D.assert(!( |
|||
(alignment == PlaceholderAlignment.aboveBaseline) || |
|||
(alignment == PlaceholderAlignment.belowBaseline) || |
|||
(alignment == PlaceholderAlignment.baseline) |
|||
)); |
|||
this.child = child; |
|||
} |
|||
|
|||
Widget child; |
|||
|
|||
public override void build( |
|||
ParagraphBuilder builder, |
|||
float textScaleFactor = 1.0f, |
|||
List<PlaceholderDimensions> dimensions = null) { |
|||
D.assert(DebugAssertIsValid()); |
|||
D.assert(dimensions != null); |
|||
bool hasStyle = style != null; |
|||
if (hasStyle) { |
|||
builder.pushStyle(style.getTextStyle(textScaleFactor: textScaleFactor)); |
|||
} |
|||
|
|||
D.assert(builder.placeholderCount < dimensions.Count); |
|||
PlaceholderDimensions currentDimensions = dimensions[builder.placeholderCount]; |
|||
builder.addPlaceholder( |
|||
currentDimensions.size.width, |
|||
currentDimensions.size.height, |
|||
alignment, |
|||
scale: textScaleFactor, |
|||
baseline: currentDimensions.baseline, |
|||
baselineOffset: currentDimensions.baselineOffset |
|||
); |
|||
if (hasStyle) { |
|||
builder.pop(); |
|||
} |
|||
} |
|||
|
|||
|
|||
public override bool visitChildren(InlineSpanVisitor visitor) { |
|||
return visitor(this); |
|||
} |
|||
|
|||
|
|||
protected override InlineSpan getSpanForPositionVisitor(TextPosition position, Accumulator offset) { |
|||
if (position.offset == offset.value) { |
|||
return this; |
|||
} |
|||
|
|||
offset.increment(1); |
|||
return null; |
|||
} |
|||
|
|||
protected override int? codeUnitAtVisitor(int index, Accumulator offset) { |
|||
return null; |
|||
} |
|||
|
|||
public override RenderComparison compareTo(InlineSpan other) { |
|||
if (this == other) |
|||
return RenderComparison.identical; |
|||
if ((style == null) != (other.style == null)) |
|||
return RenderComparison.layout; |
|||
WidgetSpan typedOther = other as WidgetSpan; |
|||
if (child.Equals(typedOther.child) || alignment != typedOther.alignment) { |
|||
return RenderComparison.layout; |
|||
} |
|||
|
|||
RenderComparison result = RenderComparison.identical; |
|||
if (style != null) { |
|||
RenderComparison candidate = style.compareTo(other.style); |
|||
if ((int) candidate > (int) result) |
|||
result = candidate; |
|||
if (result == RenderComparison.layout) |
|||
return result; |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
int hashCode = base.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ (child.GetHashCode()); |
|||
hashCode = (hashCode * 397) ^ (alignment.GetHashCode()); |
|||
hashCode = (hashCode * 397) ^ (baseline.GetHashCode()); |
|||
return hashCode; |
|||
} |
|||
|
|||
public bool DebugAssertIsValid() { |
|||
return true; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5d48514e70d8418195ae5d7352f15a0e |
|||
timeCreated: 1606303521 |
|
|||
#include "skottie.h"
|
|||
|
|||
#include "lib/ui/ui_mono_state.h"
|
|||
|
|||
namespace uiwidgets { |
|||
fml::RefPtr<Skottie> Skottie::Create(char* path) { |
|||
sk_sp<skottie::Animation> animation_ = skottie::Animation::MakeFromFile(path); |
|||
return fml::MakeRefCounted<Skottie>(animation_); |
|||
} |
|||
|
|||
Skottie::Skottie(sk_sp<skottie::Animation> animation) { |
|||
animation_ = animation; |
|||
} |
|||
|
|||
void Skottie::paint(Canvas* canvas, float x, float y, float width, float height, |
|||
float frame) { |
|||
animation_->seekFrameTime(frame); |
|||
SkRect rect = SkRect::MakeXYWH(x, y, width, height); |
|||
animation_->render(canvas->canvas(), &rect); |
|||
} |
|||
|
|||
float Skottie::duration() { return animation_->duration(); } |
|||
UIWIDGETS_API(Skottie*) |
|||
Skottie_Construct(char* path) { |
|||
fml::RefPtr<Skottie> skottie = Skottie::Create(path); |
|||
skottie->AddRef(); |
|||
return skottie.get(); |
|||
} |
|||
|
|||
UIWIDGETS_API(void) |
|||
Skottie_Dispose(Skottie* ptr) { ptr->Release(); } |
|||
|
|||
UIWIDGETS_API(void) |
|||
Skottie_Paint(Skottie* ptr, Canvas* canvas, float x, float y, float width, |
|||
float height, float frame) { |
|||
ptr->paint(canvas, x, y, width, height, frame); |
|||
} |
|||
|
|||
UIWIDGETS_API(float) |
|||
Skottie_Duration(Skottie* ptr) { return ptr->duration(); } |
|||
} // namespace uiwidgets
|
|
|||
#pragma once |
|||
|
|||
#include "flutter/fml/memory/ref_counted.h" |
|||
#include "lib/ui/painting/canvas.h" |
|||
#include "modules/skottie/include/Skottie.h" |
|||
|
|||
namespace uiwidgets { |
|||
|
|||
class Skottie : public fml::RefCountedThreadSafe<Skottie> { |
|||
FML_FRIEND_MAKE_REF_COUNTED(Skottie); |
|||
|
|||
public: |
|||
static fml::RefPtr<Skottie> Create(char* path); |
|||
|
|||
void paint(Canvas* canvas, float x, float y, float width, float height, |
|||
float frame); |
|||
|
|||
float duration(); |
|||
|
|||
private: |
|||
explicit Skottie(sk_sp<skottie::Animation> animation); |
|||
|
|||
sk_sp<skottie::Animation> animation_; |
|||
bool is_null; |
|||
}; |
|||
} // namespace uiwidgets |
撰写
预览
正在加载...
取消
保存
Reference in new issue