浏览代码

add renderanimatedopacitymixin

/siyaoH-1.17-PlatformMessage
Shiyun Wen 4 年前
当前提交
44fd1949
共有 10 个文件被更改,包括 726 次插入181 次删除
  1. 13
      com.unity.uiwidgets/Runtime/rendering/box.mixin.gen.cs
  2. 31
      com.unity.uiwidgets/Runtime/rendering/box.mixin.njk
  3. 95
      com.unity.uiwidgets/Runtime/rendering/object.mixin.gen.cs
  4. 184
      com.unity.uiwidgets/Runtime/rendering/object.mixin.njk
  5. 42
      com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.njk
  6. 2
      com.unity.uiwidgets/Runtime/rendering/proxy_sliver.cs
  7. 11
      Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.cs.meta
  8. 117
      com.unity.uiwidgets/Runtime/rendering/RenderAnimatedOpacityMixin.mixin.gen.cs
  9. 99
      com.unity.uiwidgets/Runtime/rendering/RenderAnimatedOpacityMixin.mixin.njk
  10. 313
      com.unity.uiwidgets/Runtime/widgets/DirectionalFocusTraversalPolicy.mixin.gen.cs

13
com.unity.uiwidgets/Runtime/rendering/box.mixin.gen.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.rendering {

}
public bool defaultHitTestChildren(BoxHitTestResult result, Offset position) {
// the x, y parameters have the top left of the node's box as the origin4
// the x, y parameters have the top left of the node's box as the origin
ChildType child = lastChild;
while (child != null) {
ParentDataType childParentData = child.parentData as ParentDataType;

hitTest: (BoxHitTestResult boxHitTestResult, Offset transformed) => {
D.assert(transformed == position - childParentData.offset);
return child.hitTest(boxHitTestResult, position: transformed);
}
D.assert(transformed == position - childParentData.offset);
return child.hitTest(boxHitTestResult, position: transformed);
}
return true;
child = childParentData.previousSibling;
child = childParentData.previousSibling;
}
return false;
}

31
com.unity.uiwidgets/Runtime/rendering/box.mixin.njk


