浏览代码

fix mixin issue with RenderConstrinedLayoutBuilder

/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
d63fa038
共有 3 个文件被更改,包括 21 次插入35 次删除
  1. 6
      com.unity.uiwidgets/Runtime/rendering/object.mixin.gen.cs
  2. 2
      com.unity.uiwidgets/Runtime/rendering/object.mixin.njk
  3. 48
      com.unity.uiwidgets/Runtime/widgets/layout_builder.cs

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


public abstract class RenderConstrainedLayoutBuilderMixinRenderObject<ConstraintType, ChildType> : RenderObjectWithChildMixinRenderObject<ChildType>,
RenderConstrainedLayoutBuilder<ConstraintType, ChildType>
RenderConstrainedLayoutBuilder<ConstraintType>
where ConstraintType : Constraints
where ChildType : RenderObject {

}
public class RenderConstrainedLayoutBuilderMixinRenderBox<ConstraintType, ChildType> : RenderObjectWithChildMixinRenderBox<ChildType>,
RenderConstrainedLayoutBuilder<ConstraintType, ChildType>
RenderConstrainedLayoutBuilder<ConstraintType>
where ConstraintType : BoxConstraints
where ChildType : RenderBox {

}
public abstract class RenderConstrainedLayoutBuilderMixinRenderSliver<ConstraintType, ChildType> : RenderObjectWithChildMixinRenderSliver<ChildType>,
RenderConstrainedLayoutBuilder<ConstraintType, ChildType>
RenderConstrainedLayoutBuilder<ConstraintType>
where ConstraintType : SliverConstraints
where ChildType : RenderSliver {

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


{% macro RenderConstrainedLayoutBuilderMixin(abstract, with, constraint) %}
public {{abstract}} class RenderConstrainedLayoutBuilderMixin{{with}}<ConstraintType, ChildType> : RenderObjectWithChildMixin{{with}}<ChildType>,
RenderConstrainedLayoutBuilder<ConstraintType, ChildType>
RenderConstrainedLayoutBuilder<ConstraintType>
where ConstraintType : {{constraint}}
where ChildType : {{with}} {

48
com.unity.uiwidgets/Runtime/widgets/layout_builder.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.widgets {
public delegate Widget LayoutWidgetBuilder(BuildContext context, BoxConstraints constraints);

return (ConstrainedLayoutBuilder<ConstraintType>)base.widget ;
}
}
public new RenderConstrainedLayoutBuilderMixinRenderObject<ConstraintType, RenderObject> renderObject {
public RenderConstrainedLayoutBuilder<ConstraintType> renderObject_builder {
return base.renderObject as RenderConstrainedLayoutBuilderMixinRenderObject<ConstraintType, RenderObject> ;
return base.renderObject as RenderConstrainedLayoutBuilder<ConstraintType> ;
public RenderObjectWithChildMixin renderObject_childMxin {
get { return base.renderObject as RenderObjectWithChildMixin; }
}
Element _child;
public override void visitChildren(ElementVisitor visitor) {

}
public override void mount(Element parent, object newSlot) {
base.mount(parent, newSlot); // Creates the renderObject.
((RenderConstrainedLayoutBuilderMixinRenderObject<ConstraintType, RenderObject>)renderObject).updateCallback(_layout);
renderObject_builder.updateCallback(_layout);
}
public override void update(Widget newWidget) {

D.assert(widget == newWidget);
renderObject.updateCallback(_layout);
renderObject_builder.updateCallback(_layout);
renderObject.markNeedsLayout();
}

}
public override void unmount() {
renderObject.updateCallback(null);
renderObject_builder.updateCallback(null);
base.unmount();
}

}
protected override void insertChildRenderObject(RenderObject child, object slot) {
RenderObjectWithChildMixin<RenderObject> renderObject = this.renderObject;
RenderObjectWithChildMixin renderObject = renderObject_childMxin;
D.assert(slot == null);
D.assert(renderObject.debugValidateChild(child));
renderObject.child = child;

}
protected override void removeChildRenderObject(RenderObject child) {
RenderConstrainedLayoutBuilderMixinRenderObject<ConstraintType, RenderObject> renderObject = this.renderObject;
RenderObjectWithChildMixin renderObject = renderObject_childMxin;
D.assert(renderObject.child == child);
renderObject.child = null;
D.assert(renderObject == this.renderObject);

public interface RenderConstrainedLayoutBuilder<ConstraintType,ChildType>
where ConstraintType : Constraints
where ChildType : RenderObject
public interface RenderConstrainedLayoutBuilder<ConstraintType>
where ConstraintType : Constraints
{
LayoutCallback<ConstraintType> _callback { get; set; }

}
public class _RenderLayoutBuilder : RenderConstrainedLayoutBuilderMixinRenderBox<BoxConstraints, RenderBox> {
public _RenderLayoutBuilder(
LayoutCallback<BoxConstraints> callback = null) {
_callback = callback;
}
public LayoutCallback<BoxConstraints> callback {
get { return _callback; }
set {
if (value == _callback) {
return;
}
_callback = value;
markNeedsLayout();
}
}
LayoutCallback<BoxConstraints> _callback;
bool _debugThrowIfNotCheckingIntrinsics() {
D.assert(() => {
if (!debugCheckingIntrinsics) {

}
protected override void performLayout() {
D.assert(callback != null);
invokeLayoutCallback(callback);
D.assert(_callback != null);
invokeLayoutCallback(_callback);
if (child != null) {
child.layout(constraints, parentUsesSize: true);
size = constraints.constrain(child.size);

正在加载...
取消
保存