浏览代码

widgets/framework.

/main
kg 6 年前
当前提交
d94907d4
共有 19 个文件被更改,包括 1561 次插入339 次删除
  1. 10
      Assets/UIWidgets/foundation/diagnostics.cs
  2. 5
      Assets/UIWidgets/foundation/key.cs
  3. 10
      Assets/UIWidgets/physics/spring_simulation.cs
  4. 2
      Assets/UIWidgets/rendering/editable.cs
  5. 32
      Assets/UIWidgets/rendering/object.cs
  6. 398
      Assets/UIWidgets/rendering/object.mixin.gen.cs
  7. 182
      Assets/UIWidgets/rendering/object.mixin.njk
  8. 2
      Assets/UIWidgets/widgets/basic.cs
  9. 2
      Assets/UIWidgets/widgets/binding.cs
  10. 842
      Assets/UIWidgets/widgets/framework.cs
  11. 12
      Assets/UIWidgets/widgets/image.cs
  12. 2
      Assets/UIWidgets/widgets/notification_listener.cs
  13. 296
      Assets/UIWidgets/widgets/scroll_position.cs
  14. 8
      Assets/UIWidgets/animation.meta
  15. 8
      Assets/UIWidgets/physics.meta
  16. 78
      Assets/UIWidgets/widgets/debug.cs
  17. 3
      Assets/UIWidgets/widgets/debug.cs.meta
  18. 5
      Assets/UIWidgets/widgets/focus_manager.cs
  19. 3
      Assets/UIWidgets/widgets/focus_manager.cs.meta

