|
|
|
|
|
|
using Unity.UIWidgets.rendering; |
|
|
|
using Unity.UIWidgets.scheduler; |
|
|
|
|
|
|
|
namespace Unity.UIWidgets.widgets |
|
|
|
{ |
|
|
|
public class OverlayEntry |
|
|
|
{ |
|
|
|
public OverlayEntry(WidgetBuilder builder = null, bool opaque = false, bool maintainState = false) |
|
|
|
{ |
|
|
|
namespace Unity.UIWidgets.widgets { |
|
|
|
public class OverlayEntry { |
|
|
|
public OverlayEntry(WidgetBuilder builder = null, bool opaque = false, bool maintainState = false) { |
|
|
|
D.assert(builder != null); |
|
|
|
this._opaque = opaque; |
|
|
|
this._maintainState = maintainState; |
|
|
|
|
|
|
|
|
|
|
bool _opaque; |
|
|
|
|
|
|
|
public bool opaque |
|
|
|
{ |
|
|
|
get { return this._opaque; } |
|
|
|
set |
|
|
|
{ |
|
|
|
if (this._opaque == value) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
public bool opaque { |
|
|
|
get => this._opaque; |
|
|
|
set { |
|
|
|
if (this._opaque == value) return; |
|
|
|
|
|
|
|
this._opaque = value; |
|
|
|
D.assert(this._overlay != null); |
|
|
|
|
|
|
|
|
|
|
bool _maintainState; |
|
|
|
|
|
|
|
public bool maintainState |
|
|
|
{ |
|
|
|
get { return this._maintainState; } |
|
|
|
set |
|
|
|
{ |
|
|
|
if (this._maintainState == value) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
public bool maintainState { |
|
|
|
get => this._maintainState; |
|
|
|
set { |
|
|
|
if (this._maintainState == value) return; |
|
|
|
|
|
|
|
this._maintainState = value; |
|
|
|
D.assert(this._overlay != null); |
|
|
|
|
|
|
|
|
|
|
internal readonly GlobalKey<_OverlayEntryState> _key = new LabeledGlobalKey<_OverlayEntryState>(); |
|
|
|
|
|
|
|
public void remove() |
|
|
|
{ |
|
|
|
public void remove() { |
|
|
|
{ |
|
|
|
} |
|
|
|
{ |
|
|
|
} |
|
|
|
public void markNeedsBuild() |
|
|
|
{ |
|
|
|
public void markNeedsBuild() { |
|
|
|
public override string ToString() |
|
|
|
{ |
|
|
|
public override string ToString() { |
|
|
|
class _OverlayEntry : StatefulWidget |
|
|
|
{ |
|
|
|
internal _OverlayEntry(OverlayEntry entry) : base(key: entry._key) |
|
|
|
{ |
|
|
|
internal class _OverlayEntry : StatefulWidget { |
|
|
|
internal _OverlayEntry(OverlayEntry entry) : base(key: entry._key) { |
|
|
|
D.assert(entry != null); |
|
|
|
this.entry = entry; |
|
|
|
} |
|
|
|
|
|
|
public override State createState() |
|
|
|
{ |
|
|
|
public override State createState() { |
|
|
|
class _OverlayEntryState : State<_OverlayEntry> |
|
|
|
{ |
|
|
|
public override Widget build(BuildContext context) |
|
|
|
{ |
|
|
|
internal class _OverlayEntryState : State<_OverlayEntry> { |
|
|
|
public override Widget build(BuildContext context) { |
|
|
|
internal void _markNeedsBuild() |
|
|
|
{ |
|
|
|
this.setState(() => |
|
|
|
{ |
|
|
|
internal void _markNeedsBuild() { |
|
|
|
this.setState(() => { |
|
|
|
public class Overlay : StatefulWidget |
|
|
|
{ |
|
|
|
public Overlay(Key key = null, List<OverlayEntry> initialEntries = null) : base(key) |
|
|
|
{ |
|
|
|
public class Overlay : StatefulWidget { |
|
|
|
public Overlay(Key key = null, List<OverlayEntry> initialEntries = null) : base(key) { |
|
|
|
D.assert(initialEntries != null); |
|
|
|
this.initialEntries = initialEntries; |
|
|
|
} |
|
|
|
|
|
|
public static OverlayState of(BuildContext context, Widget debugRequiredFor = null) |
|
|
|
{ |
|
|
|
public static OverlayState of(BuildContext context, Widget debugRequiredFor = null) { |
|
|
|
D.assert(() => |
|
|
|
{ |
|
|
|
if (debugRequiredFor != null && result == null) |
|
|
|
{ |
|
|
|
D.assert(() => { |
|
|
|
if (debugRequiredFor != null && result == null) { |
|
|
|
var additional = context.widget != debugRequiredFor |
|
|
|
? $"\nThe context from which that widget was searching for an overlay was:\n {context}" |
|
|
|
: ""; |
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public override State createState() |
|
|
|
{ |
|
|
|
public override State createState() { |
|
|
|
public class OverlayState : TickerProviderStateMixin<Overlay> |
|
|
|
{ |
|
|
|
public class OverlayState : TickerProviderStateMixin<Overlay> { |
|
|
|
public override void initState() |
|
|
|
{ |
|
|
|
public override void initState() { |
|
|
|
public void insert(OverlayEntry entry, OverlayEntry above = null) |
|
|
|
{ |
|
|
|
public void insert(OverlayEntry entry, OverlayEntry above = null) { |
|
|
|
this.setState(() => |
|
|
|
{ |
|
|
|
this.setState(() => { |
|
|
|
public void insertAll(ICollection<OverlayEntry> entries, OverlayEntry above = null) |
|
|
|
{ |
|
|
|
public void insertAll(ICollection<OverlayEntry> entries, OverlayEntry above = null) { |
|
|
|
foreach (OverlayEntry entry in entries) |
|
|
|
{ |
|
|
|
foreach (OverlayEntry entry in entries) { |
|
|
|
this.setState(() => |
|
|
|
{ |
|
|
|
this.setState(() => { |
|
|
|
internal void _remove(OverlayEntry entry) |
|
|
|
{ |
|
|
|
if (this.mounted) |
|
|
|
{ |
|
|
|
internal void _remove(OverlayEntry entry) { |
|
|
|
if (this.mounted) { |
|
|
|
this.setState(() => |
|
|
|
{ |
|
|
|
this.setState(() => { |
|
|
|
public bool debugIsVisible(OverlayEntry entry) |
|
|
|
{ |
|
|
|
public bool debugIsVisible(OverlayEntry entry) { |
|
|
|
D.assert(() => |
|
|
|
{ |
|
|
|
for (int i = this._entries.Count - 1; i > 0; i -= 1) |
|
|
|
{ |
|
|
|
D.assert(() => { |
|
|
|
for (int i = this._entries.Count - 1; i > 0; i -= 1) { |
|
|
|
if (candidate == entry) |
|
|
|
{ |
|
|
|
if (candidate == entry) { |
|
|
|
result = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
internal void _didChangeEntryOpacity() |
|
|
|
{ |
|
|
|
internal void _didChangeEntryOpacity() { |
|
|
|
public override Widget build(BuildContext context) |
|
|
|
{ |
|
|
|
public override Widget build(BuildContext context) { |
|
|
|
for (var i = this._entries.Count - 1; i >= 0; i -= 1) |
|
|
|
{ |
|
|
|
for (var i = this._entries.Count - 1; i >= 0; i -= 1) { |
|
|
|
if (onstage) |
|
|
|
{ |
|
|
|
if (onstage) { |
|
|
|
if (entry.opaque) |
|
|
|
{ |
|
|
|
onstage = false; |
|
|
|
} |
|
|
|
if (entry.opaque) onstage = false; |
|
|
|
else if (entry.maintainState) |
|
|
|
{ |
|
|
|
else if (entry.maintainState) { |
|
|
|
offstageChildren.Add(new TickerMode(enabled: false, child: new _OverlayEntry(entry))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class _Theatre : RenderObjectWidget |
|
|
|
{ |
|
|
|
internal _Theatre(Stack onstage = null, List<Widget> offstage = null) |
|
|
|
{ |
|
|
|
internal class _Theatre : RenderObjectWidget { |
|
|
|
internal _Theatre(Stack onstage = null, List<Widget> offstage = null) { |
|
|
|
D.assert(offstage != null); |
|
|
|
D.assert(!offstage.Any((child) => child == null)); |
|
|
|
this.onstage = onstage; |
|
|
|
|
|
|
|
|
|
|
public readonly List<Widget> offstage; |
|
|
|
|
|
|
|
public override Element createElement() |
|
|
|
{ |
|
|
|
public override Element createElement() { |
|
|
|
public override RenderObject createRenderObject(BuildContext context) |
|
|
|
{ |
|
|
|
public override RenderObject createRenderObject(BuildContext context) { |
|
|
|
class _TheatreElement : RenderObjectElement |
|
|
|
{ |
|
|
|
public _TheatreElement(RenderObjectWidget widget) : base(widget) |
|
|
|
{ |
|
|
|
internal class _TheatreElement : RenderObjectElement { |
|
|
|
public _TheatreElement(RenderObjectWidget widget) : base(widget) { |
|
|
|
public new _Theatre widget |
|
|
|
{ |
|
|
|
get { return (_Theatre) base.widget; } |
|
|
|
} |
|
|
|
public new _Theatre widget => (_Theatre) base.widget; |
|
|
|
public new _RenderTheatre renderObject |
|
|
|
{ |
|
|
|
get { return (_RenderTheatre) base.renderObject; } |
|
|
|
} |
|
|
|
public new _RenderTheatre renderObject => (_RenderTheatre) base.renderObject; |
|
|
|
|
|
|
|
Element _onstage; |
|
|
|
static readonly object _onstageSlot = new object(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void insertChildRenderObject(RenderObject child, object slot) |
|
|
|
{ |
|
|
|
protected override void insertChildRenderObject(RenderObject child, object slot) { |
|
|
|
if (slot == _onstageSlot) |
|
|
|
{ |
|
|
|
if (slot == _onstageSlot) { |
|
|
|
else |
|
|
|
{ |
|
|
|
else { |
|
|
|
protected override void moveChildRenderObject(RenderObject child, object slot) |
|
|
|
{ |
|
|
|
if (slot == _onstageSlot) |
|
|
|
{ |
|
|
|
protected override void moveChildRenderObject(RenderObject child, object slot) { |
|
|
|
if (slot == _onstageSlot) { |
|
|
|
else |
|
|
|
{ |
|
|
|
else { |
|
|
|
if (this.renderObject.child == child) |
|
|
|
{ |
|
|
|
if (this.renderObject.child == child) { |
|
|
|
else |
|
|
|
{ |
|
|
|
else { |
|
|
|
protected override void removeChildRenderObject(RenderObject child) |
|
|
|
{ |
|
|
|
protected override void removeChildRenderObject(RenderObject child) { |
|
|
|
{ |
|
|
|
} |
|
|
|
{ |
|
|
|
} |
|
|
|
public override void visitChildren(ElementVisitor visitor) |
|
|
|
{ |
|
|
|
public override void visitChildren(ElementVisitor visitor) { |
|
|
|
{ |
|
|
|
} |
|
|
|
public override void debugVisitOnstageChildren(ElementVisitor visitor) |
|
|
|
{ |
|
|
|
public override void debugVisitOnstageChildren(ElementVisitor visitor) { |
|
|
|
protected override void forgetChild(Element child) |
|
|
|
{ |
|
|
|
if (child == this._onstage) |
|
|
|
{ |
|
|
|
protected override void forgetChild(Element child) { |
|
|
|
if (child == this._onstage) { |
|
|
|
else |
|
|
|
{ |
|
|
|
else { |
|
|
|
D.assert(this._offstage.Contains(child)); |
|
|
|
D.assert(!this._forgottenOffstageChildren.Contains(child)); |
|
|
|
this._forgottenOffstageChildren.Add(child); |
|
|
|
|
|
|
public override void mount(Element parent, object newSlot) |
|
|
|
{ |
|
|
|
public override void mount(Element parent, object newSlot) { |
|
|
|
for (int i = 0; i < this._offstage.Count; i += 1) |
|
|
|
{ |
|
|
|
for (int i = 0; i < this._offstage.Count; i += 1) { |
|
|
|
var newChild = this.inflateWidget(this.widget.offstage[i], previousChild); |
|
|
|
this._offstage[i] = newChild; |
|
|
|
previousChild = newChild; |
|
|
|
|
|
|
public override void update(Widget newWidget) |
|
|
|
{ |
|
|
|
public override void update(Widget newWidget) { |
|
|
|
this._offstage = this.updateChildren(this._offstage, this.widget.offstage, forgottenChildren: this._forgottenOffstageChildren); |
|
|
|
this._offstage = this.updateChildren(this._offstage, this.widget.offstage, |
|
|
|
forgottenChildren: this._forgottenOffstageChildren); |
|
|
|
class _RenderTheatre : ContainerRenderObjectMixinRenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack< |
|
|
|
RenderBox, StackParentData> |
|
|
|
{ |
|
|
|
public override void setupParentData(RenderObject child) |
|
|
|
{ |
|
|
|
internal class _RenderTheatre : |
|
|
|
ContainerRenderObjectMixinRenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack< |
|
|
|
RenderBox, StackParentData> { |
|
|
|
public override void setupParentData(RenderObject child) { |
|
|
|
public override void redepthChildren() |
|
|
|
{ |
|
|
|
public override void redepthChildren() { |
|
|
|
public override void visitChildren(RenderObjectVisitor visitor) |
|
|
|
{ |
|
|
|
public override void visitChildren(RenderObjectVisitor visitor) { |
|
|
|
public override List<DiagnosticsNode> debugDescribeChildren() |
|
|
|
{ |
|
|
|
public override List<DiagnosticsNode> debugDescribeChildren() { |
|
|
|
if (this.firstChild != null) |
|
|
|
{ |
|
|
|
if (this.firstChild != null) { |
|
|
|
while (true) |
|
|
|
{ |
|
|
|
while (true) { |
|
|
|
children.Add( |
|
|
|
child.toDiagnosticsNode( |
|
|
|
name: $"offstage {count}", |
|
|
|
|
|
|
count += 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
else { |
|
|
|
children.Add( |
|
|
|
DiagnosticsNode.message( |
|
|
|
"no offstage children", |
|
|
|