kg
6 年前
当前提交
70cc57ee
共有 17 个文件被更改,包括 668 次插入 和 135 次删除
-
5Assets/UIWidgets/Tests/Menu.cs
-
2Assets/UIWidgets/foundation/debug.cs
-
118Assets/UIWidgets/foundation/diagnostics.cs
-
57Assets/UIWidgets/foundation/node.cs
-
11Assets/UIWidgets/gestures/binding.cs
-
78Assets/UIWidgets/gestures/events.cs
-
25Assets/UIWidgets/rendering/binding.cs
-
22Assets/UIWidgets/rendering/box.cs
-
33Assets/UIWidgets/rendering/object.cs
-
92Assets/UIWidgets/rendering/proxy_box.cs
-
2Assets/UIWidgets/rendering/sliver_multi_box_adaptor.cs
-
90Assets/UIWidgets/Tests/Gestures.cs
-
3Assets/UIWidgets/Tests/Gestures.cs.meta
-
163Assets/UIWidgets/foundation/node.mixin.gen.cs
-
11Assets/UIWidgets/foundation/node.mixin.gen.cs.meta
-
88Assets/UIWidgets/foundation/node.mixin.njk
-
3Assets/UIWidgets/foundation/node.mixin.njk.meta
|
|||
namespace UIWidgets.foundation { |
|||
public class AbstractNode { |
|||
public int depth { |
|||
get { return this._depth; } |
|||
} |
|||
|
|||
public int _depth = 0; |
|||
|
|||
public void redepthChild(AbstractNode child) { |
|||
if (child._depth <= this._depth) { |
|||
child._depth = this._depth + 1; |
|||
child.redepthChildren(); |
|||
} |
|||
} |
|||
|
|||
public virtual void redepthChildren() { |
|||
} |
|||
|
|||
public object owner { |
|||
get { return this._owner; } |
|||
} |
|||
|
|||
public object _owner; |
|||
|
|||
public bool attached { |
|||
get { return this._owner != null; } |
|||
} |
|||
|
|||
public virtual void attach(object owner) { |
|||
this._owner = owner; |
|||
} |
|||
|
|||
public virtual void detach() { |
|||
this._owner = null; |
|||
} |
|||
|
|||
public AbstractNode parent { |
|||
get { return this._parent; } |
|||
} |
|||
|
|||
public AbstractNode _parent; |
|||
|
|||
public virtual void adoptChild(AbstractNode child) { |
|||
child._parent = this; |
|||
if (this.attached) { |
|||
child.attach(this._owner); |
|||
} |
|||
|
|||
this.redepthChild(child); |
|||
} |
|||
|
|||
public virtual void dropChild(AbstractNode child) { |
|||
child._parent = null; |
|||
if (this.attached) { |
|||
child.detach(); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Linq; |
|||
using UIWidgets.editor; |
|||
using UIWidgets.gestures; |
|||
using UIWidgets.painting; |
|||
using UIWidgets.rendering; |
|||
using UIWidgets.ui; |
|||
using UnityEditor; |
|||
using UnityEngine; |
|||
using Color=UIWidgets.ui.Color; |
|||
|
|||
namespace UIWidgets.Tests { |
|||
public class Gestures : EditorWindow { |
|||
private readonly Func<RenderBox>[] _options; |
|||
|
|||
private readonly string[] _optionStrings; |
|||
|
|||
private int _selected; |
|||
|
|||
Gestures() { |
|||
this._options = new Func<RenderBox>[] { |
|||
this.tap, |
|||
}; |
|||
this._optionStrings = this._options.Select(x => x.Method.Name).ToArray(); |
|||
this._selected = 0; |
|||
|
|||
this.titleContent = new GUIContent("Gestures"); |
|||
} |
|||
|
|||
private WindowAdapter windowAdapter; |
|||
|
|||
private RendererBindings rendererBindings; |
|||
|
|||
[NonSerialized] private bool hasInvoked = false; |
|||
|
|||
void OnGUI() { |
|||
var selected = EditorGUILayout.Popup("test case", this._selected, this._optionStrings); |
|||
if (selected != this._selected || !this.hasInvoked) { |
|||
this._selected = selected; |
|||
this.hasInvoked = true; |
|||
|
|||
var renderBox = this._options[this._selected](); |
|||
this.rendererBindings.setRoot(renderBox); |
|||
} |
|||
|
|||
if (this.windowAdapter != null) { |
|||
this.windowAdapter.OnGUI(); |
|||
} |
|||
} |
|||
|
|||
void Update() { |
|||
if (this.windowAdapter != null) { |
|||
this.windowAdapter.Update(); |
|||
} |
|||
} |
|||
|
|||
private void OnEnable() { |
|||
this.windowAdapter = new WindowAdapter(this); |
|||
this.rendererBindings = new RendererBindings(this.windowAdapter); |
|||
|
|||
this._tapRecognizer = new TapGestureRecognizer(this.rendererBindings.gestureBinding); |
|||
this._tapRecognizer.onTap = () => { Debug.Log("tap"); }; |
|||
} |
|||
|
|||
void OnDestroy() { |
|||
this.windowAdapter = null; |
|||
this.rendererBindings = null; |
|||
} |
|||
|
|||
TapGestureRecognizer _tapRecognizer; |
|||
|
|||
void _handlePointerDown(PointerDownEvent evt) { |
|||
this._tapRecognizer.addPointer(evt); |
|||
} |
|||
|
|||
RenderBox tap() { |
|||
return new RenderPointerListener( |
|||
onPointerDown: this._handlePointerDown, |
|||
behavior: HitTestBehavior.opaque, |
|||
child: new RenderConstrainedBox( |
|||
additionalConstraints: BoxConstraints.tight(Size.square(100)), |
|||
child: new RenderDecoratedBox( |
|||
decoration: new BoxDecoration( |
|||
color: new Color(0xFF00FF00) |
|||
) |
|||
)) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b6e93a3e08aa4ed49ebe367645f04fd9 |
|||
timeCreated: 1536304600 |
|
|||
namespace UIWidgets.foundation { |
|||
|
|||
|
|||
|
|||
|
|||
public class AbstractNode { |
|||
public int depth { |
|||
get { return this._depth; } |
|||
} |
|||
|
|||
int _depth = 0; |
|||
|
|||
protected void redepthChild(AbstractNode child) { |
|||
D.assert(child.owner == this.owner); |
|||
if (child._depth <= this._depth) { |
|||
child._depth = this._depth + 1; |
|||
child.redepthChildren(); |
|||
} |
|||
} |
|||
|
|||
public virtual void redepthChildren() { |
|||
} |
|||
|
|||
public object owner { |
|||
get { return this._owner; } |
|||
} |
|||
|
|||
object _owner; |
|||
|
|||
public bool attached { |
|||
get { return this._owner != null; } |
|||
} |
|||
|
|||
public virtual void attach(object owner) { |
|||
D.assert(owner != null); |
|||
D.assert(this._owner == null); |
|||
this._owner = owner; |
|||
} |
|||
|
|||
public virtual void detach() { |
|||
D.assert(this._owner != null); |
|||
this._owner = null; |
|||
} |
|||
|
|||
public AbstractNode parent { |
|||
get { return this._parent; } |
|||
} |
|||
|
|||
AbstractNode _parent; |
|||
|
|||
protected virtual void adoptChild(AbstractNode child) { |
|||
D.assert(child != null); |
|||
D.assert(child._parent == null); |
|||
D.assert(() => { |
|||
var node = this; |
|||
while (node.parent != null) |
|||
node = node.parent; |
|||
D.assert(node != child); // indicates we are about to create a cycle
|
|||
return true; |
|||
}); |
|||
|
|||
child._parent = this; |
|||
if (this.attached) { |
|||
child.attach(this._owner); |
|||
} |
|||
|
|||
this.redepthChild(child); |
|||
} |
|||
|
|||
protected virtual void dropChild(AbstractNode child) { |
|||
D.assert(child != null); |
|||
D.assert(child._parent == this); |
|||
D.assert(child.attached == this.attached); |
|||
|
|||
child._parent = null; |
|||
if (this.attached) { |
|||
child.detach(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
public class AbstractNodeMixinDiagnosticableTree : DiagnosticableTree { |
|||
public int depth { |
|||
get { return this._depth; } |
|||
} |
|||
|
|||
int _depth = 0; |
|||
|
|||
protected void redepthChild(AbstractNodeMixinDiagnosticableTree child) { |
|||
D.assert(child.owner == this.owner); |
|||
if (child._depth <= this._depth) { |
|||
child._depth = this._depth + 1; |
|||
child.redepthChildren(); |
|||
} |
|||
} |
|||
|
|||
public virtual void redepthChildren() { |
|||
} |
|||
|
|||
public object owner { |
|||
get { return this._owner; } |
|||
} |
|||
|
|||
object _owner; |
|||
|
|||
public bool attached { |
|||
get { return this._owner != null; } |
|||
} |
|||
|
|||
public virtual void attach(object owner) { |
|||
D.assert(owner != null); |
|||
D.assert(this._owner == null); |
|||
this._owner = owner; |
|||
} |
|||
|
|||
public virtual void detach() { |
|||
D.assert(this._owner != null); |
|||
this._owner = null; |
|||
} |
|||
|
|||
public AbstractNodeMixinDiagnosticableTree parent { |
|||
get { return this._parent; } |
|||
} |
|||
|
|||
AbstractNodeMixinDiagnosticableTree _parent; |
|||
|
|||
protected virtual void adoptChild(AbstractNodeMixinDiagnosticableTree child) { |
|||
D.assert(child != null); |
|||
D.assert(child._parent == null); |
|||
D.assert(() => { |
|||
var node = this; |
|||
while (node.parent != null) |
|||
node = node.parent; |
|||
D.assert(node != child); // indicates we are about to create a cycle
|
|||
return true; |
|||
}); |
|||
|
|||
child._parent = this; |
|||
if (this.attached) { |
|||
child.attach(this._owner); |
|||
} |
|||
|
|||
this.redepthChild(child); |
|||
} |
|||
|
|||
protected virtual void dropChild(AbstractNodeMixinDiagnosticableTree child) { |
|||
D.assert(child != null); |
|||
D.assert(child._parent == this); |
|||
D.assert(child.attached == this.attached); |
|||
|
|||
child._parent = null; |
|||
if (this.attached) { |
|||
child.detach(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b7a18c2b3beb04ccba0b8585c1cdb618 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UIWidgets.foundation { |
|||
{% macro AbstractNodeMixin(with) %} |
|||
{% set className = 'AbstractNode' if with == '' else 'AbstractNodeMixin' + with %} |
|||
|
|||
{% set extends = '' if with == '' else ' : ' + with %} |
|||
|
|||
public class {{className}} {{extends}} { |
|||
public int depth { |
|||
get { return this._depth; } |
|||
} |
|||
|
|||
int _depth = 0; |
|||
|
|||
protected void redepthChild({{className}} child) { |
|||
D.assert(child.owner == this.owner); |
|||
if (child._depth <= this._depth) { |
|||
child._depth = this._depth + 1; |
|||
child.redepthChildren(); |
|||
} |
|||
} |
|||
|
|||
public virtual void redepthChildren() { |
|||
} |
|||
|
|||
public object owner { |
|||
get { return this._owner; } |
|||
} |
|||
|
|||
object _owner; |
|||
|
|||
public bool attached { |
|||
get { return this._owner != null; } |
|||
} |
|||
|
|||
public virtual void attach(object owner) { |
|||
D.assert(owner != null); |
|||
D.assert(this._owner == null); |
|||
this._owner = owner; |
|||
} |
|||
|
|||
public virtual void detach() { |
|||
D.assert(this._owner != null); |
|||
this._owner = null; |
|||
} |
|||
|
|||
public {{className}} parent { |
|||
get { return this._parent; } |
|||
} |
|||
|
|||
{{className}} _parent; |
|||
|
|||
protected virtual void adoptChild({{className}} child) { |
|||
D.assert(child != null); |
|||
D.assert(child._parent == null); |
|||
D.assert(() => { |
|||
var node = this; |
|||
while (node.parent != null) |
|||
node = node.parent; |
|||
D.assert(node != child); // indicates we are about to create a cycle |
|||
return true; |
|||
}); |
|||
|
|||
child._parent = this; |
|||
if (this.attached) { |
|||
child.attach(this._owner); |
|||
} |
|||
|
|||
this.redepthChild(child); |
|||
} |
|||
|
|||
protected virtual void dropChild({{className}} child) { |
|||
D.assert(child != null); |
|||
D.assert(child._parent == this); |
|||
D.assert(child.attached == this.attached); |
|||
|
|||
child._parent = null; |
|||
if (this.attached) { |
|||
child.detach(); |
|||
} |
|||
} |
|||
} |
|||
{% endmacro %} |
|||
|
|||
{{ AbstractNodeMixin('') }} |
|||
|
|||
{{ AbstractNodeMixin('DiagnosticableTree') }} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3169ab76e1bc45cf92b23f07f2688b62 |
|||
timeCreated: 1536301833 |
撰写
预览
正在加载...
取消
保存
Reference in new issue