10
Assets/UIWidgets/foundation/diagnostics.cs


}
public class MessageProperty : DiagnosticsProperty<object> {
MessageProperty(String name, String message,
public MessageProperty(String name, String message,
DiagnosticLevel level = DiagnosticLevel.info
) : base(name, null, description: message, level: level) {
D.assert(name != null);

public class StringProperty : DiagnosticsProperty<string> {
StringProperty(string name, string value,
string description,
string tooltip,
public StringProperty(string name, string value,
string description = null,
string tooltip = null,
bool showName = true,
object defaultValue = null,
bool quoted = true,

);
internal static readonly _NoDefaultValue kNoDefaultValue = new _NoDefaultValue();
internal static readonly _NoDefaultValue kNullDefaultValue = new _NoDefaultValue();
internal static readonly _NullDefaultValue kNullDefaultValue = new _NullDefaultValue();
public static string shortHash(object o) {
return (o.GetHashCode() & 0xFFFFF).ToString("X").PadLeft(5, '0');

5
Assets/UIWidgets/foundation/key.cs


public override string ToString() {
string valueString = typeof(T) == typeof(string) ? "<\'" + this.value + "\'>" : "<" + this.value + ">";
if (this.GetType() == typeof(ValueKey<T>)) {
return string.Format("[{0}]", valueString);
}
return string.Format("[{0} {1}]", this.GetType(), valueString);
}
}

10
Assets/UIWidgets/physics/spring_simulation.cs


) : base(spring, start, end, velocity, tolerance: tolerance) {
}
public double x(double time) {
public override double x(double time) {
public static _SpringSolution create(
internal static _SpringSolution create(
SpringDescription spring,
double initialPosition,
double initialVelocity

}
class _CriticalSolution : _SpringSolution {
internal static _CriticalSolution create(
internal new static _CriticalSolution create(
SpringDescription spring,
double distance,
double velocity

}
class _OverdampedSolution : _SpringSolution {
internal static _OverdampedSolution create(
internal new static _OverdampedSolution create(
SpringDescription spring,
double distance,
double velocity

}
class _UnderdampedSolution : _SpringSolution {
internal static _UnderdampedSolution create(
internal new static _UnderdampedSolution create(
SpringDescription spring,
double distance,
double velocity

2
Assets/UIWidgets/rendering/editable.cs


// describeSemanticsConfiguration todo
protected internal override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Color>("cursorColor", cursorColor));
properties.add(new DiagnosticsProperty<ValueNotifier<bool>>("showCursor", showCursor));

32
Assets/UIWidgets/rendering/object.cs


}
}
public interface RenderObjectWithChildMixin {
bool debugValidateChild(RenderObject child);
RenderObject child { get; set; }
}
}
public interface ContainerRenderObjectMixin {
int childCount { get; }
bool debugValidateChild(RenderObject child);
void insert(RenderObject child, RenderObject after = null);
void remove(RenderObject child);
void move(RenderObject child, RenderObject after = null);
RenderObject firstChild { get; }
RenderObject lastChild { get; }
RenderObject childBefore(RenderObject child);
RenderObject childAfter(RenderObject child);
}
public abstract class RenderObject : AbstractNodeMixinDiagnosticableTree, HitTestTarget {

}
}
public bool _needsLayout = true;
public bool debugNeedsLayout {
get {
bool result = false;
D.assert(() => {
result = this._needsLayout;
return true;
});
return result;
}
}
internal bool _needsLayout = true;
public RenderObject _relayoutBoundary;
bool _doingThisLayoutWithCallback = false;

398
Assets/UIWidgets/rendering/object.mixin.gen.cs


namespace UIWidgets.rendering {
public abstract class RenderObjectWithChildMixinRenderObject<ChildType> : RenderObject where ChildType : RenderObject {
public ChildType _child;
public abstract class RenderObjectWithChildMixinRenderObject<ChildType> : RenderObject, RenderObjectWithChildMixin where ChildType : RenderObject {
internal ChildType _child;
public ChildType child {
get { return this._child; }

}
}
RenderObject RenderObjectWithChildMixin.child {
get { return this.child; }
set { this.child = (ChildType) value; }
}
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(
"A " + this.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 " +
"example, a RenderSliver cannot be the child of a RenderBox because " +
"a RenderSliver does not understand the RenderBox layout protocol.\n" +
"\n" +
"The " + this.GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + this.debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +
" " + child.debugCreator + "\n"
);
}
return true;
});
return true;
}
public override void attach(object owner) {
base.attach(owner);
if (this._child != null) {

}
public abstract class RenderObjectWithChildMixinRenderBox<ChildType> : RenderBox where ChildType : RenderObject {
public ChildType _child;
public abstract class RenderObjectWithChildMixinRenderBox<ChildType> : RenderBox, RenderObjectWithChildMixin where ChildType : RenderObject {
internal ChildType _child;
public ChildType child {
get { return this._child; }

}
}
RenderObject RenderObjectWithChildMixin.child {
get { return this.child; }
set { this.child = (ChildType) value; }
}
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(
"A " + this.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 " +
"example, a RenderSliver cannot be the child of a RenderBox because " +
"a RenderSliver does not understand the RenderBox layout protocol.\n" +
"\n" +
"The " + this.GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + this.debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +
" " + child.debugCreator + "\n"
);
}
return true;
});
return true;
}
public override void attach(object owner) {
base.attach(owner);
if (this._child != null) {

}
public abstract class RenderObjectWithChildMixinRenderSliver<ChildType> : RenderSliver where ChildType : RenderObject {
public ChildType _child;
public abstract class RenderObjectWithChildMixinRenderSliver<ChildType> : RenderSliver, RenderObjectWithChildMixin where ChildType : RenderObject {
internal ChildType _child;
public ChildType child {
get { return this._child; }

}
}
RenderObject RenderObjectWithChildMixin.child {
get { return this.child; }
set { this.child = (ChildType) value; }
}
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(
"A " + this.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 " +
"example, a RenderSliver cannot be the child of a RenderBox because " +
"a RenderSliver does not understand the RenderBox layout protocol.\n" +
"\n" +
"The " + this.GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + this.debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +
" " + child.debugCreator + "\n"
);
}
return true;
});
return true;
}
public override void attach(object owner) {
base.attach(owner);
if (this._child != null) {

public abstract class ContainerRenderObjectMixinRenderBox<ChildType, ParentDataType> : RenderBox
public abstract class ContainerRenderObjectMixinRenderBox<ChildType, ParentDataType> : RenderBox, ContainerRenderObjectMixin
public int _childCount = 0;
bool _debugUltimatePreviousSiblingOf(ChildType child, ChildType equals = null) {
ParentDataType childParentData = (ParentDataType) child.parentData;
while (childParentData.previousSibling != null) {
D.assert(childParentData.previousSibling != child);
child = childParentData.previousSibling;
childParentData = (ParentDataType) child.parentData;
}
return child == equals;
}
bool _debugUltimateNextSiblingOf(ChildType child, ChildType equals = null) {
ParentDataType childParentData = (ParentDataType) child.parentData;
while (childParentData.nextSibling != null) {
D.assert(childParentData.nextSibling != child);
child = childParentData.nextSibling;
childParentData = (ParentDataType) child.parentData;
}
return child == equals;
}
int _childCount = 0;
public ChildType _firstChild;
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(
"A " + this.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 " +
"example, a RenderSliver cannot be the child of a RenderBox because " +
"a RenderSliver does not understand the RenderBox layout protocol.\n" +
"\n" +
"The " + this.GetType() + " that expected a $ChildType child was created by:\n" +
" " + this.debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +
" " + child.debugCreator + "\n"
);
}
return true;
});
return true;
}
ChildType _firstChild;
public ChildType _lastChild;
ChildType _lastChild;
public void _insertIntoChildList(ChildType child, ChildType after = null) {
void _insertIntoChildList(ChildType child, ChildType after = null) {
D.assert(childParentData.nextSibling == null);
D.assert(childParentData.previousSibling == null);
D.assert(this._childCount > 0);
if (after == null) {
childParentData.nextSibling = this._firstChild;
if (this._firstChild != null) {

this._firstChild = child;
if (this._lastChild == null) {
this._lastChild = child;
}
this._lastChild = this._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(after == this._lastChild);
childParentData.previousSibling = after;
afterParentData.nextSibling = child;
this._lastChild = child;

var childNextSiblingParentData = (ParentDataType) childParentData.nextSibling.parentData;
childPreviousSiblingParentData.nextSibling = child;
childNextSiblingParentData.previousSibling = child;
D.assert(afterParentData.nextSibling == child);
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._firstChild);
D.assert(child != this._lastChild);
this.adoptChild(child);
this._insertIntoChildList(child, after);
}

public void _removeFromChildList(ChildType child) {
var childParentData = (ParentDataType) child.parentData;
D.assert(this._debugUltimatePreviousSiblingOf(child, equals: this._firstChild));
D.assert(this._debugUltimateNextSiblingOf(child, equals: this._lastChild));
D.assert(this._childCount >= 0);
D.assert(this._firstChild == child);
this._firstChild = childParentData.nextSibling;
} else {
var childPreviousSiblingParentData = (ParentDataType) childParentData.previousSibling.parentData;

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

this.dropChild(child);
child = next;
}
this._firstChild = null;
this._lastChild = null;
this._childCount = 0;

D.assert(child != this);
D.assert(after != this);
D.assert(child != after);
D.assert(child.parent == this);
this._removeFromChildList(child);
this._insertIntoChildList(child, after);
this.markNeedsLayout();

}
public ChildType childBefore(ChildType child) {
D.assert(child != null);
D.assert(child.parent == this);
D.assert(child != null);
D.assert(child.parent == this);
public override List<DiagnosticsNode> debugDescribeChildren() {
var children = new List<DiagnosticsNode>();
if (this.firstChild != null) {
ChildType child = this.firstChild;
int count = 1;
while (true) {
children.Add(child.toDiagnosticsNode(name: "child " + count));
if (child == this.lastChild) {
break;
}
count += 1;
var childParentData = (ParentDataType) child.parentData;
child = childParentData.nextSibling;
}
}
return children;
}
void ContainerRenderObjectMixin.insert(RenderObject child, RenderObject after) {
this.insert((ChildType) child, (ChildType) after);
}
void ContainerRenderObjectMixin.remove(RenderObject child) {
this.remove((ChildType) child);
}
void ContainerRenderObjectMixin.move(RenderObject child, RenderObject after) {
this.move((ChildType) child, (ChildType) after);
}
RenderObject ContainerRenderObjectMixin.firstChild {
get { return this.firstChild; }
}
RenderObject ContainerRenderObjectMixin.lastChild {
get { return this.lastChild; }
}
RenderObject ContainerRenderObjectMixin.childBefore(RenderObject child) {
return this.childBefore((ChildType) child);
}
RenderObject ContainerRenderObjectMixin.childAfter(RenderObject child) {
return this.childAfter((ChildType) child);
}
public abstract class ContainerRenderObjectMixinRenderSliver<ChildType, ParentDataType> : RenderSliver
public abstract class ContainerRenderObjectMixinRenderSliver<ChildType, ParentDataType> : RenderSliver, ContainerRenderObjectMixin
public int _childCount = 0;
bool _debugUltimatePreviousSiblingOf(ChildType child, ChildType equals = null) {
ParentDataType childParentData = (ParentDataType) child.parentData;
while (childParentData.previousSibling != null) {
D.assert(childParentData.previousSibling != child);
child = childParentData.previousSibling;
childParentData = (ParentDataType) child.parentData;
}
return child == equals;
}
bool _debugUltimateNextSiblingOf(ChildType child, ChildType equals = null) {
ParentDataType childParentData = (ParentDataType) child.parentData;
while (childParentData.nextSibling != null) {
D.assert(childParentData.nextSibling != child);
child = childParentData.nextSibling;
childParentData = (ParentDataType) child.parentData;
}
return child == equals;
}
int _childCount = 0;
public ChildType _firstChild;
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(
"A " + this.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 " +
"example, a RenderSliver cannot be the child of a RenderBox because " +
"a RenderSliver does not understand the RenderBox layout protocol.\n" +
"\n" +
"The " + this.GetType() + " that expected a $ChildType child was created by:\n" +
" " + this.debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +
" " + child.debugCreator + "\n"
);
}
return true;
});
return true;
}
ChildType _firstChild;
public ChildType _lastChild;
ChildType _lastChild;
public void _insertIntoChildList(ChildType child, ChildType after = null) {
void _insertIntoChildList(ChildType child, ChildType after = null) {
D.assert(childParentData.nextSibling == null);
D.assert(childParentData.previousSibling == null);
D.assert(this._childCount > 0);
if (after == null) {
childParentData.nextSibling = this._firstChild;
if (this._firstChild != null) {

this._firstChild = child;
if (this._lastChild == null) {
this._lastChild = child;
}
this._lastChild = this._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(after == this._lastChild);
childParentData.previousSibling = after;
afterParentData.nextSibling = child;
this._lastChild = child;

var childNextSiblingParentData = (ParentDataType) childParentData.nextSibling.parentData;
childPreviousSiblingParentData.nextSibling = child;
childNextSiblingParentData.previousSibling = child;
D.assert(afterParentData.nextSibling == child);
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._firstChild);
D.assert(child != this._lastChild);
this.adoptChild(child);
this._insertIntoChildList(child, after);
}

public void _removeFromChildList(ChildType child) {
var childParentData = (ParentDataType) child.parentData;
D.assert(this._debugUltimatePreviousSiblingOf(child, equals: this._firstChild));
D.assert(this._debugUltimateNextSiblingOf(child, equals: this._lastChild));
D.assert(this._childCount >= 0);
D.assert(this._firstChild == child);
this._firstChild = childParentData.nextSibling;
} else {
var childPreviousSiblingParentData = (ParentDataType) childParentData.previousSibling.parentData;

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

this.dropChild(child);
child = next;
}
this._firstChild = null;
this._lastChild = null;
this._childCount = 0;

D.assert(child != this);
D.assert(after != this);
D.assert(child != after);
D.assert(child.parent == this);
this._removeFromChildList(child);
this._insertIntoChildList(child, after);
this.markNeedsLayout();

}
public ChildType childBefore(ChildType child) {
D.assert(child != null);
D.assert(child.parent == this);
D.assert(child != null);
D.assert(child.parent == this);
}
public override List<DiagnosticsNode> debugDescribeChildren() {
var children = new List<DiagnosticsNode>();
if (this.firstChild != null) {
ChildType child = this.firstChild;
int count = 1;
while (true) {
children.Add(child.toDiagnosticsNode(name: "child " + count));
if (child == this.lastChild) {
break;
}
count += 1;
var childParentData = (ParentDataType) child.parentData;
child = childParentData.nextSibling;
}
}
return children;
}
void ContainerRenderObjectMixin.insert(RenderObject child, RenderObject after) {
this.insert((ChildType) child, (ChildType) after);
}
void ContainerRenderObjectMixin.remove(RenderObject child) {
this.remove((ChildType) child);
}
void ContainerRenderObjectMixin.move(RenderObject child, RenderObject after) {
this.move((ChildType) child, (ChildType) after);
}
RenderObject ContainerRenderObjectMixin.firstChild {
get { return this.firstChild; }
}
RenderObject ContainerRenderObjectMixin.lastChild {
get { return this.lastChild; }
}
RenderObject ContainerRenderObjectMixin.childBefore(RenderObject child) {
return this.childBefore((ChildType) child);
}
RenderObject ContainerRenderObjectMixin.childAfter(RenderObject child) {
return this.childAfter((ChildType) child);
}
}

