|
|
|
|
|
|
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); |
|
|
|