where ParentDataType : ContainerParentDataMixinBoxParentData<ChildType> {
public float? defaultComputeDistanceToFirstActualBaseline(TextBaseline baseline) {
var child = this.firstChild;
var child = firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
float? result = child.getDistanceToActualBaseline(baseline);

public float? defaultComputeDistanceToHighestActualBaseline(TextBaseline baseline) {
float? result = null;
var child = this.firstChild;
var child = firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
float? candidate = child.getDistanceToActualBaseline(baseline);

}
public void defaultPaint(PaintingContext context, Offset offset) {
var child = this.firstChild;
var child = firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
context.paintChild(child, childParentData.offset + offset);

public bool defaultHitTestChildren(HitTestResult result, Offset position) {
// the x, y parameters have the top left of the node's box as the origin
ChildType child = this.lastChild;
while (child != null)
{
ParentDataType childParentData = (ParentDataType) child.parentData;
if (child.hitTest(result, position: position - childParentData.offset)) {
return true;
}
child = childParentData.previousSibling;
public bool defaultHitTestChildren(BoxHitTestResult result, Offset position) {
// the x, y parameters have the top left of the node's box as the origin
ChildType child = lastChild;
while (child != null) {
ParentDataType childParentData = child.parentData as ParentDataType;
bool isHit = result.addWithPaintOffset(
offset: childParentData.offset,
position: position,
hitTest: (BoxHitTestResult boxHitTestResult, Offset transformed) => {
D.assert(transformed == position - childParentData.offset);
return child.hitTest(boxHitTestResult, position: transformed);
}
);
if (isHit)
child = childParentData.previousSibling;
}
return false;
}

95
com.unity.uiwidgets/Runtime/rendering/object.mixin.gen.cs


namespace Unity.UIWidgets.rendering {
public abstract class RenderObjectWithChildMixinRenderObject<ChildType> : RenderObject, RenderObjectWithChildMixin<ChildType>, RenderObjectWithChildMixin where ChildType : RenderObject {
public virtual bool debugValidateChild(RenderObject child) {
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(

public abstract class RenderObjectWithChildMixinRenderBox<ChildType> : RenderBox, RenderObjectWithChildMixin<ChildType>, RenderObjectWithChildMixin where ChildType : RenderObject {
public virtual bool debugValidateChild(RenderObject child) {
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(

D.assert(previousSibling == null);
D.assert(nextSibling == null);
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

D.assert(previousSibling == null);
D.assert(nextSibling == null);
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

D.assert(previousSibling == null);
D.assert(nextSibling == null);
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

public ChildType nextSibling { get; set; }
public void detach() {
public override void detach() {
base.detach();
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

}
public virtual void insert(ChildType child, ChildType after = null) {
D.assert(child != this, () => "A RenderObject cannot be inserted into itself.");
D.assert(after != this,
() => "A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, () => "A RenderObject cannot be inserted after itself.");
D.assert(child != this, ()=>"A RenderObject cannot be inserted into itself.");
D.assert(after != this,()=>
"A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, ()=>"A RenderObject cannot be inserted after itself.");
D.assert(child != _firstChild);
D.assert(child != _lastChild);

}
public virtual void insert(ChildType child, ChildType after = null) {
D.assert(child != this, () => "A RenderObject cannot be inserted into itself.");
D.assert(after != this,
() => "A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, () => "A RenderObject cannot be inserted after itself.");
D.assert(child != this, ()=>"A RenderObject cannot be inserted into itself.");
D.assert(after != this,()=>
"A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, ()=>"A RenderObject cannot be inserted after itself.");
D.assert(child != _firstChild);
D.assert(child != _lastChild);

get { return _childCount; }
}
public override bool debugValidateChild(RenderObject child) {
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(

}
public virtual void insert(ChildType child, ChildType after = null) {
D.assert(child != this, () => "A RenderObject cannot be inserted into itself.");
D.assert(child != this, ()=>"A RenderObject cannot be inserted into itself.");
() => "A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, () => "A RenderObject cannot be inserted after itself.");
()=> "A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after,()=> "A RenderObject cannot be inserted after itself.");
D.assert(child != _firstChild);
D.assert(child != _lastChild);

184
com.unity.uiwidgets/Runtime/rendering/object.mixin.njk


D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(
"A " + this.GetType() + " expected a child of type " + typeof(ChildType) + " but received a " +
"A " + GetType() + " expected a child of type " + typeof(ChildType) + " but received a " +
"child of type " + child.GetType() + ".\n" +
"RenderObjects expect specific types of children because they " +
"coordinate with their children during layout and paint. For " +

"The " + this.GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + this.debugCreator + "\n" +
"The " + GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +

internal ChildType _child;
public ChildType child {
get { return this._child; }
get { return _child; }
if (this._child != null) {
this.dropChild(this._child);
if (_child != null) {
dropChild(_child);
this._child = value;
if (this._child != null) {
this.adoptChild(this._child);
_child = value;
if (_child != null) {
adoptChild(_child);
get { return this.child; }
set { this.child = (ChildType) value; }
get { return child; }
set { child = (ChildType) value; }
if (this._child != null) {
this._child.attach(owner);
if (_child != null) {
_child.attach(owner);
if (this._child != null) {
this._child.detach();
if (_child != null) {
_child.detach();
if (this._child != null) {
this.redepthChild(this._child);
if (_child != null) {
redepthChild(_child);
if (this._child != null) {
visitor(this._child);
if (_child != null) {
visitor(_child);
return this.child != null
? new List<DiagnosticsNode>{this.child.toDiagnosticsNode(name: "child")}
return child != null
? new List<DiagnosticsNode>{child.toDiagnosticsNode(name: "child")}
: new List<DiagnosticsNode>();
}
}

public override void detach() {
base.detach();
D.assert(this.previousSibling == null);
D.assert(this.nextSibling == null);
D.assert(previousSibling == null);
D.assert(nextSibling == null);
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

int _childCount = 0;
public int childCount {
get { return this._childCount; }
get { return _childCount; }
}
public bool debugValidateChild(RenderObject child) {

"A " + this.GetType() + " expected a child of type " + typeof(ChildType) + " but received a " +
"A " + GetType() + " expected a child of type " + typeof(ChildType) + " but received a " +
"child of type " + child.GetType() + ".\n" +
"RenderObjects expect specific types of children because they " +
"coordinate with their children during layout and paint. For " +

"The " + this.GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + this.debugCreator + "\n" +
"The " + GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +

D.assert(childParentData.nextSibling == null);
D.assert(childParentData.previousSibling == null);
this._childCount++;
D.assert(this._childCount > 0);
_childCount++;
D.assert(_childCount > 0);
childParentData.nextSibling = this._firstChild;
if (this._firstChild != null) {
var firstChildParentData = (ParentDataType) this._firstChild.parentData;
childParentData.nextSibling = _firstChild;
if (_firstChild != null) {
var firstChildParentData = (ParentDataType) _firstChild.parentData;
this._firstChild = child;
this._lastChild = this._lastChild ?? child;
_firstChild = child;
_lastChild = _lastChild ?? child;
D.assert(this._firstChild != null);
D.assert(this._lastChild != null);
D.assert(this._debugUltimatePreviousSiblingOf(after, equals: this._firstChild));
D.assert(this._debugUltimateNextSiblingOf(after, equals: this._lastChild));
D.assert(_firstChild != null);
D.assert(_lastChild != null);
D.assert(_debugUltimatePreviousSiblingOf(after, equals: _firstChild));
D.assert(_debugUltimateNextSiblingOf(after, equals: _lastChild));
D.assert(after == this._lastChild);
D.assert(after == _lastChild);
this._lastChild = child;
_lastChild = child;
} else {
childParentData.nextSibling = afterParentData.nextSibling;
childParentData.previousSibling = after;

}
public virtual void insert(ChildType child, ChildType after = null) {
D.assert(child != this, "A RenderObject cannot be inserted into itself.");
D.assert(child != this, ()=>"A RenderObject cannot be inserted into itself.");
"A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, "A RenderObject cannot be inserted after itself.");
D.assert(child != this._firstChild);
D.assert(child != this._lastChild);
()=>"A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, ()=>"A RenderObject cannot be inserted after itself.");
D.assert(child != _firstChild);
D.assert(child != _lastChild);
this.adoptChild(child);
this._insertIntoChildList(child, after);
adoptChild(child);
_insertIntoChildList(child, after);
this.insert(child, this._lastChild);
insert(child, _lastChild);
children.ForEach(this.add);
children.ForEach(add);
D.assert(this._debugUltimatePreviousSiblingOf(child, equals: this._firstChild));
D.assert(this._debugUltimateNextSiblingOf(child, equals: this._lastChild));
D.assert(this._childCount >= 0);
D.assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild));
D.assert(_debugUltimateNextSiblingOf(child, equals: _lastChild));
D.assert(_childCount >= 0);
D.assert(this._firstChild == child);
this._firstChild = childParentData.nextSibling;
D.assert(_firstChild == child);
_firstChild = childParentData.nextSibling;
} else {
var childPreviousSiblingParentData = (ParentDataType) childParentData.previousSibling.parentData;
childPreviousSiblingParentData.nextSibling = childParentData.nextSibling;

D.assert(this._lastChild == child);
this._lastChild = childParentData.previousSibling;
D.assert(_lastChild == child);
_lastChild = childParentData.previousSibling;
} else {
var childNextSiblingParentData = (ParentDataType) childParentData.nextSibling.parentData;
childNextSiblingParentData.previousSibling = childParentData.previousSibling;

childParentData.nextSibling = null;
this._childCount--;
_childCount--;
this._removeFromChildList(child);
this.dropChild(child);
_removeFromChildList(child);
dropChild(child);
ChildType child = this._firstChild;
ChildType child = _firstChild;
this.dropChild(child);
dropChild(child);
this._firstChild = null;
this._lastChild = null;
this._childCount = 0;
_firstChild = null;
_lastChild = null;
_childCount = 0;
}
public void move(ChildType child, ChildType after = null) {

return;
}
this._removeFromChildList(child);
this._insertIntoChildList(child, after);
this.markNeedsLayout();
_removeFromChildList(child);
_insertIntoChildList(child, after);
markNeedsLayout();
ChildType child = this._firstChild;
ChildType child = _firstChild;
while (child != null) {
child.attach(owner);
var childParentData = (ParentDataType) child.parentData;

public override void detach() {
base.detach();
ChildType child = this._firstChild;
ChildType child = _firstChild;
while (child != null) {
child.detach();
var childParentData = (ParentDataType) child.parentData;

public override void redepthChildren() {
ChildType child = this._firstChild;
ChildType child = _firstChild;
this.redepthChild(child);
redepthChild(child);
var childParentData = (ParentDataType) child.parentData;
child = childParentData.nextSibling;
}

ChildType child = this._firstChild;
ChildType child = _firstChild;
while (child != null) {
visitor(child);
var childParentData = (ParentDataType) child.parentData;

public ChildType firstChild {
get { return this._firstChild; }
get { return _firstChild; }
get { return this._lastChild; }
get { return _lastChild; }
}
public ChildType childBefore(ChildType child) {

public override List<DiagnosticsNode> debugDescribeChildren() {
var children = new List<DiagnosticsNode>();
if (this.firstChild != null) {
ChildType child = this.firstChild;
if (firstChild != null) {
ChildType child = firstChild;
if (child == this.lastChild) {
if (child == lastChild) {
break;
}

}
void ContainerRenderObjectMixin.insert(RenderObject child, RenderObject after) {
this.insert((ChildType) child, (ChildType) after);
insert((ChildType) child, (ChildType) after);
this.remove((ChildType) child);
remove((ChildType) child);
this.move((ChildType) child, (ChildType) after);
move((ChildType) child, (ChildType) after);
get { return this.firstChild; }
get { return firstChild; }
get { return this.lastChild; }
get { return lastChild; }
return this.childBefore((ChildType) child);
return childBefore((ChildType) child);
return this.childAfter((ChildType) child);
return childAfter((ChildType) child);
}
}
{% endmacro %}

42
com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.njk


}
protected override float computeMinIntrinsicWidth(float height) {
if (this.child != null) {
return this.child.getMinIntrinsicWidth(height);
if (child != null) {
return child.getMinIntrinsicWidth(height);
}
return 0.0f;

if (this.child != null) {
return this.child.getMaxIntrinsicWidth(height);
if (child != null) {
return child.getMaxIntrinsicWidth(height);
}
return 0.0f;

if (this.child != null) {
return this.child.getMinIntrinsicHeight(width);
if (child != null) {
return child.getMinIntrinsicHeight(width);
protected override float computeMaxIntrinsicHeight(float width) {
if (this.child != null) {
return this.child.getMaxIntrinsicHeight(width);
protected override internal float computeMaxIntrinsicHeight(float width) {
if (child != null) {
return child.getMaxIntrinsicHeight(width);
}
return 0.0f;

if (this.child != null) {
return this.child.getDistanceToActualBaseline(baseline);
if (child != null) {
return child.getDistanceToActualBaseline(baseline);
}
return base.computeDistanceToActualBaseline(baseline);

if (this.child != null) {
this.child.layout(this.constraints, parentUsesSize: true);
this.size = this.child.size;
if (child != null) {
child.layout(constraints, parentUsesSize: true);
size = child.size;
this.performResize();
performResize();
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
if (this.child != null) {
return this.child.hitTest(result, position);
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
if (child != null) {
return child.hitTest(result, position);
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
if (this.child != null) {
context.paintChild(this.child, offset);
if (child != null) {
context.paintChild(child, offset);
}
}
}

2
com.unity.uiwidgets/Runtime/rendering/proxy_sliver.cs


set { child = (RenderSliver) value; }
}
}
public class RenderSliverAnimatedOpacity : RenderProxySliver , RenderAnimatedOpacityMixin<RenderSliver>{
public class RenderSliverAnimatedOpacity :RenderAnimatedOpacityMixinRenderSliver<RenderSliver>{
public RenderSliverAnimatedOpacity(
Animation<float> opacity ,
RenderSliver sliver = null,

11
Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.cs.meta


fileFormatVersion: 2
guid: 0817e3443c80cb943a03dcf7b120bd2e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

117
com.unity.uiwidgets/Runtime/rendering/RenderAnimatedOpacityMixin.mixin.gen.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.rendering {
public abstract class RenderAnimatedOpacityMixinRenderSliver<ChildType> : RenderProxySliver, RenderAnimatedOpacityMixin<ChildType> where ChildType : RenderObject {
public int _alpha { get; set; }
public new bool alwaysNeedsCompositing {
get { return child != null && _currentlyNeedsCompositing;}
}
public bool _currentlyNeedsCompositing { get; set; }
public Animation<float> opacity {
get { return _opacity; }
set {
D.assert(value != null);
if (_opacity == value)
return;
if (attached && _opacity != null)
_opacity.removeListener(_updateOpacity);
_opacity = value;
if (attached)
_opacity.addListener(_updateOpacity);
_updateOpacity();
}
}
public Animation<float> _opacity { get; set; }
public bool alwaysIncludeSemantics {
get { return _alwaysIncludeSemantics; }
set {
if (value == _alwaysIncludeSemantics)
return;
_alwaysIncludeSemantics = value;
//markNeedsSemanticsUpdate();
}
}
public bool _alwaysIncludeSemantics { get; set; }
public override void attach(object owner) {
owner = (PipelineOwner) owner;
base.attach(owner);
_opacity.addListener(_updateOpacity);
_updateOpacity();
}
public void attach(PipelineOwner owner) {
base.attach(owner);
_opacity.addListener(_updateOpacity);
_updateOpacity();
}
public override void detach() {
_opacity.removeListener(_updateOpacity);
base.detach();
}
public void _updateOpacity() {
int oldAlpha = _alpha;
_alpha = ui.Color.getAlphaFromOpacity((float)_opacity.value);
if (oldAlpha != _alpha) {
bool didNeedCompositing = _currentlyNeedsCompositing;
_currentlyNeedsCompositing = _alpha > 0 && _alpha < 255;
if (child != null && didNeedCompositing != _currentlyNeedsCompositing)
markNeedsCompositingBitsUpdate();
markNeedsPaint();
//if (oldAlpha == 0 || _alpha == 0)
// markNeedsSemanticsUpdate();
}
}
public override void paint(PaintingContext context, Offset offset) {
if (child != null) {
if (_alpha == 0) {
layer = null;
return;
}
if (_alpha == 255) {
layer = null;
context.paintChild(child, offset);
return;
}
D.assert(needsCompositing);
layer = context.pushOpacity(offset, _alpha, base.paint, oldLayer: layer as OpacityLayer);
}
}
public void visitChildrenForSemantics(RenderObjectVisitor visitor) {
if (child != null && (_alpha != 0 || alwaysIncludeSemantics))
visitor(child);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Animation<float>>("opacity", opacity));
properties.add(new FlagProperty("alwaysIncludeSemantics", value: alwaysIncludeSemantics, ifTrue: "alwaysIncludeSemantics"));
}
public ChildType child { get; set; }
}
}

99
com.unity.uiwidgets/Runtime/rendering/RenderAnimatedOpacityMixin.mixin.njk


namespace Unity.UIWidgets.rendering {
{% macro RenderAnimatedOpacityMixin(with) %}
public abstract class RenderAnimatedOpacityMixin{{with}}<ChildType> : {{with}}, RenderAnimatedOpacityMixin<ChildType> where ChildType : RenderSliver {
public int _alpha { get; set;}
public new bool alwaysNeedsCompositing {
get { child != null && _currentlyNeedsCompositing;}
}
public bool _currentlyNeedsCompositing { get;set; }
public Animation<float> opacity {
get { return _opacity; }
set {
D.assert(value != null);
if (_opacity == value)
return;
if (attached && _opacity != null)
_opacity.removeListener(_updateOpacity);
_opacity = value;
if (attached)
_opacity.addListener(_updateOpacity);
_updateOpacity();
}
}
public Animation<float> _opacity { get; set; }
public bool alwaysIncludeSemantics {
get { return _alwaysIncludeSemantics; }
set {
if (value == _alwaysIncludeSemantics)
return;
_alwaysIncludeSemantics = value;
//markNeedsSemanticsUpdate();
}
}
public bool _alwaysIncludeSemantics { get; set; }
public override void attach(PipelineOwner owner) {
base.attach(owner);
_opacity.addListener(_updateOpacity);
_updateOpacity();
}
public override void detach() {
_opacity.removeListener(_updateOpacity);
base.detach();
}
public void _updateOpacity() {
int oldAlpha = _alpha;
_alpha = ui.Color.getAlphaFromOpacity((float)_opacity.value);
if (oldAlpha != _alpha) {
bool didNeedCompositing = _currentlyNeedsCompositing;
_currentlyNeedsCompositing = _alpha > 0 && _alpha < 255;
if (child != null && didNeedCompositing != _currentlyNeedsCompositing)
markNeedsCompositingBitsUpdate();
markNeedsPaint();
//if (oldAlpha == 0 || _alpha == 0)
// markNeedsSemanticsUpdate();
}
}
public override void paint(PaintingContext context, Offset offset) {
if (child != null) {
if (_alpha == 0) {
layer = null;
return;
}
if (_alpha == 255) {
layer = null;
context.paintChild(child, offset);
return;
}
D.assert(needsCompositing);
layer = context.pushOpacity(offset, _alpha, base.paint, oldLayer: layer as OpacityLayer);
}
}
public void visitChildrenForSemantics(RenderObjectVisitor visitor) {
if (child != null && (_alpha != 0 || alwaysIncludeSemantics))
visitor(child);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Animation<float>>("opacity", opacity));
properties.add(new FlagProperty("alwaysIncludeSemantics", value: alwaysIncludeSemantics, ifTrue: "alwaysIncludeSemantics"));
}
}
{% endmacro %}
{{ RenderAnimatedOpacityMixin('RenderSliver') }}
}

313
com.unity.uiwidgets/Runtime/widgets/DirectionalFocusTraversalPolicy.mixin.gen.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.widgets {
public class DirectionalFocusTraversalPolicyMixinFocusTraversalPolicy : FocusTraversalPolicy, DirectionalFocusTraversalPolicyMixin {
protected DirectionalFocusTraversalPolicyMixinFocusTraversalPolicy() {
}
public readonly Dictionary<FocusScopeNode, _DirectionalPolicyData> _policyData = new Dictionary<FocusScopeNode, _DirectionalPolicyData>();
public override void invalidateScopeData(FocusScopeNode node) {
base.invalidateScopeData(node);
_policyData.Remove(node);
}
public override void changedScope(FocusNode node = null, FocusScopeNode oldScope = null) {
base.changedScope(node: node, oldScope: oldScope);
if (oldScope != null) {
var delEntries = _policyData[oldScope]?.history?.Where((_DirectionalPolicyDataEntry entry)=> {
return entry.node == node;
});
foreach (var delEntry in delEntries) {
_policyData[oldScope]?.history?.Remove(delEntry);
}
}
}
public override FocusNode findFirstFocusInDirection(FocusNode currentNode, TraversalDirection direction) {
D.assert(direction != null);
D.assert(currentNode != null);
switch (direction) {
case TraversalDirection.up:
return _sortAndFindInitial(currentNode, vertical: true, first: false);
case TraversalDirection.down:
return _sortAndFindInitial(currentNode, vertical: true, first: true);
case TraversalDirection.left:
return _sortAndFindInitial(currentNode, vertical: false, first: false);
case TraversalDirection.right:
return _sortAndFindInitial(currentNode, vertical: false, first: true);
}
return null;
}
public FocusNode _sortAndFindInitial(FocusNode currentNode, bool vertical = false, bool first = false) {
IEnumerable<FocusNode> nodes = currentNode.nearestScope.traversalDescendants;
List<FocusNode> sorted = nodes.ToList();
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b)=> {
if (vertical) {
if (first) {
return a.rect.top.CompareTo(b.rect.top);
} else {
return b.rect.bottom.CompareTo(a.rect.bottom);
}
} else {
if (first) {
return a.rect.left.CompareTo(b.rect.left);
} else {
return b.rect.right.CompareTo(a.rect.right);
}
}
});
if (sorted.isNotEmpty()) {
return sorted.First();
}
return null;
}
public IEnumerable<FocusNode> _sortAndFilterHorizontally(
TraversalDirection direction,
Rect target,
FocusNode nearestScope)
{
D.assert(direction == TraversalDirection.left || direction == TraversalDirection.right);
IEnumerable<FocusNode> nodes = nearestScope.traversalDescendants;
D.assert(!nodes.Contains(nearestScope));
List<FocusNode> sorted = nodes.ToList();
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b) => a.rect.center.dx.CompareTo(b.rect.center.dx));
IEnumerable<FocusNode> result = new List<FocusNode>();
switch (direction) {
case TraversalDirection.left:
result = sorted.Where((FocusNode node) => node.rect != target && node.rect.center.dx <= target.left);
break;
case TraversalDirection.right:
result = sorted.Where((FocusNode node) => node.rect != target && node.rect.center.dx >= target.right);
break;
case TraversalDirection.up:
case TraversalDirection.down:
break;
}
return result;
}
public IEnumerable<FocusNode> _sortAndFilterVertically(
TraversalDirection direction,
Rect target,
IEnumerable<FocusNode> nodes)
{
List<FocusNode> sorted = nodes.ToList();
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b) => a.rect.center.dy.CompareTo(b.rect.center.dy));
switch (direction) {
case TraversalDirection.up:
return sorted.Where((FocusNode node) => node.rect != target && node.rect.center.dy <= target.top);
case TraversalDirection.down:
return sorted.Where((FocusNode node) => node.rect != target && node.rect.center.dy >= target.bottom);
case TraversalDirection.left:
case TraversalDirection.right:
break;
}
D.assert(direction == TraversalDirection.up || direction == TraversalDirection.down);
return null;
}
public bool _popPolicyDataIfNeeded(TraversalDirection direction, FocusScopeNode nearestScope, FocusNode focusedChild) {
_DirectionalPolicyData policyData = _policyData[nearestScope];
if (policyData != null && policyData.history.isNotEmpty() && policyData.history.First().direction != direction) {
if (policyData.history.Last().node.parent == null) {
invalidateScopeData(nearestScope);
return false;
}
bool popOrInvalidate(TraversalDirection direction) {
FocusNode lastNode = policyData.history.removeLast().node;
if (Scrollable.of(lastNode.context) != Scrollable.of(FocusManagerUtils.primaryFocus.context)) {
invalidateScopeData(nearestScope);
return false;
}
ScrollPositionAlignmentPolicy alignmentPolicy = ScrollPositionAlignmentPolicy.explicitPolicy;
switch (direction) {
case TraversalDirection.up:
case TraversalDirection.left:
alignmentPolicy = ScrollPositionAlignmentPolicy.keepVisibleAtStart;
break;
case TraversalDirection.right:
case TraversalDirection.down:
alignmentPolicy = ScrollPositionAlignmentPolicy.keepVisibleAtEnd;
break;
}
FocusTravesalUtils._focusAndEnsureVisible(
lastNode,
alignmentPolicy: alignmentPolicy
);
return true;
}
switch (direction) {
case TraversalDirection.down:
case TraversalDirection.up:
switch (policyData.history.First().direction) {
case TraversalDirection.left:
case TraversalDirection.right:
invalidateScopeData(nearestScope);
break;
case TraversalDirection.up:
case TraversalDirection.down:
if (popOrInvalidate(direction)) {
return true;
}
break;
}
break;
case TraversalDirection.left:
case TraversalDirection.right:
switch (policyData.history.First().direction) {
case TraversalDirection.left:
case TraversalDirection.right:
if (popOrInvalidate(direction)) {
return true;
}
break;
case TraversalDirection.up:
case TraversalDirection.down:
invalidateScopeData(nearestScope);
break;
}
break;
}
}
if (policyData != null && policyData.history.isEmpty()) {
invalidateScopeData(nearestScope);
}
return false;
}
public void _pushPolicyData(TraversalDirection direction, FocusScopeNode nearestScope, FocusNode focusedChild) {
_DirectionalPolicyData policyData = _policyData[nearestScope];
if (policyData != null && !(policyData is _DirectionalPolicyData)) {
return;
}
_DirectionalPolicyDataEntry newEntry = new _DirectionalPolicyDataEntry(node: focusedChild, direction: direction);
if (policyData != null) {
policyData.history.Add(newEntry);
} else {
_policyData[nearestScope] = new _DirectionalPolicyData(history: new List<_DirectionalPolicyDataEntry>(){newEntry});
}
}
public override bool inDirection(FocusNode currentNode, TraversalDirection direction) {
FocusScopeNode nearestScope = currentNode.nearestScope;
FocusNode focusedChild = nearestScope.focusedChild;
if (focusedChild == null) {
FocusNode firstFocus = findFirstFocusInDirection(currentNode, direction) ?? currentNode;
switch (direction) {
case TraversalDirection.up:
case TraversalDirection.left:
FocusTravesalUtils._focusAndEnsureVisible(
firstFocus,
alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtStart
);
break;
case TraversalDirection.right:
case TraversalDirection.down:
FocusTravesalUtils._focusAndEnsureVisible(
firstFocus,
alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtEnd
);
break;
}
return true;
}
if (_popPolicyDataIfNeeded(direction, nearestScope, focusedChild)) {
return true;
}
FocusNode found = null;
ScrollableState focusedScrollable = Scrollable.of(focusedChild.context);
switch (direction) {
case TraversalDirection.down:
case TraversalDirection.up:
IEnumerable<FocusNode> eligibleNodes = _sortAndFilterVertically(
direction,
focusedChild.rect,
nearestScope.traversalDescendants
);
if (focusedScrollable != null && !focusedScrollable.position.atEdge()) {
IEnumerable<FocusNode> filteredEligibleNodes = eligibleNodes.Where((FocusNode node) => Scrollable.of(node.context) == focusedScrollable);
if (filteredEligibleNodes.Count() !=0) {
eligibleNodes = filteredEligibleNodes;
}
}
if (eligibleNodes.Count() == 0) {
break;
}
List<FocusNode> sorted = eligibleNodes.ToList();
if (direction == TraversalDirection.up) {
//sorted = sorted.reversed.toList();
sorted.Reverse();
sorted = sorted.ToList();
}
Rect band = Rect.fromLTRB(focusedChild.rect.left, float.NegativeInfinity, focusedChild.rect.right, float.PositiveInfinity);
IEnumerable<FocusNode> inBand = sorted.Where((FocusNode node) => !node.rect.intersect(band).isEmpty);
if (inBand.Count() !=0) {
found = inBand.First();
break;
}
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b)=> {
return (a.rect.center.dx - focusedChild.rect.center.dx).abs().CompareTo((b.rect.center.dx - focusedChild.rect.center.dx).abs());
});
found = sorted.First();
break;
case TraversalDirection.right:
case TraversalDirection.left:
eligibleNodes = _sortAndFilterHorizontally(direction, focusedChild.rect, nearestScope);
if (focusedScrollable != null && !focusedScrollable.position.atEdge()) {
IEnumerable<FocusNode> filteredEligibleNodes = eligibleNodes.Where((FocusNode node) => Scrollable.of(node.context) == focusedScrollable);
if (filteredEligibleNodes.Count()!=0) {
eligibleNodes = filteredEligibleNodes;
}
}
if (eligibleNodes.Count() == 0) {
break;
}
sorted = eligibleNodes.ToList();
if (direction == TraversalDirection.left) {
sorted.Reverse();
sorted = sorted.ToList();
//sorted = sorted.reversed.toList();
}
band = Rect.fromLTRB(float.NegativeInfinity, focusedChild.rect.top, float.PositiveInfinity, focusedChild.rect.bottom);
inBand = sorted.Where((FocusNode node) => !node.rect.intersect(band).isEmpty);
if (inBand.Count()!=0) {
found = inBand.First();
break;
}
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b) =>{
return (a.rect.center.dy - focusedChild.rect.center.dy).abs().CompareTo((b.rect.center.dy - focusedChild.rect.center.dy).abs());
});
found = sorted.First();
break;
}
if (found != null) {
_pushPolicyData(direction, nearestScope, focusedChild);
switch (direction) {
case TraversalDirection.up:
case TraversalDirection.left:
FocusTravesalUtils._focusAndEnsureVisible(
found,
alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtStart
);
break;
case TraversalDirection.down:
case TraversalDirection.right:
FocusTravesalUtils._focusAndEnsureVisible(
found,
alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtEnd
);
break;
}
return true;
}
return false;
}
public override IEnumerable<FocusNode> sortDescendants(IEnumerable<FocusNode> descendants) {
return null;
}
}
}
正在加载...
取消
保存