182
Assets/UIWidgets/rendering/object.mixin.njk


namespace UIWidgets.rendering {
{% macro RenderObjectWithChildMixin(with) %}
public abstract class RenderObjectWithChildMixin{{with}}<ChildType> : {{with}} where ChildType : RenderObject {
public ChildType _child;
public abstract class RenderObjectWithChildMixin{{with}}<ChildType> : {{with}}, RenderObjectWithChildMixin where ChildType : RenderObject {
internal ChildType _child;
public ChildType child {
get { return this._child; }

this.adoptChild(this._child);
}
}
}
RenderObject RenderObjectWithChildMixin.child {
get { return this.child; }
set { this.child = (ChildType) value; }
}
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(
"A " + this.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 " +
"example, a RenderSliver cannot be the child of a RenderBox because " +
"a RenderSliver does not understand the RenderBox layout protocol.\n" +
"\n" +
"The " + this.GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + this.debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +
" " + child.debugCreator + "\n"
);
}
return true;
});
return true;
}
public override void attach(object owner) {

{% macro ContainerRenderObjectMixin(with) %}
public abstract class ContainerRenderObjectMixin{{with}}<ChildType, ParentDataType> : {{with}}
public abstract class ContainerRenderObjectMixin{{with}}<ChildType, ParentDataType> : {{with}}, ContainerRenderObjectMixin
public int _childCount = 0;
bool _debugUltimatePreviousSiblingOf(ChildType child, ChildType equals = null) {
ParentDataType childParentData = (ParentDataType) child.parentData;
while (childParentData.previousSibling != null) {
D.assert(childParentData.previousSibling != child);
child = childParentData.previousSibling;
childParentData = (ParentDataType) child.parentData;
}
return child == equals;
}
bool _debugUltimateNextSiblingOf(ChildType child, ChildType equals = null) {
ParentDataType childParentData = (ParentDataType) child.parentData;
while (childParentData.nextSibling != null) {
D.assert(childParentData.nextSibling != child);
child = childParentData.nextSibling;
childParentData = (ParentDataType) child.parentData;
}
return child == equals;
}
int _childCount = 0;
public ChildType _firstChild;
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(
"A " + this.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 " +
"example, a RenderSliver cannot be the child of a RenderBox because " +
"a RenderSliver does not understand the RenderBox layout protocol.\n" +
"\n" +
"The " + this.GetType() + " that expected a $ChildType child was created by:\n" +
" " + this.debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +
" " + child.debugCreator + "\n"
);
}
public ChildType _lastChild;
return true;
});
return true;
}
ChildType _firstChild;
ChildType _lastChild;
public void _insertIntoChildList(ChildType child, ChildType after = null) {
void _insertIntoChildList(ChildType child, ChildType after = null) {
D.assert(childParentData.nextSibling == null);
D.assert(childParentData.previousSibling == null);
D.assert(this._childCount > 0);
if (after == null) {
childParentData.nextSibling = this._firstChild;
if (this._firstChild != null) {

this._firstChild = child;
if (this._lastChild == null) {
this._lastChild = child;
}
this._lastChild = this._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(after == this._lastChild);
childParentData.previousSibling = after;
afterParentData.nextSibling = child;
this._lastChild = child;

var childNextSiblingParentData = (ParentDataType) childParentData.nextSibling.parentData;
childPreviousSiblingParentData.nextSibling = child;
childNextSiblingParentData.previousSibling = child;
D.assert(afterParentData.nextSibling == child);
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._firstChild);
D.assert(child != this._lastChild);
this.adoptChild(child);
this._insertIntoChildList(child, after);
}

public void _removeFromChildList(ChildType child) {
var childParentData = (ParentDataType) child.parentData;
D.assert(this._debugUltimatePreviousSiblingOf(child, equals: this._firstChild));
D.assert(this._debugUltimateNextSiblingOf(child, equals: this._lastChild));
D.assert(this._childCount >= 0);
D.assert(this._firstChild == child);
this._firstChild = childParentData.nextSibling;
} else {
var childPreviousSiblingParentData = (ParentDataType) childParentData.previousSibling.parentData;

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

this.dropChild(child);
child = next;
}
this._firstChild = null;
this._lastChild = null;
this._childCount = 0;

D.assert(child != this);
D.assert(after != this);
D.assert(child != after);
D.assert(child.parent == this);
this._removeFromChildList(child);
this._insertIntoChildList(child, after);
this.markNeedsLayout();

}
public ChildType childBefore(ChildType child) {
D.assert(child != null);
D.assert(child.parent == this);
D.assert(child != null);
D.assert(child.parent == this);
}
public override List<DiagnosticsNode> debugDescribeChildren() {
var children = new List<DiagnosticsNode>();
if (this.firstChild != null) {
ChildType child = this.firstChild;
int count = 1;
while (true) {
children.Add(child.toDiagnosticsNode(name: "child " + count));
if (child == this.lastChild) {
break;
}
count += 1;
var childParentData = (ParentDataType) child.parentData;
child = childParentData.nextSibling;
}
}
return children;
}
void ContainerRenderObjectMixin.insert(RenderObject child, RenderObject after) {
this.insert((ChildType) child, (ChildType) after);
}
void ContainerRenderObjectMixin.remove(RenderObject child) {
this.remove((ChildType) child);
}
void ContainerRenderObjectMixin.move(RenderObject child, RenderObject after) {
this.move((ChildType) child, (ChildType) after);
}
RenderObject ContainerRenderObjectMixin.firstChild {
get { return this.firstChild; }
}
RenderObject ContainerRenderObjectMixin.lastChild {
get { return this.lastChild; }
}
RenderObject ContainerRenderObjectMixin.childBefore(RenderObject child) {
return this.childBefore((ChildType) child);
}
RenderObject ContainerRenderObjectMixin.childAfter(RenderObject child) {
return this.childAfter((ChildType) child);
}
}
{% endmacro %}

2
Assets/UIWidgets/widgets/basic.cs


namespace UIWidgets.widgets {
public class RawImage : LeafRenderObjectWidget {
public RawImage(string key, ui.Image image, double width, double height, double scale, Color color,
public RawImage(Key key, ui.Image image, double width, double height, double scale, Color color,
BlendMode colorBlendMode, BoxFit fit, Rect centerSlice, Alignment alignment = null,
ImageRepeat repeat = ImageRepeat.noRepeat) : base(key) {
this.image = image;

2
Assets/UIWidgets/widgets/binding.cs


// }
}
public void drawFrame() {
protected override void drawFrame() {
if (renderViewElement != null) {
buildOwner.buildScope(renderViewElement);
}

842
Assets/UIWidgets/widgets/framework.cs
文件差异内容过多而无法显示
查看文件

12
Assets/UIWidgets/widgets/image.cs


public bool gaplessPlayback;
public Image(
string key,
Key key,
ImageProvider<System.Object> image,
double width,
double height,

// Network Image
public Image(
string src,
string key,
Key key,
double width,
double height,
Color color,

_resolveImage();
}
public override void reassemble() {
_resolveImage(); // in case the image cache was flushed
}
// public override void reassemble() {
// _resolveImage(); // in case the image cache was flushed
// }
void _resolveImage() {
var imageWidget = (Image<T>) widget;

public override Widget build(BuildContext context) {
var imageWidget = (Image<T>) widget;
RawImage image = new RawImage(
"", // todo
null, // todo
_imageInfo == null ? null : _imageInfo.image,
imageWidget.width,
imageWidget.height,

2
Assets/UIWidgets/widgets/notification_listener.cs


public class NotificationListener<T> : StatelessWidget, _NotificationListener where T : Notification {
public NotificationListener(
string key = null,
Key key = null,
Widget child = null,
NotificationListenerCallback<T> onNotification = null) : base(key) {
this.child = child;

296
Assets/UIWidgets/widgets/scroll_position.cs


using UIWidgets.ui;
namespace UIWidgets.widgets {
public abstract class ScrollPosition : ViewportOffset, ScrollMetrics {
ScrollPosition(
ScrollPhysics physics = null,
ScrollContext context = null,
bool keepScrollOffset = true,
ScrollPosition oldPosition = null,
string debugLabel = null
) {
D.assert(physics != null);
D.assert(context != null);
D.assert(context.vsync != null);
this.physics = physics;
this.context = context;
this.keepScrollOffset = keepScrollOffset;
this.debugLabel = debugLabel;
if (oldPosition != null) {
this.absorb(oldPosition);
}
if (keepScrollOffset) {
this.restoreScrollOffset();
}
}
public readonly ScrollPhysics physics;
public readonly ScrollContext context;
public readonly bool keepScrollOffset;
public readonly string debugLabel;
public double minScrollExtent {
get { return this._minScrollExtent; }
}
double _minScrollExtent;
public double maxScrollExtent {
get { return this._maxScrollExtent; }
}
double _maxScrollExtent;
public override double? pixels {
get { return this._pixels; }
}
double? _pixels;
public double viewportDimension {
get { return this._viewportDimension; }
}
double _viewportDimension;
public bool haveDimensions {
get { return this._haveDimensions; }
}
bool _haveDimensions = false;
protected virtual void absorb(ScrollPosition other) {
D.assert(other != null);
D.assert(other.context == context);
D.assert(_pixels == null);
_minScrollExtent = other.minScrollExtent;
_maxScrollExtent = other.maxScrollExtent;
_pixels = other._pixels;
_viewportDimension = other.viewportDimension;
D.assert(activity == null);
D.assert(other.activity != null);
_activity = other.activity;
other._activity = null;
if (other.runtimeType != runtimeType)
activity.resetActivity();
context.setIgnorePointer(activity.shouldIgnorePointer);
isScrollingNotifier.value = activity.isScrolling;
}
public double setPixels(double newPixels) {
D.assert(this._pixels != null);
D.assert(this.context.vsync.schedulerBinding.schedulerPhase <= SchedulerPhase.transientCallbacks);
if (newPixels != this.pixels) {
double overscroll = this.applyBoundaryConditions(newPixels);
D.assert(() => {
double delta = newPixels - this.pixels;
if (overscroll.abs() > delta.abs()) {
throw new UIWidgetsError(
string.Format(
"{0}.applyBoundaryConditions returned invalid overscroll value.\n" +
"setPixels() was called to change the scroll offset from {1} to {2}.\n" +
"That is a delta of {3} units.\n" +
"{0}.applyBoundaryConditions reported an overscroll of {4} units."
, this.GetType(), this.pixels, newPixels, delta, overscroll));
}
return true;
});
double oldPixels = this.pixels;
this._pixels = newPixels - overscroll;
if (this._pixels != oldPixels) {
this.notifyListeners();
this.didUpdateScrollPositionBy(this._pixels - oldPixels);
}
if (overscroll != 0.0) {
this.didOverscrollBy(overscroll);
return overscroll;
}
}
return 0.0;
}
public void correctPixels(double value) {
this._pixels = value;
}
public override void correctBy(double correction) {
D.assert(
this._pixels != null,
"An initial pixels value must exist by caling correctPixels on the ScrollPosition"
);
this._pixels += correction;
this._didChangeViewportDimensionOrReceiveCorrection = true;
}
protected void forcePixels(double value) {
D.assert(this.pixels != null);
_pixels = value;
notifyListeners();
}
protected void saveScrollOffset() {
PageStorage.of(context.storageContext)?.writeState(context.storageContext, pixels);
}
protected void restoreScrollOffset() {
if (pixels == null) {
final double value = PageStorage.of(context.storageContext)?.readState(context.storageContext);
if (value != null)
correctPixels(value);
}
}
}
// public abstract class ScrollPosition : ViewportOffset, ScrollMetrics {
// ScrollPosition(
// ScrollPhysics physics = null,
// ScrollContext context = null,
// bool keepScrollOffset = true,
// ScrollPosition oldPosition = null,
// string debugLabel = null
// ) {
// D.assert(physics != null);
// D.assert(context != null);
// D.assert(context.vsync != null);
//
// this.physics = physics;
// this.context = context;
// this.keepScrollOffset = keepScrollOffset;
// this.debugLabel = debugLabel;
//
// if (oldPosition != null) {
// this.absorb(oldPosition);
// }
//
// if (keepScrollOffset) {
// this.restoreScrollOffset();
// }
// }
//
// public readonly ScrollPhysics physics;
// public readonly ScrollContext context;
// public readonly bool keepScrollOffset;
// public readonly string debugLabel;
//
// public double minScrollExtent {
// get { return this._minScrollExtent; }
// }
//
// double _minScrollExtent;
//
// public double maxScrollExtent {
// get { return this._maxScrollExtent; }
// }
//
// double _maxScrollExtent;
//
// public override double? pixels {
// get { return this._pixels; }
// }
//
// double? _pixels;
//
// public double viewportDimension {
// get { return this._viewportDimension; }
// }
//
// double _viewportDimension;
//
// public bool haveDimensions {
// get { return this._haveDimensions; }
// }
//
// bool _haveDimensions = false;
//
// protected virtual void absorb(ScrollPosition other) {
// D.assert(other != null);
// D.assert(other.context == context);
// D.assert(_pixels == null);
// _minScrollExtent = other.minScrollExtent;
// _maxScrollExtent = other.maxScrollExtent;
// _pixels = other._pixels;
// _viewportDimension = other.viewportDimension;
//
// D.assert(activity == null);
// D.assert(other.activity != null);
// _activity = other.activity;
// other._activity = null;
// if (other.runtimeType != runtimeType)
// activity.resetActivity();
// context.setIgnorePointer(activity.shouldIgnorePointer);
// isScrollingNotifier.value = activity.isScrolling;
// }
//
// public double setPixels(double newPixels) {
// D.assert(this._pixels != null);
// D.assert(this.context.vsync.schedulerBinding.schedulerPhase <= SchedulerPhase.transientCallbacks);
// if (newPixels != this.pixels) {
// double overscroll = this.applyBoundaryConditions(newPixels);
// D.assert(() => {
// double delta = newPixels - this.pixels;
// if (overscroll.abs() > delta.abs()) {
// throw new UIWidgetsError(
// string.Format(
// "{0}.applyBoundaryConditions returned invalid overscroll value.\n" +
// "setPixels() was called to change the scroll offset from {1} to {2}.\n" +
// "That is a delta of {3} units.\n" +
// "{0}.applyBoundaryConditions reported an overscroll of {4} units."
// , this.GetType(), this.pixels, newPixels, delta, overscroll));
// }
//
// return true;
// });
//
// double oldPixels = this.pixels;
// this._pixels = newPixels - overscroll;
// if (this._pixels != oldPixels) {
// this.notifyListeners();
// this.didUpdateScrollPositionBy(this._pixels - oldPixels);
// }
//
// if (overscroll != 0.0) {
// this.didOverscrollBy(overscroll);
// return overscroll;
// }
// }
//
// return 0.0;
// }
//
// public void correctPixels(double value) {
// this._pixels = value;
// }
//
// public override void correctBy(double correction) {
// D.assert(
// this._pixels != null,
// "An initial pixels value must exist by caling correctPixels on the ScrollPosition"
// );
//
// this._pixels += correction;
// this._didChangeViewportDimensionOrReceiveCorrection = true;
// }
//
// protected void forcePixels(double value) {
// D.assert(this.pixels != null);
// _pixels = value;
// notifyListeners();
// }
//
// protected void saveScrollOffset() {
// PageStorage.of(context.storageContext)?.writeState(context.storageContext, pixels);
// }
//
// protected void restoreScrollOffset() {
// if (pixels == null) {
// final double value = PageStorage.of(context.storageContext)?.readState(context.storageContext);
// if (value != null)
// correctPixels(value);
// }
// }
// }
}

8
Assets/UIWidgets/animation.meta


fileFormatVersion: 2
guid: 1c53122c52c3f4fd897b13cc476e8baf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/UIWidgets/physics.meta


fileFormatVersion: 2
guid: 9fced70753a79436d832caab7657fef3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

78
Assets/UIWidgets/widgets/debug.cs


using System;
using System.Collections.Generic;
using UIWidgets.foundation;
namespace UIWidgets.widgets {
public static class WidgetsD {
public static bool debugPrintRebuildDirtyWidgets = false;
public static bool debugPrintBuildScope = false;
public static bool debugPrintGlobalKeyedWidgetLifecycle = false;
public static bool debugPrintScheduleBuildForStacks = false;
static Key _firstNonUniqueKey(IEnumerable<Widget> widgets) {
var keySet = new HashSet<Key>();
foreach (Widget widget in widgets) {
D.assert(widget != null);
if (widget.key == null) {
continue;
}
if (!keySet.Add(widget.key)) {
return widget.key;
}
}
return null;
}
public static bool debugChildrenHaveDuplicateKeys(Widget parent, IEnumerable<Widget> children) {
D.assert(() => {
Key nonUniqueKey = _firstNonUniqueKey(children);
if (nonUniqueKey != null) {
throw new UIWidgetsError(
"Duplicate keys found.\n" +
"If multiple keyed nodes exist as children of another node, they must have unique keys.\n" +
parent + " has multiple children with key " + children + "."
);
}
return true;
});
return false;
}
public static void debugWidgetBuilderValue(Widget widget, Widget built) {
D.assert(() => {
if (built == null) {
throw new UIWidgetsError(
"A build function returned null.\n" +
"The offending widget is: " + widget + "\n" +
"Build functions must never return null. " +
"To return an empty space that causes the building widget to fill available room, return \"new Container()\". " +
"To return an empty space that takes as little room as possible, return \"new Container(width: 0.0, height: 0.0)\".");
}
return true;
});
}
internal static UIWidgetsErrorDetails _debugReportException(
string context,
Exception exception,
InformationCollector informationCollector = null
) {
var details = new UIWidgetsErrorDetails(
exception: exception,
library: "widgets library",
context: context,
informationCollector: informationCollector
);
UIWidgetsError.reportError(details);
return details;
}
}
}

3
Assets/UIWidgets/widgets/debug.cs.meta


fileFormatVersion: 2
guid: 3211d930ee9840718a013e09295ce087
timeCreated: 1536894099

5
Assets/UIWidgets/widgets/focus_manager.cs


namespace UIWidgets.widgets {
public class FocusManager {
}
}

3
Assets/UIWidgets/widgets/focus_manager.cs.meta


fileFormatVersion: 2
guid: 78895a8736b34e4085f9324116273d59
timeCreated: 1536819300
正在加载...
取消
保存